nexus_cli 4.0.3 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
+ .idea
1
2
  .DS_Store
2
3
  .rake_tasks~
3
4
  .project
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # 4.1.0
2
+
3
+ * [#92](https://github.com/RiotGames/nexus_cli/pull/92) Added a new task for gettting an artifact's download URL
4
+ * Add License to Gemspec
5
+
1
6
  # 4.0.3
2
7
 
3
8
  * Support old-style overriding of config file.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.0.3
1
+ 4.1.0
@@ -54,6 +54,14 @@ Feature: Use the Nexus CLI
54
54
  """
55
55
  And the exit status should be 0
56
56
 
57
+ Scenario: Get an artifact's download URL
58
+ When I call the nexus "get_artifact_download_url com.test:mytest" command
59
+ Then the output should contain:
60
+ """
61
+ com/test/mytest/1.0.0/mytest-1.0.0.tgz
62
+ """
63
+ And the exit status should be 0
64
+
57
65
  @transfer
58
66
  Scenario: Transfer an artifact between repositories
59
67
  When I call the nexus "transfer com.test:mytest:tgz:1.0.0 releases thirdparty" command
@@ -140,6 +140,30 @@ module NexusCli
140
140
  do_transfer_artifact(coordinates, from_repository, to_repository)
141
141
  end
142
142
 
143
+ # Gets the Nexus download URL for the given [artifact].
144
+ #
145
+ # @param coordinates [String] the Maven identifier
146
+ # @example com.artifact:my-artifact
147
+ #
148
+ # @return [String] The Nexus download url for the artifact
149
+ # @example
150
+ # https://nexus.my-domain.com/content/repositories/my-repository/my-artifact/1.0.0/my-artifact-1.0.0.tgz
151
+ def get_artifact_download_url(coordinates)
152
+ artifact = Artifact.new(coordinates)
153
+ query = {:g => artifact.group_id, :a => artifact.artifact_id, :e => artifact.extension, :v => artifact.version, :r => configuration['repository']}
154
+ query.merge!({:c => artifact.classifier}) unless artifact.classifier.nil?
155
+ response = nexus.get(nexus_url("service/local/artifact/maven/redirect"), :query => query)
156
+ case response.status
157
+ when 301, 307
158
+ # Follow redirect and return download URL.
159
+ return response.content.gsub(/If you are not automatically redirected use this url: /, "")
160
+ when 404
161
+ raise ArtifactNotFoundException
162
+ else
163
+ raise UnexpectedStatusCodeException.new(response.status)
164
+ end
165
+ end
166
+
143
167
  private
144
168
 
145
169
  # Formats the given XML into an [Array<String>] so it
@@ -433,6 +433,11 @@ module NexusCli
433
433
  end
434
434
  end
435
435
 
436
+ desc "get_artifact_download_url coordinates", "Gets the Nexus download URL for the given artifact."
437
+ def get_artifact_download_url(coordinates)
438
+ say nexus_remote.get_artifact_download_url(coordinates), :green
439
+ end
440
+
436
441
  private
437
442
 
438
443
  def nexus_remote
data/nexus_cli.gemspec CHANGED
@@ -10,6 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.homepage = "https://github.com/RiotGames/nexus_cli"
11
11
  s.summary = %q{A command-line wrapper for making REST calls to Sonatype Nexus.}
12
12
  s.description = s.summary
13
+ s.licenses = ["Apache 2.0"]
13
14
 
14
15
  s.files = `git ls-files`.split("\n")
15
16
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -75,4 +75,9 @@ describe NexusCli do
75
75
  stub_request(:get, "http://admin:admin123@localhost:8081/nexus/service/local/data_index?a=something&g=com.something").to_return(:status => 200, :body => fake_xml, :headers => {})
76
76
  remote.search_for_artifacts("com.something:something").should eq fake_xml
77
77
  end
78
+
79
+ it "gives you errors when you attempt to get an artifact's download url and it cannot be found" do
80
+ HTTPClient.any_instance.stub(:get).and_raise(NexusCli::ArtifactNotFoundException)
81
+ expect {remote.get_artifact_download_url "com.something:something:tgz:1.0.0"}.to raise_error(NexusCli::ArtifactNotFoundException)
82
+ end
78
83
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nexus_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.3
4
+ version: 4.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-09 00:00:00.000000000 Z
12
+ date: 2013-10-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
@@ -275,7 +275,8 @@ files:
275
275
  - spec/unit/nexus_cli/pro_remote_spec.rb
276
276
  - spec/unit/nexus_cli/remote_factory_spec.rb
277
277
  homepage: https://github.com/RiotGames/nexus_cli
278
- licenses: []
278
+ licenses:
279
+ - Apache 2.0
279
280
  post_install_message:
280
281
  rdoc_options: []
281
282
  require_paths:
@@ -288,7 +289,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
288
289
  version: '0'
289
290
  segments:
290
291
  - 0
291
- hash: 1086708981034420466
292
+ hash: -445078072146336837
292
293
  required_rubygems_version: !ruby/object:Gem::Requirement
293
294
  none: false
294
295
  requirements:
@@ -297,7 +298,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
297
298
  version: '0'
298
299
  segments:
299
300
  - 0
300
- hash: 1086708981034420466
301
+ hash: -445078072146336837
301
302
  requirements: []
302
303
  rubyforge_project:
303
304
  rubygems_version: 1.8.23