rnexus 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.0.5
@@ -1,6 +1,6 @@
1
1
  class Nexus::Artifact
2
- attr_accessor :group, :name, :version, :type, :uri, :repo
3
-
2
+ attr_accessor :group, :name, :version, :type, :uri, :repo, :classifier
3
+
4
4
  def initialize(parameters)
5
5
  self.group = parameters['groupId']
6
6
  self.name = parameters['artifactId']
@@ -8,5 +8,6 @@ class Nexus::Artifact
8
8
  self.type = parameters['packaging']
9
9
  self.uri = parameters['resourceURI']
10
10
  self.repo = parameters['repoId']
11
+ self.classifier = parameters['classifier']
11
12
  end
12
13
  end
@@ -30,6 +30,19 @@ class Nexus::Repository
30
30
  RestClient::Resource.new(url, :user => @username, :password => @password).delete.code
31
31
  end
32
32
 
33
+ def put(artifact, file)
34
+ filename = artifact.name
35
+
36
+ if(artifact.classifier)
37
+ filename = filename + "-" + artifact.classifier
38
+ end
39
+
40
+ filename = filename + "." + artifact.type
41
+
42
+ url = "#{@baseuri}/service/local/repositories/#{artifact.repo}/content/#{artifact.group.gsub(/\./, '/')}/#{artifact.name}/#{artifact.version}/#{filename}"
43
+ RestClient::Resource.new(url, :user => @username, :password => @password).put(:file => file).code
44
+ end
45
+
33
46
  private
34
47
 
35
48
  def build_query_parameters_from(args)
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rnexus}
8
- s.version = "0.0.4"
8
+ s.version = "0.0.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Darrin Holst"]
12
- s.date = %q{2010-05-28}
12
+ s.date = %q{2010-10-12}
13
13
  s.email = %q{darrinholst@gmail.com}
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE",
@@ -33,7 +33,7 @@ Gem::Specification.new do |s|
33
33
  s.homepage = %q{http://github.com/darrinholst/rnexus}
34
34
  s.rdoc_options = ["--charset=UTF-8"]
35
35
  s.require_paths = ["lib"]
36
- s.rubygems_version = %q{1.3.6}
36
+ s.rubygems_version = %q{1.3.7}
37
37
  s.summary = %q{a ruby wrapper to interact with a nexus maven repository}
38
38
  s.test_files = [
39
39
  "test/artifact_test.rb",
@@ -45,7 +45,7 @@ Gem::Specification.new do |s|
45
45
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
46
46
  s.specification_version = 3
47
47
 
48
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
48
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
49
49
  s.add_runtime_dependency(%q<rest-client>, [">= 1.4.0"])
50
50
  s.add_runtime_dependency(%q<crack>, [">= 0.1.3"])
51
51
  else
@@ -16,5 +16,5 @@ class ArtifactTest < Test::Unit::TestCase
16
16
  assert_equal('war', artifact.type)
17
17
  assert_equal('uri', artifact.uri)
18
18
  assert_equal('repo', artifact.repo)
19
- end
19
+ end
20
20
  end
@@ -69,6 +69,20 @@ class RepositoryTest < Test::Unit::TestCase
69
69
  assert_equal(200, @repository.delete(artifact))
70
70
  end
71
71
 
72
+ def test_put
73
+ expected_url = "http://user:pass@localhost/nexus/service/local/repositories/repo/content/org/group/artifact/version/artifact.war"
74
+ artifact = Nexus::Artifact.new('groupId' => 'org.group', 'artifactId' => 'artifact', 'version' => 'version', 'repoId' => 'repo', 'packaging' => 'war')
75
+ FakeWeb.register_uri(:put, expected_url, :status => 200)
76
+ assert_equal(200, @repository.put(artifact, Tempfile.new('some.war')))
77
+ end
78
+
79
+ def test_put_with_classifier
80
+ expected_url = "http://user:pass@localhost/nexus/service/local/repositories/repo/content/org/group/artifact/version/artifact-classifier.war"
81
+ artifact = Nexus::Artifact.new('groupId' => 'org.group', 'artifactId' => 'artifact', 'version' => 'version', 'repoId' => 'repo', 'packaging' => 'war', 'classifier' => 'classifier')
82
+ FakeWeb.register_uri(:put, expected_url, :status => 200)
83
+ assert_equal(200, @repository.put(artifact, Tempfile.new('some.war')))
84
+ end
85
+
72
86
  def test_download
73
87
  artifact = Nexus::Artifact.new('resourceURI' => 'http://nexus/artifact')
74
88
  FakeWeb.register_uri(:get, "http://nexus/artifact", :body => 'file content')
@@ -3,7 +3,7 @@ require 'test/unit'
3
3
  require 'fakeweb'
4
4
 
5
5
  FakeWeb.allow_net_connect = false
6
-
6
+
7
7
  $LOAD_PATH.unshift(File.dirname(__FILE__))
8
8
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
9
9
  require 'rnexus'
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rnexus
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 21
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 0
8
- - 4
9
- version: 0.0.4
9
+ - 5
10
+ version: 0.0.5
10
11
  platform: ruby
11
12
  authors:
12
13
  - Darrin Holst
@@ -14,16 +15,18 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-05-28 00:00:00 -05:00
18
+ date: 2010-10-12 00:00:00 -05:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: rest-client
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 7
27
30
  segments:
28
31
  - 1
29
32
  - 4
@@ -35,9 +38,11 @@ dependencies:
35
38
  name: crack
36
39
  prerelease: false
37
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
38
42
  requirements:
39
43
  - - ">="
40
44
  - !ruby/object:Gem::Version
45
+ hash: 29
41
46
  segments:
42
47
  - 0
43
48
  - 1
@@ -78,23 +83,27 @@ rdoc_options:
78
83
  require_paths:
79
84
  - lib
80
85
  required_ruby_version: !ruby/object:Gem::Requirement
86
+ none: false
81
87
  requirements:
82
88
  - - ">="
83
89
  - !ruby/object:Gem::Version
90
+ hash: 3
84
91
  segments:
85
92
  - 0
86
93
  version: "0"
87
94
  required_rubygems_version: !ruby/object:Gem::Requirement
95
+ none: false
88
96
  requirements:
89
97
  - - ">="
90
98
  - !ruby/object:Gem::Version
99
+ hash: 3
91
100
  segments:
92
101
  - 0
93
102
  version: "0"
94
103
  requirements: []
95
104
 
96
105
  rubyforge_project:
97
- rubygems_version: 1.3.6
106
+ rubygems_version: 1.3.7
98
107
  signing_key:
99
108
  specification_version: 3
100
109
  summary: a ruby wrapper to interact with a nexus maven repository