rnexus 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -4,13 +4,13 @@ A ruby wrapper to perform actions against the Nexus maven repository manager
4
4
 
5
5
  == Synopsis
6
6
 
7
- repo = Nexus::Repository.new("http://path/to/nexus")
8
- artifacts = repo.find_artifacts(:group => 'org.mockito', :name => 'mockito', :type => 'jar')
9
- jar = repo.download_artifact(artifacts.first)
7
+ repo = Nexus::Repository.new("http://path/to/nexus")
8
+ artifacts = repo.find_artifacts(:group => 'org.mockito', :name => 'mockito', :type => 'jar')
9
+ jar = repo.download_artifact(artifacts.first)
10
10
 
11
11
  == Install
12
12
 
13
- sudo gem install rnexus
13
+ sudo gem install rnexus
14
14
 
15
15
  == Copyright
16
16
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
data/lib/artifact.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  class Nexus::Artifact
2
- attr_accessor :group, :name, :version, :type, :uri
2
+ attr_accessor :group, :name, :version, :type, :uri, :repo
3
3
 
4
4
  def initialize(parameters)
5
5
  self.group = parameters['groupId']
@@ -7,5 +7,6 @@ class Nexus::Artifact
7
7
  self.version = parameters['version']
8
8
  self.type = parameters['packaging']
9
9
  self.uri = parameters['resourceURI']
10
+ self.repo = parameters['repoId']
10
11
  end
11
12
  end
data/lib/repository.rb CHANGED
@@ -9,8 +9,10 @@ class Nexus::Repository
9
9
  :type => :p
10
10
  }
11
11
 
12
- def initialize(baseuri)
12
+ def initialize(baseuri, username = nil, password = nil)
13
13
  @baseuri = baseuri
14
+ @username = username
15
+ @password = password
14
16
  end
15
17
 
16
18
  def find_artifacts(args)
@@ -19,10 +21,15 @@ class Nexus::Repository
19
21
  Crack::JSON.parse(response)['data'].map {|data| Nexus::Artifact.new(data)}
20
22
  end
21
23
 
22
- def download_artifact(artifact)
24
+ def download(artifact)
23
25
  RestClient.get(artifact.uri)
24
26
  end
25
27
 
28
+ def delete(artifact)
29
+ url = "#{@baseuri}/service/local/repositories/#{artifact.repo}/content/#{artifact.group.gsub(/\./, '/')}/#{artifact.name}/#{artifact.version}/"
30
+ RestClient::Resource.new(url, :user => @username, :password => @password).delete.code
31
+ end
32
+
26
33
  private
27
34
 
28
35
  def build_query_parameters_from(args)
@@ -46,4 +53,5 @@ class Nexus::Repository
46
53
  def nexus_parameters_to_s
47
54
  "(#{NEXUS_PARAMETERS.keys.join(', ')})"
48
55
  end
49
- end
56
+ end
57
+
data/rnexus.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{rnexus}
5
- s.version = "0.0.1"
5
+ s.version = "0.0.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Darrin Holst"]
9
- s.date = %q{2009-07-15}
9
+ s.date = %q{2009-07-22}
10
10
  s.email = %q{darrinholst@gmail.com}
11
11
  s.extra_rdoc_files = [
12
12
  "LICENSE",
@@ -7,12 +7,14 @@ class ArtifactTest < Test::Unit::TestCase
7
7
  'artifactId' => 'name',
8
8
  'version' => 'version',
9
9
  'packaging' => 'war',
10
- 'resourceURI' => 'uri')
10
+ 'resourceURI' => 'uri',
11
+ 'repoId' => 'repo')
11
12
 
12
13
  assert_equal('group', artifact.group)
13
14
  assert_equal('name', artifact.name)
14
15
  assert_equal('version', artifact.version)
15
16
  assert_equal('war', artifact.type)
16
17
  assert_equal('uri', artifact.uri)
18
+ assert_equal('repo', artifact.repo)
17
19
  end
18
20
  end
@@ -23,22 +23,18 @@ class RepositoryTest < Test::Unit::TestCase
23
23
  eos
24
24
 
25
25
  def setup
26
- @repository = Nexus::Repository.new("http://localhost/nexus")
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
-
32
31
  FakeWeb.register_uri(:get, expected_url, :body => JSON)
33
-
34
32
  assert_artifacts @repository.find_artifacts(:group => 'group', :name => 'artifact', :type => 'war')
35
33
  end
36
34
 
37
35
  def test_find_artifacts_using_artifact_id_only
38
36
  expected_url = "http://localhost/nexus/service/local/data_index/repo_groups/public?a=artifact"
39
-
40
37
  FakeWeb.register_uri(:get, expected_url, :body => JSON)
41
-
42
38
  assert_artifacts @repository.find_artifacts(:name => 'artifact')
43
39
  end
44
40
 
@@ -66,13 +62,17 @@ class RepositoryTest < Test::Unit::TestCase
66
62
  assert_equal("must pass at least one argument (type, name, group)", exception.message)
67
63
  end
68
64
 
69
- def test_download_artifact
65
+ def test_delete
66
+ expected_url = "http://user:pass@localhost/nexus/service/local/repositories/repo/content/org/group/artifact/version/"
67
+ artifact = Nexus::Artifact.new('groupId' => 'org.group', 'artifactId' => 'artifact', 'version' => 'version', 'repoId' => 'repo')
68
+ FakeWeb.register_uri(:delete, expected_url, :status => 200)
69
+ assert_equal(200, @repository.delete(artifact))
70
+ end
71
+
72
+ def test_download
70
73
  artifact = Nexus::Artifact.new('resourceURI' => 'http://nexus/artifact')
71
-
72
74
  FakeWeb.register_uri(:get, "http://nexus/artifact", :body => 'file content')
73
-
74
- file = @repository.download_artifact(artifact)
75
-
75
+ file = @repository.download(artifact)
76
76
  assert_equal('file content', file)
77
77
  end
78
78
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rnexus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darrin Holst
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-07-15 00:00:00 -05:00
12
+ date: 2009-07-22 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency