rnexus 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,16 +2,16 @@
2
2
 
3
3
  A ruby wrapper to perform actions against the Nexus maven repository manager
4
4
 
5
- == Synopsis
5
+ == Install
6
+
7
+ sudo gem install rnexus
8
+
9
+ == Usage
6
10
 
7
11
  repo = Nexus::Repository.new("http://path/to/nexus")
8
12
  artifacts = repo.find_artifacts(:group => 'org.mockito', :name => 'mockito', :type => 'jar')
9
13
  jar = repo.download_artifact(artifacts.first)
10
14
 
11
- == Install
12
-
13
- sudo gem install rnexus
14
-
15
15
  == Copyright
16
16
 
17
17
  Copyright (c) 2009 Darrin Holst. See LICENSE for details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -8,48 +8,48 @@ class Nexus::Repository
8
8
  :name => :a,
9
9
  :type => :p
10
10
  }
11
-
11
+
12
12
  def initialize(baseuri, username = nil, password = nil)
13
13
  @baseuri = baseuri
14
14
  @username = username
15
15
  @password = password
16
16
  end
17
-
17
+
18
18
  def find_artifacts(args)
19
19
  url = "#{@baseuri}/service/local/data_index/repo_groups/public?#{build_query_parameters_from(args)}"
20
20
  response = RestClient.get(url, :accept => 'application/json')
21
- Crack::JSON.parse(response)['data'].map {|data| Nexus::Artifact.new(data)}
21
+ Crack::JSON.parse(response.body)['data'].map {|data| Nexus::Artifact.new(data)}
22
22
  end
23
-
23
+
24
24
  def download(artifact)
25
25
  RestClient.get(artifact.uri)
26
26
  end
27
-
27
+
28
28
  def delete(artifact)
29
29
  url = "#{@baseuri}/service/local/repositories/#{artifact.repo}/content/#{artifact.group.gsub(/\./, '/')}/#{artifact.name}/#{artifact.version}/"
30
30
  RestClient::Resource.new(url, :user => @username, :password => @password).delete.code
31
31
  end
32
-
32
+
33
33
  private
34
-
34
+
35
35
  def build_query_parameters_from(args)
36
36
  raise "arguments must be a hash" unless args.is_a? Hash
37
37
 
38
38
  query_parameters = args.map do |entry|
39
39
  "#{nexus_parameter_for(entry.first)}=#{entry.last}"
40
40
  end.join("&")
41
-
41
+
42
42
  raise "must pass at least one argument #{nexus_parameters_to_s}" if query_parameters.empty?
43
-
43
+
44
44
  query_parameters
45
45
  end
46
-
46
+
47
47
  def nexus_parameter_for(parameter)
48
48
  nexus_param = NEXUS_PARAMETERS[parameter]
49
49
  raise "invalid argument passed, valid arguments are #{nexus_parameters_to_s}" unless nexus_param
50
50
  nexus_param
51
51
  end
52
-
52
+
53
53
  def nexus_parameters_to_s
54
54
  "(#{NEXUS_PARAMETERS.keys.join(', ')})"
55
55
  end
@@ -1,12 +1,15 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
1
4
  # -*- encoding: utf-8 -*-
2
5
 
3
6
  Gem::Specification.new do |s|
4
7
  s.name = %q{rnexus}
5
- s.version = "0.0.2"
8
+ s.version = "0.0.3"
6
9
 
7
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
11
  s.authors = ["Darrin Holst"]
9
- s.date = %q{2009-07-22}
12
+ s.date = %q{2010-05-27}
10
13
  s.email = %q{darrinholst@gmail.com}
11
14
  s.extra_rdoc_files = [
12
15
  "LICENSE",
@@ -31,7 +34,7 @@ Gem::Specification.new do |s|
31
34
  s.rdoc_options = ["--charset=UTF-8"]
32
35
  s.require_paths = ["lib"]
33
36
  s.rubyforge_project = %q{rnexus}
34
- s.rubygems_version = %q{1.3.4}
37
+ s.rubygems_version = %q{1.3.6}
35
38
  s.summary = %q{a ruby wrapper to interact with a nexus maven repository}
36
39
  s.test_files = [
37
40
  "test/artifact_test.rb",
@@ -55,3 +58,4 @@ Gem::Specification.new do |s|
55
58
  s.add_dependency(%q<crack>, [">= 0.1.3"])
56
59
  end
57
60
  end
61
+
@@ -21,28 +21,28 @@ class RepositoryTest < Test::Unit::TestCase
21
21
  ]
22
22
  }
23
23
  eos
24
-
24
+
25
25
  def setup
26
26
  @repository = Nexus::Repository.new("http://localhost/nexus", "user", "pass")
27
27
  end
28
-
28
+
29
29
  def test_find_artifacts_using_all_options
30
30
  expected_url = "http://localhost/nexus/service/local/data_index/repo_groups/public?a=artifact&g=group&p=war"
