Class: Ocean::Upload::Helper

Inherits:
Object
  • Object
show all
Includes:
SourcesHelper
Defined in:
lib/swordfish/helpers/upload_helper.rb

Instance Method Summary collapse

Methods included from SourcesHelper

#binary_source, #code_source, #sources_manager, #sources_option, #valid_sources

Constructor Details

#initialize(spec, code_dependencies, sources) ⇒ Helper

Returns a new instance of Helper.



20
21
22
23
24
# File 'lib/swordfish/helpers/upload_helper.rb', line 20

def initialize(spec,code_dependencies,sources)
  @spec = spec
  @code_dependencies = code_dependencies
  @sources = sources
end

Instance Method Details

#curl_zipObject

推送二进制 curl ci.xxx:9192/frameworks -F “name=IMYFoundation” -F “version=7.7.4.2” -F “annotate=IMYFoundation_7.7.4.2_log” -F “file=@bin-zip/bin_IMYFoundation_7.7.4.2.zip”



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/swordfish/helpers/upload_helper.rb', line 50

def curl_zip
  zip_file = "#{Ocean::Config::Builder.instance.library_file(@spec)}.zip"
  res = File.exist?(zip_file)
  unless res
    zip_file = Ocean::Config::Builder.instance.framework_zip_file(@spec) + ".zip"
    res = File.exist?(zip_file)
  end
  if res
    command = "curl #{Ocean.config.binary_upload_url} -F \"name=#{@spec.name}\" -F \"version=#{@spec.version}\" -F \"annotate=#{@spec.name}_#{@spec.version}_log\" -F \"file=@#{zip_file}\""
    print <<EOF
    上传二进制文件
    #{command}
EOF
    upload_result = `#{command}`
    puts "#{upload_result}"
  end

  res
end

#push_binary_repo(binary_podsepc_json) ⇒ Object

上传二进制 podspec



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/swordfish/helpers/upload_helper.rb', line 72

def push_binary_repo(binary_podsepc_json)
  argvs = [
      "#{binary_podsepc_json}",
      "--binary",
      "--sources=#{sources_option(@code_dependencies, @sources)}",
      "--skip-import-validation",
      "--use-libraries",
      "--allow-warnings",
      "--verbose",
      "--code-dependencies"
  ]
  if @verbose
    argvs += ['--verbose']
  end

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

#spec_creator(is_framework) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/swordfish/helpers/upload_helper.rb', line 40

def spec_creator(is_framework)
  spec_creator = Ocean::SpecificationSource::Creator.new(@spec)
  spec_creator.create(is_framework)
  spec_creator.write_spec_file
  spec_creator.filename

end

#upload(is_framework) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/swordfish/helpers/upload_helper.rb', line 26

def upload(is_framework)
  Dir.chdir(Ocean::Config::Builder.instance.root_dir) do
    # 创建binary-template.podsepc
    # 上传二进制文件
    # 上传二进制 podspec
    res_zip = curl_zip
    if res_zip
      filename = spec_creator(is_framework)
      push_binary_repo(filename)
    end
    res_zip
  end
end