nexus 0.1.0 → 0.2.0

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.
data/Rakefile CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'rake'
2
2
  require 'rake/testtask'
3
+ require 'bundler/setup'
3
4
 
4
5
  task :default => [:test]
5
6
 
@@ -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
- url = config[:url]
14
- # no leadng slash
15
- url.sub!(/\/$/,'') if url
16
- url
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", "Nexus Gem Command"
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)
@@ -1,11 +1,11 @@
1
1
  class Gem::Commands::NexusCommand < Gem::AbstractCommand
2
2
 
3
3
  def description
4
- 'Push a gem up to Nexus server'
4
+ 'Upload a gem up to Nexus server'
5
5
  end
6
6
 
7
7
  def arguments
8
- "GEM built gem to push up"
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 'push', description
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 "Pushing gem to Nexus..."
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!
@@ -28,9 +28,9 @@ class CommandTest < ActiveSupport::TestCase
28
28
  end
29
29
 
30
30
  def stub_config(config)
31
- # file = Gem::ConfigFile.new({})
32
- #xs config.each { |key, value| file[key] = value }
33
- # stub(:config).configuration { config }
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)
@@ -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("Pushing gem to Nexus...") }
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'=>'Nexus Gem Command'
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.1.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-08-17 00:00:00 Z
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