nexus 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a1c2323675c17ca433009c88d2a26aa01b1846e1
4
+ data.tar.gz: 46970225772cc8e915be276896057307caa02ae8
5
+ SHA512:
6
+ metadata.gz: 06b148374732475db9985b821d2e9ff61c3c4760cf9da0f887cfec656456ebac74521b9c8581b900033726fcc566c5447a00bc12458227bfa8611183c36935dd
7
+ data.tar.gz: d2d813112d009ffe9946f380b000f4cc44fdda405461261739a8d71bd435e0c6c81631be5907de461055babafd157e2ca3243d564b8f1a6f16c291aecdaeecff
@@ -19,12 +19,10 @@ class Gem::AbstractCommand < Gem::Command
19
19
  end
20
20
 
21
21
  def url
22
- unless options[:nexus_clear]
23
- url = config[:url]
24
- # no leadng slash
25
- url.sub!(/\/$/,'') if url
26
- url
27
- end
22
+ url = config[:url]
23
+ # no leading slash
24
+ url.sub!(/\/$/,'') if url
25
+ url
28
26
  end
29
27
 
30
28
  def configure_url
@@ -38,9 +36,9 @@ class Gem::AbstractCommand < Gem::Command
38
36
  end
39
37
 
40
38
  def setup
41
- configure_url unless url
39
+ configure_url if !config.key?( :url ) || options[:nexus_clear]
42
40
  use_proxy!( url ) if http_proxy( url )
43
- sign_in unless authorization
41
+ sign_in if !config.key?( :authorization ) || options[:nexus_clear]
44
42
  end
45
43
 
46
44
  def sign_in
@@ -49,8 +47,13 @@ class Gem::AbstractCommand < Gem::Command
49
47
  password = ask_for_password("Password: ")
50
48
 
51
49
  # mimic strict_encode64 which is not there on ruby1.8
52
- store_config(:authorization,
53
- "Basic #{Base64.encode64(username + ':' + password).gsub(/\s+/, '')}")
50
+ token = "#{username}:#{password}"
51
+ if token != ':'
52
+ store_config(:authorization,
53
+ "Basic #{Base64.encode64(username + ':' + password).gsub(/\s+/, '')}")
54
+ else
55
+ store_config(:authorization, nil )
56
+ end
54
57
 
55
58
  say "Your Nexus credentials has been stored in ~/.gem/nexus"
56
59
  end
@@ -64,7 +67,7 @@ class Gem::AbstractCommand < Gem::Command
64
67
  end
65
68
 
66
69
  def authorization
67
- config[:authorization] unless options[:nexus_clear]
70
+ config[:authorization]
68
71
  end
69
72
 
70
73
  def store_config(key, value)
@@ -110,6 +113,18 @@ class Gem::AbstractCommand < Gem::Command
110
113
  request.add_field "User-Agent", "Ruby" unless RUBY_VERSION =~ /^1.9/
111
114
 
112
115
  yield request if block_given?
116
+
117
+ if Gem.configuration.verbose.to_s.to_i > 0
118
+ warn "#{request.method} #{url.to_s}"
119
+ if authorization
120
+ warn 'use authorization'
121
+ else
122
+ warn 'no authorization'
123
+ end
124
+
125
+ warn "use proxy at #{http.proxy_address}" if http.proxy_address
126
+ end
127
+
113
128
  http.request(request)
114
129
  end
115
130
 
@@ -133,6 +148,7 @@ class Gem::AbstractCommand < Gem::Command
133
148
  key = uri.scheme == 'http' ? 'http_proxy' : 'https_proxy'
134
149
  proxy = Gem.configuration[ :http_proxy ] || ENV[ key ] || ENV[ key.upcase ]
135
150
  return nil if proxy.nil? || proxy == :no_proxy
151
+
136
152
  URI.parse( proxy )
137
153
  end
138
154
 
@@ -18,8 +18,12 @@ class Gem::Commands::NexusCommand < Gem::AbstractCommand
18
18
  end
19
19
 
20
20
  def execute
