Class: Pod::Command::Binary::Lint

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

Constant Summary

Constants inherited from Pod::Command::Binary

FIRE_FLAG

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Pod::Command::Binary

#fire_sources, #first_podspec

Constructor Details

#initialize(argv) ⇒ Lint

Returns a new instance of Lint.



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

def initialize(argv)
  @clean = argv.flag?('clean')
  @sources = argv.option('sources')
  @spec_file = first_podspec
  @spec_name = @spec_file.split('/').last.split('.').first
  unzip_framework
  super
end

Class Method Details

.optionsObject



13
14
15
16
17
18
# File 'lib/cocoapods-tdfire-binary/command/lint.rb', line 13

def self.options
  [
      ['--sources', '私有源地址'],
      ['--clean', '执行成功后,删除 zip 文件外的所有生成文件'],
  ].concat(super)
end

Instance Method Details

#runObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/cocoapods-tdfire-binary/command/lint.rb', line 44

def run
  Tdfire::BinaryStateStore.lib_lint_binary_pod = @spec_name

  argvs = [
      "--sources=#{@sources || Tdfire::BinaryUrlManager.private_cocoapods_url}",
      '--allow-warnings',
      '--use-libraries',
      '--verbose'
  ]

  lint= Pod::Command::Lib::Lint.new(CLAide::ARGV.new(argvs))
  lint.validate!
  lint.run

  system "rm -fr #{@spec_name}.framework " if @clean
end

#unzip_frameworkObject



36
37
38
39
40
41
42
# File 'lib/cocoapods-tdfire-binary/command/lint.rb', line 36

def unzip_framework
  framework = "#{@spec_name}.framework"
  zip_name = "#{framework}.zip"
  if File.exist?(zip_name) && !File.exist?("#{@spec_name}.framework")
    system "unzip #{zip_name}"
  end
end

#validate!Object



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

def validate!
  super
  help! '当前目录下没有podspec文件.' if @spec_file.nil?
  framework = "#{@spec_name}.framework"
  help! "当前目录下没有#{framework}文件" unless File.exist?(framework)
end