Class: Pod::Command::Binary::Publish

Inherits:
Pod::Command::Binary show all
Defined in:
lib/cocoapods-tdfire-binary/command/publish.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Pod::Command::Binary

#binary_config, #first_podspec, #private_sources

Constructor Details

#initialize(argv) ⇒ Publish

Returns a new instance of Publish.



21
22
23
24
25
26
27
28
# File 'lib/cocoapods-tdfire-binary/command/publish.rb', line 21

def initialize(argv)
  spec_file = argv.shift_argument
  @commit = argv.option('commit')

  spec_file = first_podspec if spec_file.nil?
  @spec_file = spec_file
  super
end

Class Method Details

.optionsObject



15
16
17
18
19
# File 'lib/cocoapods-tdfire-binary/command/publish.rb', line 15

def self.options
  [
    ['--commit="Fix some bugs"', '发布的 commit 信息']
  ].concat(super)
end

Instance Method Details

#runObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/cocoapods-tdfire-binary/command/publish.rb', line 35

def run
  spec = Specification.from_file(@spec_file)

  UI.section("Tdfire: start publishing #{spec.name} ...") do
    argvs = [
        private_sources.first.name,
        @spec_file,
        '--allow-warnings',
        '--use-libraries',
        '--verbose'
    ]
    argvs << %Q[--commit-message=#{commit_prefix(spec) + "\n" + @commit}] unless @commit.to_s.empty?

    push = Pod::Command::Repo::Push.new(CLAide::ARGV.new(argvs))
    push.validate!
    push.run

    raise Pod::StandardError, "执行 pod repo push 失败,错误信息 #{$?}" if $?.exitstatus != 0
  end
end

#validate!Object



30
31
32
33
# File 'lib/cocoapods-tdfire-binary/command/publish.rb', line 30

def validate!
  super
  help! "当前目录下找不到有效的 podspec 文件" if @spec_file.nil?
end