Class: Pod::Command::Nexus::Push
- Inherits:
-
Pod::Command::Nexus
- Object
- Pod::Command
- Pod::Command::Nexus
- Pod::Command::Nexus::Push
- Defined in:
- lib/cocoapods-nexus/command/nexus/push.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ Push
constructor
A new instance of Push.
- #run ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(argv) ⇒ Push
Returns a new instance of Push.
25 26 27 28 29 30 31 |
# File 'lib/cocoapods-nexus/command/nexus/push.rb', line 25 def initialize(argv) @podspec = argv.shift_argument @url = argv.option('url') @repo = argv.option('repo') @artifact = argv.option('artifact') super end |
Class Method Details
.options ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/cocoapods-nexus/command/nexus/push.rb', line 17 def self. [ ['--url=url', 'a nexus hostname'], ['--repo=repo', 'a nexus repo'], ['--artifact=artifact', 'a nexus artifact'] ].concat(super) end |
Instance Method Details
#run ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/cocoapods-nexus/command/nexus/push.rb', line 40 def run podspec_path = File.(@podspec) artifact_path = File.(@artifact) unless @artifact.nil? UI.section("开始发布 #{File.basename(@podspec)} -> #{@url}/nexus/#browse/browse:#{@repo}") do spec = Specification.from_file(podspec_path) artifact_id = spec.attributes_hash['name'] version = spec.attributes_hash['version'] group_id = 'Specs' if nexus_api.upload_maven_component(artifact_id: artifact_id, version: version, group_id: group_id, podspec: podspec_path, artifact: artifact_path, files: []) UI.puts "成功发布 #{artifact_id}(#{version})" else raise Informative, "发布失败 #{artifact_id}(#{version}),请检查~/.netrc文件或#{@repo}类型" end end end |
#validate! ⇒ Object
33 34 35 36 37 38 |
# File 'lib/cocoapods-nexus/command/nexus/push.rb', line 33 def validate! super help! 'A podspec is required.' unless @podspec && File.exist?(File.(@podspec)) help! 'A url is required.' unless @url help! 'A repo is required.' unless @repo end |