21
+ name = get_one_gem_name rescue nil
21
22
  setup
22
- send_gem
23
+ # if there is no gemname and no clear options then fail with send_gem
24
+ if !name.nil? || !options[ :nexus_clear ]
25
+ send_gem
26
+ end
23
27
  end
24
28
 
25
29
  def send_gem
@@ -31,7 +35,7 @@ class Gem::Commands::NexusCommand < Gem::AbstractCommand
31
35
  request.body = Gem.read_binary(path)
32
36
  request.add_field("Content-Length", request.body.size)
33
37
  request.add_field("Content-Type", "application/octet-stream")
34
- request.add_field("Authorization", authorization.strip)
38
+ request.add_field("Authorization", authorization.strip) if authorization
35
39
  end
36
40
 
37
41
  case response.code
data/lib/nexus/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Nexus
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
@@ -18,6 +18,7 @@ class AbstractCommandTest < CommandTest
18
18
  context "with an fake command" do
19
19
  setup do
20
20
  @command = Gem::Commands::FakeCommand.new
21
+ Gem.configuration.verbose = false
21
22
  stub(@command).say
22
23
  ENV['http_proxy'] = nil
23
24
  ENV['HTTP_PROXY'] = nil
@@ -49,8 +50,9 @@ class AbstractCommandTest < CommandTest
49
50
  end
50
51
  end
51
52
 
52
- should "sign in if authorization and no nexus url" do
53
+ should "sign in if no authorization and no nexus url in config" do
53
54
  stub(@command).authorization { nil }
55
+ stub(@command).config { { } }
54
56
  stub(@command).url { nil }
55
57
  stub(@command).sign_in
56
58
  stub(@command).configure_url
@@ -68,6 +70,14 @@ class AbstractCommandTest < CommandTest
68
70
  assert_received(@command) { |command| command.configure_url }
69
71
  end
70
72
 
73
+ should "always return stored authorization and url" do
74
+ @command.config[ :url ] = 'something'
75
+ @command.config[ :authorization ] = 'something'
76
+ stub(@command).options { {:nexus_clear => true} }
77
+ assert_not_nil @command.authorization
78
+ assert_not_nil @command.url
79
+ end
80
+
71
81
  should "not sign in nor configure if authorizaton and url exists" do
72
82
  stub(@command).authorization { "1234567890" }
73
83
  stub(@command).url { "abc" }
@@ -90,6 +100,21 @@ class AbstractCommandTest < CommandTest
90
100
  assert_equal @proxy_class, @command.proxy_class
91
101
  end
92
102
  end
103
+
104
+ context "clear username + password" do
105
+
106
+ should "clear stored authorization" do
107
+ stub(@command).options { {:nexus_config => File.join( 'pkg',
108
+ 'config') } }
109
+ stub(@command).say
110
+ stub(@command).ask { nil }
111
+ stub(@command).ask_for_password { nil }
112
+ @command.config[ :authorization ] = 'something'
113
+
114
+ @command.sign_in
115
+ assert_nil @command.authorization
116
+ end
117
+ end
93
118
 
94
119
  context "signing in" do
95
120
  setup do
@@ -102,7 +127,7 @@ class AbstractCommandTest < CommandTest
102
127
  stub(@command).ask_for_password { @password }
103
128
  stub(@command).store_config { {:authorization => @key} }
104
129
  end
105
-
130
+
106
131
  should "ask for username and password" do
107
132
  @command.sign_in
108
133
  assert_received(@command) { |command| command.ask("Username: ") }
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nexus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
5
- prerelease:
4
+ version: 1.0.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Nick Quaranto
@@ -10,7 +9,7 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2013-09-20 00:00:00.000000000 Z
12
+ date: 2013-11-13 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: rake
@@ -19,13 +18,11 @@ dependencies:
19
18
  - - ~>
20
19
  - !ruby/object:Gem::Version
21
20
  version: '10.1'
22
- none: false
23
21
  requirement: !ruby/object:Gem::Requirement
24
22
  requirements:
