nexus 0.2.5 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +9 -1
- data/lib/commands/abstract_command.rb +14 -6
- data/lib/nexus/version.rb +3 -0
- data/test/abstract_command_test.rb +10 -9
- data/test/command_helper.rb +12 -3
- data/test/nexus_command_test.rb +1 -2
- metadata +46 -34
data/Rakefile
CHANGED
@@ -1,10 +1,18 @@
|
|
1
|
+
#-*- mode: ruby -*-
|
2
|
+
|
1
3
|
require 'rake'
|
2
4
|
require 'rake/testtask'
|
5
|
+
require 'rubygems/package_task'
|
6
|
+
|
7
|
+
task :default => [ :test, :package ]
|
3
8
|
|
4
|
-
|
9
|
+
Gem::PackageTask.new( Gem::Specification.load( 'nexus.gemspec' ) ) do
|
10
|
+
end
|
5
11
|
|
6
12
|
Rake::TestTask.new(:test) do |t|
|
7
13
|
t.libs << "test"
|
8
14
|
t.test_files = FileList['test/*_command_test.rb']
|
9
15
|
t.verbose = true
|
10
16
|
end
|
17
|
+
|
18
|
+
# vim: syntax=Ruby
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'rubygems/local_remote_options'
|
2
|
+
require 'net/http'
|
2
3
|
require 'base64'
|
3
4
|
|
4
5
|
class Gem::AbstractCommand < Gem::Command
|
@@ -37,8 +38,8 @@ class Gem::AbstractCommand < Gem::Command
|
|
37
38
|
end
|
38
39
|
|
39
40
|
def setup
|
40
|
-
use_proxy! if http_proxy
|
41
41
|
configure_url unless url
|
42
|
+
use_proxy!( url ) if http_proxy( url )
|
42
43
|
sign_in unless authorization
|
43
44
|
end
|
44
45
|
|
@@ -112,8 +113,8 @@ class Gem::AbstractCommand < Gem::Command
|
|
112
113
|
http.request(request)
|
113
114
|
end
|
114
115
|
|
115
|
-
def use_proxy!
|
116
|
-
proxy_uri = http_proxy
|
116
|
+
def use_proxy!( url )
|
117
|
+
proxy_uri = http_proxy( url )
|
117
118
|
@proxy_class = Net::HTTP::Proxy(proxy_uri.host, proxy_uri.port, proxy_uri.user, proxy_uri.password)
|
118
119
|
end
|
119
120
|
|
@@ -122,10 +123,17 @@ class Gem::AbstractCommand < Gem::Command
|
|
122
123
|
end
|
123
124
|
|
124
125
|
# @return [URI, nil] the HTTP-proxy as a URI if set; +nil+ otherwise
|
125
|
-
def http_proxy
|
126
|
-
|
126
|
+
def http_proxy( url )
|
127
|
+
uri = URI.parse( url ) rescue nil
|
128
|
+
return nil if uri.nil?
|
129
|
+
if no_proxy = ENV[ 'no_proxy' ] || ENV[ 'NO_PROXY' ]
|
130
|
+
# does not look on ip-adress ranges
|
131
|
+
return nil if no_proxy.split( /, */ ).member?( uri.host )
|
132
|
+
end
|
133
|
+
key = uri.scheme == 'http' ? 'http_proxy' : 'https_proxy'
|
134
|
+
proxy = Gem.configuration[ :http_proxy ] || ENV[ key ] || ENV[ key.upcase ]
|
127
135
|
return nil if proxy.nil? || proxy == :no_proxy
|
128
|
-
URI.parse(proxy)
|
136
|
+
URI.parse( proxy )
|
129
137
|
end
|
130
138
|
|
131
139
|
def ask_for_password(message)
|
@@ -14,6 +14,7 @@ class Gem::Commands::FakeCommand < Gem::AbstractCommand
|
|
14
14
|
end
|
15
15
|
|
16
16
|
class AbstractCommandTest < CommandTest
|
17
|
+
|
17
18
|
context "with an fake command" do
|
18
19
|
setup do
|
19
20
|
@command = Gem::Commands::FakeCommand.new
|
@@ -25,26 +26,26 @@ class AbstractCommandTest < CommandTest
|
|
25
26
|
context "parsing the proxy" do
|
26
27
|
should "return nil if no proxy is set" do
|
27
28
|
stub_config(:http_proxy => nil)
|
28
|
-
assert_equal nil, @command.http_proxy
|
29
|
+
assert_equal nil, @command.http_proxy( nil )
|
29
30
|
end
|
30
31
|
|
31
32
|
should "return nil if the proxy is set to :no_proxy" do
|
32
33
|
stub_config(:http_proxy => :no_proxy)
|
33
|
-
assert_equal nil, @command.http_proxy
|
34
|
+
assert_equal nil, @command.http_proxy( 'asd' )
|
34
35
|
end
|
35
36
|
|
36
37
|
should "return a proxy as a URI if set" do
|
37
38
|
stub_config( :http_proxy => 'http://proxy.example.org:9192' )
|
38
|
-
assert_equal 'proxy.example.org', @command.http_proxy.host
|
39
|
-
assert_equal 9192, @command.http_proxy.port
|
39
|
+
assert_equal 'proxy.example.org', @command.http_proxy( 'http://asd' ).host
|
40
|
+
assert_equal 9192, @command.http_proxy( 'http://asd' ).port
|
40
41
|
end
|
41
42
|
|
42
43
|
should "return a proxy as a URI if set by environment variable" do
|
43
44
|
ENV['http_proxy'] = "http://jack:duck@192.168.1.100:9092"
|
44
|
-
assert_equal "192.168.1.100", @command.http_proxy.host
|
45
|
-
assert_equal 9092, @command.http_proxy.port
|
46
|
-
assert_equal "jack", @command.http_proxy.user
|
47
|
-
assert_equal "duck", @command.http_proxy.password
|
45
|
+
assert_equal "192.168.1.100", @command.http_proxy( 'http://asd' ).host
|
46
|
+
assert_equal 9092, @command.http_proxy( 'http://asd' ).port
|
47
|
+
assert_equal "jack", @command.http_proxy( 'http://asd' ).user
|
48
|
+
assert_equal "duck", @command.http_proxy( 'http://asd' ).password
|
48
49
|
end
|
49
50
|
end
|
50
51
|
|
@@ -82,7 +83,7 @@ class AbstractCommandTest < CommandTest
|
|
82
83
|
stub_config( :http_proxy => "http://gilbert:sekret@proxy.example.org:8081" )
|
83
84
|
@proxy_class = Object.new
|
84
85
|
mock(Net::HTTP).Proxy('proxy.example.org', 8081, 'gilbert', 'sekret') { @proxy_class }
|
85
|
-
@command.use_proxy!
|
86
|
+
@command.use_proxy!( 'http://asd' )
|
86
87
|
end
|
87
88
|
|
88
89
|
should "replace Net::HTTP with a proxy version" do
|
data/test/command_helper.rb
CHANGED
@@ -1,7 +1,16 @@
|
|
1
|
-
require '
|
2
|
-
require 'test/unit'
|
1
|
+
require 'minitest/autorun'
|
3
2
|
|
4
3
|
require 'shoulda'
|
4
|
+
|
5
|
+
# for some reasons the refute_predicate is missing when executing
|
6
|
+
# via jruby-1.7.4
|
7
|
+
module ActiveSupport
|
8
|
+
class TestCase < ::MiniTest::Unit::TestCase
|
9
|
+
def refute_predicate
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
5
14
|
require 'active_support'
|
6
15
|
require 'active_support/test_case'
|
7
16
|
require 'webmock'
|
@@ -19,8 +28,8 @@ $:.unshift File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
|
19
28
|
require "rubygems_plugin"
|
20
29
|
|
21
30
|
class CommandTest < ActiveSupport::TestCase
|
22
|
-
include RR::Adapters::TestUnit unless include?(RR::Adapters::TestUnit)
|
23
31
|
include WebMock::API
|
32
|
+
include ShouldaContextLoadable
|
24
33
|
|
25
34
|
def teardown
|
26
35
|
WebMock.reset!
|
data/test/nexus_command_test.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nexus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,21 +10,37 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-09-20 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|
17
17
|
version_requirements: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: '10.1'
|
22
22
|
none: false
|
23
23
|
requirement: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - ~>
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
27
|
+
version: '10.1'
|
28
|
+
none: false
|
29
|
+
prerelease: false
|
30
|
+
type: :development
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: ruby-maven
|
33
|
+
version_requirements: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 3.1.0.0.0
|
38
|
+
none: false
|
39
|
+
requirement: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 3.1.0.0.0
|
28
44
|
none: false
|
29
45
|
prerelease: false
|
30
46
|
type: :development
|
@@ -32,15 +48,15 @@ dependencies:
|
|
32
48
|
name: shoulda
|
33
49
|
version_requirements: !ruby/object:Gem::Requirement
|
34
50
|
requirements:
|
35
|
-
- -
|
51
|
+
- - ~>
|
36
52
|
- !ruby/object:Gem::Version
|
37
|
-
version: 3.1
|
53
|
+
version: '3.1'
|
38
54
|
none: false
|
39
55
|
requirement: !ruby/object:Gem::Requirement
|
40
56
|
requirements:
|
41
|
-
- -
|
57
|
+
- - ~>
|
42
58
|
- !ruby/object:Gem::Version
|
43
|
-
version: 3.1
|
59
|
+
version: '3.1'
|
44
60
|
none: false
|
45
61
|
prerelease: false
|
46
62
|
type: :development
|
@@ -48,15 +64,13 @@ dependencies:
|
|
48
64
|
name: activesupport
|
49
65
|
version_requirements: !ruby/object:Gem::Requirement
|
50
66
|
requirements:
|
51
|
-
- -
|
52
|
-
PA==
|
67
|
+
- - ~>
|
53
68
|
- !ruby/object:Gem::Version
|
54
69
|
version: 4.0.0
|
55
70
|
none: false
|
56
71
|
requirement: !ruby/object:Gem::Requirement
|
57
72
|
requirements:
|
58
|
-
- -
|
59
|
-
PA==
|
73
|
+
- - ~>
|
60
74
|
- !ruby/object:Gem::Version
|
61
75
|
version: 4.0.0
|
62
76
|
none: false
|
@@ -66,15 +80,15 @@ dependencies:
|
|
66
80
|
name: webmock
|
67
81
|
version_requirements: !ruby/object:Gem::Requirement
|
68
82
|
requirements:
|
69
|
-
- -
|
83
|
+
- - ~>
|
70
84
|
- !ruby/object:Gem::Version
|
71
|
-
version: 1.8
|
85
|
+
version: '1.8'
|
72
86
|
none: false
|
73
87
|
requirement: !ruby/object:Gem::Requirement
|
74
88
|
requirements:
|
75
|
-
- -
|
89
|
+
- - ~>
|
76
90
|
- !ruby/object:Gem::Version
|
77
|
-
version: 1.8
|
91
|
+
version: '1.8'
|
78
92
|
none: false
|
79
93
|
prerelease: false
|
80
94
|
type: :development
|
@@ -82,17 +96,15 @@ dependencies:
|
|
82
96
|
name: rr
|
83
97
|
version_requirements: !ruby/object:Gem::Requirement
|
84
98
|
requirements:
|
85
|
-
- -
|
99
|
+
- - ~>
|
86
100
|
- !ruby/object:Gem::Version
|
87
|
-
version:
|
88
|
-
MA==
|
101
|
+
version: '1.1'
|
89
102
|
none: false
|
90
103
|
requirement: !ruby/object:Gem::Requirement
|
91
104
|
requirements:
|
92
|
-
- -
|
105
|
+
- - ~>
|
93
106
|
- !ruby/object:Gem::Version
|
94
|
-
version:
|
95
|
-
MA==
|
107
|
+
version: '1.1'
|
96
108
|
none: false
|
97
109
|
prerelease: false
|
98
110
|
type: :development
|
@@ -111,13 +123,15 @@ files:
|
|
111
123
|
- lib/rubygems_plugin.rb
|
112
124
|
- lib/bundler/rubygems_mirror.rb
|
113
125
|
- lib/bundler/monkey_patch.rb
|
114
|
-
- lib/
|
126
|
+
- lib/nexus/version.rb
|
115
127
|
- lib/commands/abstract_command.rb
|
128
|
+
- lib/commands/nexus.rb
|
116
129
|
- test/command_helper.rb
|
117
|
-
- test/abstract_command_test.rb
|
118
130
|
- test/nexus_command_test.rb
|
131
|
+
- test/abstract_command_test.rb
|
119
132
|
homepage: https://github.com/sonatype/nexus-ruby-support/tree/master/nexus-gem
|
120
|
-
licenses:
|
133
|
+
licenses:
|
134
|
+
- MIT-LICENSE
|
121
135
|
post_install_message: "\n========================================================================\n\
|
122
136
|
\n Thanks for installing Nexus gem! You can now run:\n\n gem nexus\
|
123
137
|
\ publish your gems onto Nexus server\n\n nbundle a bundler\
|
@@ -130,22 +144,20 @@ require_paths:
|
|
130
144
|
- lib
|
131
145
|
required_ruby_version: !ruby/object:Gem::Requirement
|
132
146
|
requirements:
|
133
|
-
- -
|
147
|
+
- - '>='
|
134
148
|
- !ruby/object:Gem::Version
|
135
|
-
version:
|
136
|
-
MA==
|
149
|
+
version: '0'
|
137
150
|
none: false
|
138
151
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
152
|
requirements:
|
140
|
-
- -
|
153
|
+
- - '>='
|
141
154
|
- !ruby/object:Gem::Version
|
142
|
-
version:
|
143
|
-
MA==
|
155
|
+
version: '0'
|
144
156
|
none: false
|
145
157
|
requirements: []
|
146
158
|
rubyforge_project:
|
147
159
|
rubygems_version: 1.8.24
|
148
160
|
signing_key:
|
149
161
|
specification_version: 3
|
150
|
-
summary:
|
162
|
+
summary: Gem Command to interact with Nexus server
|
151
163
|
test_files: []
|