class Pod::Command::Bin::Archive
Public Class Methods
new(argv)
click to toggle source
Calls superclass method
Pod::Command::Bin::new
# File lib/cocoapods-miBin/command/bin/archive.rb, line 31 def initialize(argv) @code_dependencies = argv.flag?('code-dependencies') @allow_prerelease = argv.flag?('allow-prerelease') @clean = argv.flag?('clean', true) @zip = argv.flag?('zip', true) @sources = argv.option('sources') || [] @platform = Platform.new(:ios) super @additional_args = argv.remainder! end
options()
click to toggle source
Calls superclass method
# File lib/cocoapods-miBin/command/bin/archive.rb, line 18 def self.options [ ['--code-dependencies', '使用源码依赖'], ['--allow-prerelease', '允许使用 prerelease 的版本'], ['--no-clean', '保留构建中间产物'], ['--no-zip', '不压缩静态 framework 为 zip'] ].concat(Pod::Command::Gen.options).concat(super).uniq end
Public Instance Methods
run()
click to toggle source
# File lib/cocoapods-miBin/command/bin/archive.rb, line 43 def run @spec = Specification.from_file(spec_file) generate_project build_static_framework zip_static_framework if @zip clean_workspace if @clean end
Private Instance Methods
binary_name()
click to toggle source
# File lib/cocoapods-miBin/command/bin/archive.rb, line 109 def binary_name "#{@spec.name}_binary" end
build_static_framework()
click to toggle source
# File lib/cocoapods-miBin/command/bin/archive.rb, line 85 def build_static_framework source_dir = Dir.pwd file_accessor = Sandbox::FileAccessor.new(Pathname.new('.').expand_path, @spec.consumer(@platform)) Dir.chdir(workspace_directory) do builder = CBin::Framework::Builder.new(@spec, file_accessor, @platform, source_dir) builder.build end end
clean_workspace()
click to toggle source
# File lib/cocoapods-miBin/command/bin/archive.rb, line 94 def clean_workspace UI.puts 'Cleaning workspace' FileUtils.rm_rf(gen_name) FileUtils.rm_rf(binary_name) if @zip end
framework_name()
click to toggle source
# File lib/cocoapods-miBin/command/bin/archive.rb, line 105 def framework_name "#{@spec.name}.framework" end
gen_name()
click to toggle source
# File lib/cocoapods-miBin/command/bin/archive.rb, line 101 def gen_name 'bin-archive' end
generate_project()
click to toggle source
# File lib/cocoapods-miBin/command/bin/archive.rb, line 53 def generate_project Podfile.execute_with_bin_plugin do Podfile.execute_with_allow_prerelease(@allow_prerelease) do Podfile.execute_with_use_binaries(!@code_dependencies) do argvs = [ "--sources=#{sources_option(@code_dependencies, @sources)}", "--gen-directory=#{gen_name}", '--clean', *@additional_args ] argvs << spec_file if spec_file gen = Pod::Command::Gen.new(CLAide::ARGV.new(argvs)) gen.validate! gen.run end end end end
spec_file()
click to toggle source
# File lib/cocoapods-miBin/command/bin/archive.rb, line 117 def spec_file @spec_file ||= begin if @podspec find_spec_file(@podspec) else if code_spec_files.empty? raise Informative, '当前目录下没有找到可用源码 podspec.' end spec_file = code_spec_files.first spec_file end end end
workspace_directory()
click to toggle source
# File lib/cocoapods-miBin/command/bin/archive.rb, line 113 def workspace_directory File.expand_path("./#{gen_name}/#{@spec.name}") end
zip_static_framework()
click to toggle source
# File lib/cocoapods-miBin/command/bin/archive.rb, line 74 def zip_static_framework output_name = "#{binary_name}.zip" unless File.exist?(binary_name) raise Informative, "没有需要压缩的 framework 文件:#{binary_name}" end UI.puts "Compressing #{binary_name} into #{output_name}" `zip --symlinks -r #{output_name} #{binary_name}` end