Class: CBin::BuildAll::ZipFileHelper
- Inherits:
-
Object
- Object
- CBin::BuildAll::ZipFileHelper
- Includes:
- Pod
- Defined in:
- lib/cocoapods-mtxx-bin/helpers/buildAll/zip_file_helper.rb
Instance Method Summary collapse
-
#initialize(pod_target, version, product_dir, build_as_framework = false, configuration = 'Debug') ⇒ ZipFileHelper
constructor
A new instance of ZipFileHelper.
-
#upload_zip_lib ⇒ Object
上传静态库.
- #version ⇒ Object
-
#zip_file_name ⇒ Object
zip文件名字.
-
#zip_lib ⇒ Object
压缩静态库.
Methods included from Pod
Constructor Details
#initialize(pod_target, version, product_dir, build_as_framework = false, configuration = 'Debug') ⇒ ZipFileHelper
Returns a new instance of ZipFileHelper.
9 10 11 12 13 14 15 |
# File 'lib/cocoapods-mtxx-bin/helpers/buildAll/zip_file_helper.rb', line 9 def initialize(pod_target, version, product_dir, build_as_framework = false, configuration = 'Debug') @pod_target = pod_target @version = version @product_dir = product_dir @build_as_framework = build_as_framework @configuration = configuration end |
Instance Method Details
#upload_zip_lib ⇒ Object
上传静态库
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/cocoapods-mtxx-bin/helpers/buildAll/zip_file_helper.rb', line 18 def upload_zip_lib Dir.chdir(@product_dir) do zip_file = File.join(Dir.pwd, "#{zip_file_name}") unless File.exist?(zip_file) UI.info "`#{Dir.pwd}`目录下无`#{zip_file_name}`文件".red return false end UI.info "Uploading binary zip file `#{@pod_target.root_spec.name} (#{version})`".yellow do upload_url = CBin.config.binary_upload_url_str xcode_version = BinHelper.xcode_version command = "curl -F \"name=#{@pod_target.product_module_name}\" -F \"version=#{version}\" -F \"xcode_version=#{xcode_version}\" -F \"configuration=#{@configuration}\" -F \"file=@#{zip_file}\" #{upload_url}" UI.info "#{command}" json = `#{command}` UI.info json begin success = JSON.parse(json)["success"] if success Pod::UI.info "#{@pod_target.root_spec.name} (#{version}) 上传成功".green return true else Pod::UI.info "#{@pod_target.root_spec.name} (#{version}) 上传失败".red return false end rescue JSON::ParserError => e Pod::UI.info "#{@pod_target.root_spec.name} (#{version}) 上传失败".red Pod::UI.info "#{e.to_s}".red return false end end end end |
#version ⇒ Object
81 82 83 |
# File 'lib/cocoapods-mtxx-bin/helpers/buildAll/zip_file_helper.rb', line 81 def version @version || @pod_target.root_spec.version end |
#zip_file_name ⇒ Object
zip文件名字
75 76 77 78 79 |
# File 'lib/cocoapods-mtxx-bin/helpers/buildAll/zip_file_helper.rb', line 75 def zip_file_name @zip_file_name ||= begin "#{@pod_target.framework_name}_#{@version || @pod_target.root_spec.version}.zip" end end |
#zip_lib ⇒ Object
压缩静态库
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/cocoapods-mtxx-bin/helpers/buildAll/zip_file_helper.rb', line 51 def zip_lib Dir.chdir(@product_dir) do input_library = "#{@pod_target.framework_name}" output_library = File.join(Dir.pwd, zip_file_name) FileUtils.rm_f(output_library) if File.exist?(output_library) unless File.exist?(input_library) UI.info "没有需要压缩的二进制文件:`#{input_library}`".red return false end UI.info "Compressing `#{input_library}` into `#{zip_file_name}`".yellow do command = "zip --symlinks -r #{output_library} #{input_library}" UI.info "#{command}" `#{command}` unless File.exist?(output_library) UI.info "压缩`#{output_library}`失败".red return false end return true end end end |