31
31
  FakeWeb.register_uri(:get, expected_url, :body => JSON)
32
32
  assert_artifacts @repository.find_artifacts(:group => 'group', :name => 'artifact', :type => 'war')
33
33
  end
34
-
34
+
35
35
  def test_find_artifacts_using_artifact_id_only
36
36
  expected_url = "http://localhost/nexus/service/local/data_index/repo_groups/public?a=artifact"
37
37
  FakeWeb.register_uri(:get, expected_url, :body => JSON)
38
- assert_artifacts @repository.find_artifacts(:name => 'artifact')
38
+ assert_artifacts @repository.find_artifacts(:name => 'artifact')
39
39
  end
40
-
40
+
41
41
  def test_find_artifacts_when_arguments_is_not_a_hash
42
42
  exception = assert_raise RuntimeError do
43
43
  @repository.find_artifacts(nil)
44
44
  end
45
-
45
+
46
46
  assert_equal("arguments must be a hash", exception.message)
47
47
  end
48
48
 
@@ -50,38 +50,38 @@ class RepositoryTest < Test::Unit::TestCase
50
50
  exception = assert_raise RuntimeError do
51
51
  @repository.find_artifacts(:a => 'foo', :b => 'bar')
52
52
  end
53
-
53
+
54
54
  assert_equal("invalid argument passed, valid arguments are (type, name, group)", exception.message)
55
55
  end
56
-
56
+
57
57
  def test_find_artifacts_when_empty_arguments_passed
58
58
  exception = assert_raise RuntimeError do
59
59
  @repository.find_artifacts({})
60
60
  end
61
-
61
+
62
62
  assert_equal("must pass at least one argument (type, name, group)", exception.message)
63
63
  end
64
-
64
+
65
65
  def test_delete
66
66
  expected_url = "http://user:pass@localhost/nexus/service/local/repositories/repo/content/org/group/artifact/version/"
67
67
  artifact = Nexus::Artifact.new('groupId' => 'org.group', 'artifactId' => 'artifact', 'version' => 'version', 'repoId' => 'repo')
68
68
  FakeWeb.register_uri(:delete, expected_url, :status => 200)
69
69
  assert_equal(200, @repository.delete(artifact))
70
70
  end
71
-
71
+
72
72
  def test_download
73
73
  artifact = Nexus::Artifact.new('resourceURI' => 'http://nexus/artifact')
74
74
  FakeWeb.register_uri(:get, "http://nexus/artifact", :body => 'file content')
75
75
  file = @repository.download(artifact)
76
- assert_equal('file content', file)
76
+ assert_equal('file content', file.body)
77
77
  end
78
-
78
+
79
79
  def assert_artifacts(artifacts)
80
80
  assert_equal(2, artifacts.size)
81
81
  assert_artifact(artifacts[0], 'group1', 'artifact1', 'version1', 'packaging1', 'uri1')
82
82
  assert_artifact(artifacts[1], 'group2', 'artifact2', 'version2', 'packaging2', 'uri2')
83
83
  end
84
-
84
+
85
85
  def assert_artifact(artifact, group, name, version, type, uri)
86
86
  assert_equal(group, artifact.group)
87
87
  assert_equal(name, artifact.name)
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rnexus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 3
9
+ version: 0.0.3
5
10
  platform: ruby
6
11
  authors:
7
12
  - Darrin Holst
@@ -9,29 +14,37 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2009-07-22 00:00:00 -05:00
17
+ date: 2010-05-27 00:00:00 -05:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: rest-client
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 1
29
+ - 0
30
+ - 3
23
31
  version: 1.0.3
24
- version:
32
+ type: :runtime
33
+ version_requirements: *id001
25
34
  - !ruby/object:Gem::Dependency
26
35
  name: crack
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
30
38
  requirements:
31
39
  - - ">="
32
40
  - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
43
+ - 1
44
+ - 3
33
45
  version: 0.1.3
34
- version:
46
+ type: :runtime
47
+ version_requirements: *id002
35
48
  description:
36
49
  email: darrinholst@gmail.com
37
50
  executables: []
@@ -68,18 +81,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
68
81
  requirements:
69
82
  - - ">="
70
83
  - !ruby/object:Gem::Version
84
+ segments:
85
+ - 0
71
86
  version: "0"
72
- version:
73
87
  required_rubygems_version: !ruby/object:Gem::Requirement
74
88
  requirements:
75
89
  - - ">="
76
90
  - !ruby/object:Gem::Version
91
+ segments:
92
+ - 0
77
93
  version: "0"
78
- version:
79
94
  requirements: []
80
95
 
81
96
  rubyforge_project: rnexus
82
- rubygems_version: 1.3.4
97
+ rubygems_version: 1.3.6
83
98
  signing_key:
84
99
  specification_version: 3
85
100
  summary: a ruby wrapper to interact with a nexus maven repository