gem_publisher 1.4.2 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/gem_publisher/version.rb +1 -1
- data/lib/rubygems_plugin.rb +12 -2
- data/test/rubygems_plugin_test.rb +28 -4
- metadata +4 -4
data/lib/rubygems_plugin.rb
CHANGED
@@ -11,9 +11,16 @@ class Gem::Commands::PublishCommand < Gem::Command
|
|
11
11
|
add_option(
|
12
12
|
"-rREPOSITORY", "--repository=REPOSITORY",
|
13
13
|
"Set the gem repository (rubygems or gemfury)",
|
14
|
-
"Default: #{
|
14
|
+
"Default: #{defaults[:gem_repository]}") do |value, options|
|
15
15
|
options[:gem_repository] = value
|
16
16
|
end
|
17
|
+
|
18
|
+
add_option(
|
19
|
+
"-aAS", "--as=AS",
|
20
|
+
"Specify a shared account to publish the gem (gemfury only)"
|
21
|
+
) do |value, options|
|
22
|
+
options[:as] = value
|
23
|
+
end
|
17
24
|
end
|
18
25
|
|
19
26
|
def usage # :nodoc:
|
@@ -23,7 +30,10 @@ class Gem::Commands::PublishCommand < Gem::Command
|
|
23
30
|
def execute
|
24
31
|
options[:args].each do |gemspec|
|
25
32
|
Dir.chdir(File.dirname(gemspec)) do
|
26
|
-
|
33
|
+
new_opts = {}
|
34
|
+
new_opts[:as] = options[:as] if options[:as]
|
35
|
+
|
36
|
+
gem = GemPublisher.publish_if_updated(File.basename(gemspec), options[:gem_repository], new_opts)
|
27
37
|
|
28
38
|
if gem
|
29
39
|
$stderr.puts "Published #{gem}"
|
@@ -11,7 +11,7 @@ module GemPublisher
|
|
11
11
|
|
12
12
|
def test_should_report_published_gem
|
13
13
|
GemPublisher.expects(:publish_if_updated).
|
14
|
-
with("awesome.gemspec", "rubygems").
|
14
|
+
with("awesome.gemspec", "rubygems", optionally({})).
|
15
15
|
returns("awesome-1.0.0.gem")
|
16
16
|
$stderr.expects(:puts).with("Published awesome-1.0.0.gem")
|
17
17
|
|
@@ -21,7 +21,7 @@ module GemPublisher
|
|
21
21
|
|
22
22
|
def test_should_not_report_unpublished_gem
|
23
23
|
GemPublisher.expects(:publish_if_updated).
|
24
|
-
with("awesome.gemspec", "rubygems").
|
24
|
+
with("awesome.gemspec", "rubygems", optionally({})).
|
25
25
|
returns(nil)
|
26
26
|
$stderr.expects(:puts).with("Nothing to do for awesome.gemspec")
|
27
27
|
|
@@ -31,7 +31,7 @@ module GemPublisher
|
|
31
31
|
|
32
32
|
def test_should_use_gemfury_if_requested
|
33
33
|
GemPublisher.expects(:publish_if_updated).
|
34
|
-
with("awesome.gemspec", "gemfury").
|
34
|
+
with("awesome.gemspec", "gemfury", optionally({})).
|
35
35
|
returns("awesome-1.0.0.gem")
|
36
36
|
$stderr.expects(:puts).with(anything)
|
37
37
|
|
@@ -41,12 +41,36 @@ module GemPublisher
|
|
41
41
|
|
42
42
|
def test_should_use_gemfury_with_long_option
|
43
43
|
GemPublisher.expects(:publish_if_updated).
|
44
|
-
with("awesome.gemspec", "gemfury").
|
44
|
+
with("awesome.gemspec", "gemfury", optionally({})).
|
45
45
|
returns("awesome-1.0.0.gem")
|
46
46
|
$stderr.expects(:puts).with(anything)
|
47
47
|
|
48
48
|
@command.handle_options ["--repository=gemfury", "awesome.gemspec"]
|
49
49
|
@command.execute
|
50
50
|
end
|
51
|
+
|
52
|
+
def test_should_use_specific_user_if_requested
|
53
|
+
expected_username = "username"
|
54
|
+
|
55
|
+
GemPublisher.expects(:publish_if_updated).
|
56
|
+
with("awesome.gemspec", 'rubygems', has_entry(:as, expected_username)).
|
57
|
+
returns("awesome-1.0.0.gem")
|
58
|
+
$stderr.expects(:puts).with(anything)
|
59
|
+
|
60
|
+
@command.handle_options ["-a", expected_username, "awesome.gemspec"]
|
61
|
+
@command.execute
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_should_use_specific_user_with_long_option
|
65
|
+
expected_username = "username"
|
66
|
+
|
67
|
+
GemPublisher.expects(:publish_if_updated).
|
68
|
+
with("awesome.gemspec", 'rubygems', has_entry(:as, expected_username)).
|
69
|
+
returns("awesome-1.0.0.gem")
|
70
|
+
$stderr.expects(:puts).with(anything)
|
71
|
+
|
72
|
+
@command.handle_options ["--as", expected_username, "awesome.gemspec"]
|
73
|
+
@command.execute
|
74
|
+
end
|
51
75
|
end
|
52
76
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gem_publisher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-10-
|
12
|
+
date: 2014-10-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mocha
|
@@ -99,7 +99,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
99
99
|
version: '0'
|
100
100
|
segments:
|
101
101
|
- 0
|
102
|
-
hash: -
|
102
|
+
hash: -839019601125332302
|
103
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
104
|
none: false
|
105
105
|
requirements:
|
@@ -108,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
108
|
version: '0'
|
109
109
|
segments:
|
110
110
|
- 0
|
111
|
-
hash: -
|
111
|
+
hash: -839019601125332302
|
112
112
|
requirements: []
|
113
113
|
rubyforge_project:
|
114
114
|
rubygems_version: 1.8.23.2
|