Class: Pod::Command::Mod::Template

Inherits:
Pod::Command::Mod show all
Defined in:
lib/cocoapods-modularization/command/mod/template.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Template

Returns a new instance of Template.



21
22
23
24
25
# File 'lib/cocoapods-modularization/command/mod/template.rb', line 21

def initialize(argv)
  @binary = argv.flag?('binary-only')
  @framework = argv.flag?('framework-only')
  super
end

Class Method Details

.optionsObject



14
15
16
17
18
19
# File 'lib/cocoapods-modularization/command/mod/template.rb', line 14

def self.options 
  [
    ['--binary-only', '把framework推送到source和binary,一般用于三方库本地化'],
    ['--framework-only', '把Binary/*framework推送到source和binary,一般用于私有库']
  ].concat(super)
end

Instance Method Details

#runObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/cocoapods-modularization/command/mod/template.rb', line 31

def run
  build_path = "#{Dir.pwd}/build.rb"
  if File.exist?(build_path)
    FileUtils.rm_rf(build_path)
  end

  `git clone [email protected]:shared-specs/template.git .build`

  unless File.exist?("#{Dir.pwd}/.build")
    puts "./.build not found"
    return
  end

  if @binary
    FileUtils.mv("#{Dir.pwd}/.build/Binary/binary_only.rb", "#{Dir.pwd}/build.rb")
  elsif @framework
    FileUtils.mv("#{Dir.pwd}/.build/Binary/framework_only.rb", "#{Dir.pwd}/build.rb")
  else
    FileUtils.mv("#{Dir.pwd}/.build/build.rb", "#{Dir.pwd}/build.rb")
  end
  FileUtils.rm_rf("#{Dir.pwd}/.build")
end

#validate!Object



27
28
29
# File 'lib/cocoapods-modularization/command/mod/template.rb', line 27

def validate!
  super
end