25
23
  - - ~>
26
24
  - !ruby/object:Gem::Version
27
25
  version: '10.1'
28
- none: false
29
26
  prerelease: false
30
27
  type: :development
31
28
  - !ruby/object:Gem::Dependency
@@ -35,13 +32,11 @@ dependencies:
35
32
  - - ~>
36
33
  - !ruby/object:Gem::Version
37
34
  version: 3.1.0.0.0
38
- none: false
39
35
  requirement: !ruby/object:Gem::Requirement
40
36
  requirements:
41
37
  - - ~>
42
38
  - !ruby/object:Gem::Version
43
39
  version: 3.1.0.0.0
44
- none: false
45
40
  prerelease: false
46
41
  type: :development
47
42
  - !ruby/object:Gem::Dependency
@@ -51,13 +46,11 @@ dependencies:
51
46
  - - ~>
52
47
  - !ruby/object:Gem::Version
53
48
  version: '3.1'
54
- none: false
55
49
  requirement: !ruby/object:Gem::Requirement
56
50
  requirements:
57
51
  - - ~>
58
52
  - !ruby/object:Gem::Version
59
53
  version: '3.1'
60
- none: false
61
54
  prerelease: false
62
55
  type: :development
63
56
  - !ruby/object:Gem::Dependency
@@ -67,13 +60,11 @@ dependencies:
67
60
  - - ~>
68
61
  - !ruby/object:Gem::Version
69
62
  version: 4.0.0
70
- none: false
71
63
  requirement: !ruby/object:Gem::Requirement
72
64
  requirements:
73
65
  - - ~>
74
66
  - !ruby/object:Gem::Version
75
67
  version: 4.0.0
76
- none: false
77
68
  prerelease: false
78
69
  type: :development
79
70
  - !ruby/object:Gem::Dependency
@@ -83,13 +74,11 @@ dependencies:
83
74
  - - ~>
84
75
  - !ruby/object:Gem::Version
85
76
  version: '1.8'
86
- none: false
87
77
  requirement: !ruby/object:Gem::Requirement
88
78
  requirements:
89
79
  - - ~>
90
80
  - !ruby/object:Gem::Version
91
81
  version: '1.8'
92
- none: false
93
82
  prerelease: false
94
83
  type: :development
95
84
  - !ruby/object:Gem::Dependency
@@ -99,13 +88,11 @@ dependencies:
99
88
  - - ~>
100
89
  - !ruby/object:Gem::Version
101
90
  version: '1.1'
102
- none: false
103
91
  requirement: !ruby/object:Gem::Requirement
104
92
  requirements:
105
93
  - - ~>
106
94
  - !ruby/object:Gem::Version
107
95
  version: '1.1'
108
- none: false
109
96
  prerelease: false
110
97
  type: :development
111
98
  description: Adds a command to RubyGems for uploading gems to a nexus server.
@@ -132,6 +119,7 @@ files:
132
119
  homepage: https://github.com/sonatype/nexus-ruby-support/tree/master/nexus-gem
133
120
  licenses:
134
121
  - MIT-LICENSE
122
+ metadata: {}
135
123
  post_install_message: "\n========================================================================\n\
136
124
  \n Thanks for installing Nexus gem! You can now run:\n\n gem nexus\
137
125
  \ publish your gems onto Nexus server\n\n nbundle a bundler\
@@ -147,17 +135,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
147
135
  - - '>='
148
136
  - !ruby/object:Gem::Version
149
137
  version: '0'
150
- none: false
151
138
  required_rubygems_version: !ruby/object:Gem::Requirement
152
139
  requirements:
153
140
  - - '>='
154
141
  - !ruby/object:Gem::Version
155
142
  version: '0'
156
- none: false
157
143
  requirements: []
158
144
  rubyforge_project:
159
- rubygems_version: 1.8.24
145
+ rubygems_version: 2.1.9
160
146
  signing_key:
161
- specification_version: 3
147
+ specification_version: 4
162
148
  summary: Gem Command to interact with Nexus server
163
149
  test_files: []