nexus 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -0
- data/lib/commands/abstract_command.rb +25 -10
- data/lib/commands/nexus.rb +4 -4
- data/test/abstract_command_test.rb +11 -2
- data/test/command_helper.rb +3 -3
- data/test/nexus_command_test.rb +3 -4
- metadata +2 -2
data/Rakefile
CHANGED
@@ -9,11 +9,26 @@ require 'base64'
|
|
9
9
|
class Gem::AbstractCommand < Gem::Command
|
10
10
|
include Gem::LocalRemoteOptions
|
11
11
|
|
12
|
+
def initialize( name, summary )
|
13
|
+
super
|
14
|
+
|
15
|
+
add_option('-c', '--nexus-clear',
|
16
|
+
'Clears the nexus config') do |value, options|
|
17
|
+
options[:nexus_clear] = value
|
18
|
+
end
|
19
|
+
add_option('--nexus-config FILE',
|
20
|
+
'File location of nexus config') do |value, options|
|
21
|
+
options[:nexus_config] = File.expand_path( value )
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
12
25
|
def url
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
26
|
+
unless options[:nexus_clear]
|
27
|
+
url = config[:url]
|
28
|
+
# no leadng slash
|
29
|
+
url.sub!(/\/$/,'') if url
|
30
|
+
url
|
31
|
+
end
|
17
32
|
end
|
18
33
|
|
19
34
|
def configure_url
|
@@ -44,7 +59,7 @@ class Gem::AbstractCommand < Gem::Command
|
|
44
59
|
end
|
45
60
|
|
46
61
|
def config_path
|
47
|
-
File.join(Gem.user_home, '.gem', 'nexus')
|
62
|
+
options[:nexus_config] || File.join( Gem.user_home, '.gem', 'nexus' )
|
48
63
|
end
|
49
64
|
|
50
65
|
def config
|
@@ -52,7 +67,7 @@ class Gem::AbstractCommand < Gem::Command
|
|
52
67
|
end
|
53
68
|
|
54
69
|
def authorization
|
55
|
-
config[:authorization]
|
70
|
+
config[:authorization] unless options[:nexus_clear]
|
56
71
|
end
|
57
72
|
|
58
73
|
def store_config(key, value)
|
@@ -69,9 +84,9 @@ class Gem::AbstractCommand < Gem::Command
|
|
69
84
|
require 'net/http'
|
70
85
|
require 'net/https'
|
71
86
|
|
72
|
-
url = URI.parse("#{self.url}/#{path}")
|
87
|
+
url = URI.parse( "#{self.url}/#{path}" )
|
73
88
|
|
74
|
-
http = proxy_class.new(url.host, url.port)
|
89
|
+
http = proxy_class.new( url.host, url.port )
|
75
90
|
|
76
91
|
if url.scheme == 'https'
|
77
92
|
http.use_ssl = true
|
@@ -91,8 +106,8 @@ class Gem::AbstractCommand < Gem::Command
|
|
91
106
|
raise ArgumentError
|
92
107
|
end
|
93
108
|
|
94
|
-
request = request_method.new(url.path)
|
95
|
-
request.add_field "User-Agent", "
|
109
|
+
request = request_method.new( url.path )
|
110
|
+
request.add_field "User-Agent", "Ruby" unless RUBY_VERSION =~ /^1.9/
|
96
111
|
|
97
112
|
yield request if block_given?
|
98
113
|
http.request(request)
|
data/lib/commands/nexus.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
class Gem::Commands::NexusCommand < Gem::AbstractCommand
|
2
2
|
|
3
3
|
def description
|
4
|
-
'
|
4
|
+
'Upload a gem up to Nexus server'
|
5
5
|
end
|
6
6
|
|
7
7
|
def arguments
|
8
|
-
"GEM built gem to
|
8
|
+
"GEM built gem to upload"
|
9
9
|
end
|
10
10
|
|
11
11
|
def usage
|
@@ -13,7 +13,7 @@ class Gem::Commands::NexusCommand < Gem::AbstractCommand
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def initialize
|
16
|
-
super '
|
16
|
+
super 'nexus', description
|
17
17
|
add_proxy_option
|
18
18
|
end
|
19
19
|
|
@@ -23,7 +23,7 @@ class Gem::Commands::NexusCommand < Gem::AbstractCommand
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def send_gem
|
26
|
-
say "
|
26
|
+
say "Uploading gem to Nexus..."
|
27
27
|
|
28
28
|
path = get_one_gem_name
|
29
29
|
|
@@ -34,7 +34,7 @@ class AbstractCommandTest < CommandTest
|
|
34
34
|
end
|
35
35
|
|
36
36
|
should "return a proxy as a URI if set" do
|
37
|
-
stub_config(:http_proxy => 'http://proxy.example.org:9192')
|
37
|
+
stub_config( :http_proxy => 'http://proxy.example.org:9192' )
|
38
38
|
assert_equal 'proxy.example.org', @command.http_proxy.host
|
39
39
|
assert_equal 9192, @command.http_proxy.port
|
40
40
|
end
|
@@ -58,6 +58,15 @@ class AbstractCommandTest < CommandTest
|
|
58
58
|
assert_received(@command) { |command| command.sign_in }
|
59
59
|
end
|
60
60
|
|
61
|
+
should "sign in if --clear-config is set" do
|
62
|
+
stub(@command).sign_in
|
63
|
+
stub(@command).configure_url
|
64
|
+
stub(@command).options { {:nexus_clear => true} }
|
65
|
+
@command.setup
|
66
|
+
assert_received(@command) { |command| command.sign_in }
|
67
|
+
assert_received(@command) { |command| command.configure_url }
|
68
|
+
end
|
69
|
+
|
61
70
|
should "not sign in nor configure if authorizaton and url exists" do
|
62
71
|
stub(@command).authorization { "1234567890" }
|
63
72
|
stub(@command).url { "abc" }
|
@@ -70,7 +79,7 @@ class AbstractCommandTest < CommandTest
|
|
70
79
|
|
71
80
|
context "using the proxy" do
|
72
81
|
setup do
|
73
|
-
stub_config(:http_proxy => "http://gilbert:sekret@proxy.example.org:8081")
|
82
|
+
stub_config( :http_proxy => "http://gilbert:sekret@proxy.example.org:8081" )
|
74
83
|
@proxy_class = Object.new
|
75
84
|
mock(Net::HTTP).Proxy('proxy.example.org', 8081, 'gilbert', 'sekret') { @proxy_class }
|
76
85
|
@command.use_proxy!
|
data/test/command_helper.rb
CHANGED
@@ -28,9 +28,9 @@ class CommandTest < ActiveSupport::TestCase
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def stub_config(config)
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
file = Gem::ConfigFile.new({})
|
32
|
+
config.each { |key, value| file[key] = value }
|
33
|
+
stub(Gem).configuration { config }
|
34
34
|
end
|
35
35
|
|
36
36
|
def assert_said(command, what)
|
data/test/nexus_command_test.rb
CHANGED
@@ -39,7 +39,7 @@ class NexusCommandTest < CommandTest
|
|
39
39
|
end
|
40
40
|
|
41
41
|
should "say push was successful" do
|
42
|
-
assert_received(@command) { |command| command.say("
|
42
|
+
assert_received(@command) { |command| command.say("Uploading gem to Nexus...") }
|
43
43
|
# due to webmock there is no status message
|
44
44
|
assert_received(@command) { |command| command.say("") }
|
45
45
|
end
|
@@ -49,13 +49,12 @@ class NexusCommandTest < CommandTest
|
|
49
49
|
assert_requested(:post, @url,
|
50
50
|
:times => 1)
|
51
51
|
assert_requested(:post, @url,
|
52
|
+
:body => @gem_binary,
|
52
53
|
:headers => {
|
53
54
|
'Authorization' => 'key',
|
54
55
|
'Content-Type' => 'application/octet-stream',
|
55
|
-
'User-Agent'=>'
|
56
|
+
'User-Agent'=>'Ruby'
|
56
57
|
})
|
57
|
-
#assert_requested(:post, @url,
|
58
|
-
# :headers => {'Content-Length' => @gem_binary.size.to_s})
|
59
58
|
end
|
60
59
|
end
|
61
60
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: nexus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.2.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Nick Quaranto
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-09-11 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: always_verify_ssl_certificates
|