gemcutter 0.4.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +5 -6
- data/lib/rubygems/commands/{migrate.rb → migrate_command.rb} +0 -0
- data/lib/rubygems/commands/{tumble.rb → tumble_command.rb} +0 -0
- data/lib/rubygems/commands/{webhook.rb → webhook_command.rb} +4 -6
- data/lib/rubygems/commands/yank_command.rb +72 -0
- data/lib/rubygems_plugin.rb +7 -1
- data/test/webhook_command_test.rb +14 -9
- data/test/yank_command_test.rb +85 -0
- metadata +35 -30
- data/lib/gemcutter.rb +0 -6
data/Rakefile
CHANGED
@@ -13,14 +13,13 @@ begin
|
|
13
13
|
require 'jeweler'
|
14
14
|
Jeweler::Tasks.new do |gem|
|
15
15
|
gem.name = "gemcutter"
|
16
|
-
gem.version = "0.
|
16
|
+
gem.version = "0.6.0"
|
17
17
|
gem.summary = "Commands to interact with RubyGems.org"
|
18
18
|
gem.description = "Adds several commands to RubyGems for managing gems and more on RubyGems.org."
|
19
19
|
gem.email = "nick@quaran.to"
|
20
20
|
gem.homepage = "http://rubygems.org"
|
21
21
|
gem.authors = ["Nick Quaranto"]
|
22
22
|
gem.files = FileList["lib/rubygems_plugin.rb",
|
23
|
-
"lib/gemcutter.rb",
|
24
23
|
"lib/rubygems/commands/*",
|
25
24
|
"test/*_helper.rb",
|
26
25
|
"test/*_test.rb",
|
@@ -28,7 +27,6 @@ begin
|
|
28
27
|
"Rakefile"]
|
29
28
|
gem.test_files = []
|
30
29
|
gem.executables = []
|
31
|
-
gem.add_runtime_dependency('json_pure')
|
32
30
|
%w[rake shoulda activesupport webmock rr].each do |dep|
|
33
31
|
gem.add_development_dependency(dep)
|
34
32
|
end
|
@@ -38,9 +36,10 @@ begin
|
|
38
36
|
|
39
37
|
Thanks for installing Gemcutter! You can now run:
|
40
38
|
|
41
|
-
|
42
|
-
|
43
|
-
|
39
|
+
gem push merged into RubyGems 1.3.6
|
40
|
+
gem owner merged into RubyGems 1.3.6
|
41
|
+
gem webhook register urls to be pinged when gems are pushed
|
42
|
+
gem yank remove a specific version of a gem from RubyGems.org
|
44
43
|
|
45
44
|
========================================================================
|
46
45
|
|
File without changes
|
File without changes
|
@@ -74,15 +74,13 @@ EOF
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def list_webhooks
|
77
|
-
|
78
|
-
|
79
|
-
resp = rubygems_api_request(:get, "api/v1/web_hooks") do |request|
|
77
|
+
resp = rubygems_api_request(:get, "api/v1/web_hooks.yaml") do |request|
|
80
78
|
request.add_field("Authorization", Gem.configuration.rubygems_api_key)
|
81
79
|
end
|
82
80
|
|
83
81
|
with_response(resp) do |response|
|
84
82
|
begin
|
85
|
-
groups =
|
83
|
+
groups = YAML.load(response.body)
|
86
84
|
|
87
85
|
if groups.size.zero?
|
88
86
|
say "You haven't added any webhooks yet."
|
@@ -100,9 +98,9 @@ EOF
|
|
100
98
|
end
|
101
99
|
end
|
102
100
|
end
|
103
|
-
rescue
|
101
|
+
rescue Exception => error
|
104
102
|
say "There was a problem parsing the data:"
|
105
|
-
say
|
103
|
+
say error.to_s
|
106
104
|
terminate_interaction
|
107
105
|
end
|
108
106
|
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'rubygems/local_remote_options'
|
2
|
+
require 'rubygems/version_option'
|
3
|
+
require 'rubygems/gemcutter_utilities'
|
4
|
+
|
5
|
+
class Gem::Commands::YankCommand < Gem::Command
|
6
|
+
include Gem::LocalRemoteOptions
|
7
|
+
include Gem::VersionOption
|
8
|
+
include Gem::GemcutterUtilities
|
9
|
+
|
10
|
+
def description
|
11
|
+
'Remove a specific gem version release from RubyGems.org'
|
12
|
+
end
|
13
|
+
|
14
|
+
def arguments
|
15
|
+
"GEM name of gem"
|
16
|
+
end
|
17
|
+
|
18
|
+
def usage
|
19
|
+
"#{program_name} GEM -v VERSION [--undo]"
|
20
|
+
end
|
21
|
+
|
22
|
+
def initialize
|
23
|
+
super 'yank', description
|
24
|
+
add_version_option("remove")
|
25
|
+
add_option('--undo') do |value, options|
|
26
|
+
options[:undo] = true
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def execute
|
31
|
+
sign_in
|
32
|
+
version = get_version_from_requirements(options[:version])
|
33
|
+
if !version.nil?
|
34
|
+
if options[:undo]
|
35
|
+
unyank_gem(version)
|
36
|
+
else
|
37
|
+
yank_gem(version)
|
38
|
+
end
|
39
|
+
else
|
40
|
+
say "A version argument is required: #{usage}"
|
41
|
+
terminate_interaction
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def yank_gem(version)
|
46
|
+
say "Yanking gem from RubyGems.org..."
|
47
|
+
yank_api_request(:delete, version, "api/v1/gems/yank")
|
48
|
+
end
|
49
|
+
|
50
|
+
def unyank_gem(version)
|
51
|
+
say "Unyanking gem from RubyGems.org..."
|
52
|
+
yank_api_request(:put, version, "api/v1/gems/unyank")
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
def yank_api_request(method, version, api)
|
57
|
+
name = get_one_gem_name
|
58
|
+
response = rubygems_api_request(method, api) do |request|
|
59
|
+
request.add_field("Authorization", Gem.configuration.rubygems_api_key)
|
60
|
+
request.set_form_data({'gem_name' => name, 'version' => version})
|
61
|
+
end
|
62
|
+
say response.body
|
63
|
+
end
|
64
|
+
|
65
|
+
def get_version_from_requirements(requirements)
|
66
|
+
begin
|
67
|
+
requirements.requirements.first[1].version
|
68
|
+
rescue
|
69
|
+
nil
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
data/lib/rubygems_plugin.rb
CHANGED
@@ -1 +1,7 @@
|
|
1
|
-
require
|
1
|
+
require 'rubygems/command_manager'
|
2
|
+
|
3
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.3.6')
|
4
|
+
%w[migrate tumble webhook yank].each do |command|
|
5
|
+
Gem::CommandManager.instance.register_command command.to_sym
|
6
|
+
end
|
7
|
+
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'helper'
|
2
|
+
require 'lib/rubygems/commands/webhook_command'
|
2
3
|
|
3
4
|
class WebhookCommandTest < CommandTest
|
4
5
|
context "webhooking" do
|
@@ -71,11 +72,15 @@ class WebhookCommandTest < CommandTest
|
|
71
72
|
context "listing hooks with some available" do
|
72
73
|
setup do
|
73
74
|
stub_api_key("key")
|
74
|
-
stub_request(:get, @api).to_return :body => <<EOF
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
75
|
+
stub_request(:get, "#{@api}.yaml").to_return :body => <<EOF
|
76
|
+
---
|
77
|
+
foo:
|
78
|
+
- url: http://foogemhook.com
|
79
|
+
failure_count: 0
|
80
|
+
all gems:
|
81
|
+
- url: http://allgemshook.com
|
82
|
+
failure_count: 0
|
83
|
+
|
79
84
|
EOF
|
80
85
|
end
|
81
86
|
|
@@ -114,9 +119,9 @@ EOF
|
|
114
119
|
@command.execute
|
115
120
|
|
116
121
|
# webmock doesn't pass body params on correctly :[
|
117
|
-
assert_requested(:get, @api,
|
122
|
+
assert_requested(:get, "#{@api}.yaml",
|
118
123
|
:times => 1)
|
119
|
-
assert_requested(:get, @api,
|
124
|
+
assert_requested(:get, "#{@api}.yaml",
|
120
125
|
:headers => { 'Authorization' => 'key' })
|
121
126
|
end
|
122
127
|
end
|
@@ -124,7 +129,7 @@ EOF
|
|
124
129
|
context "listing hooks with none available" do
|
125
130
|
setup do
|
126
131
|
stub_api_key("key")
|
127
|
-
stub_request(:get, @api).to_return(:body => "{}")
|
132
|
+
stub_request(:get, "#{@api}.yaml").to_return(:body => "{}")
|
128
133
|
@command.handle_options([])
|
129
134
|
@command.execute
|
130
135
|
end
|
@@ -140,7 +145,7 @@ EOF
|
|
140
145
|
setup do
|
141
146
|
stub(@command).terminate_interaction
|
142
147
|
stub_api_key("key")
|
143
|
-
stub_request(:get, @api).to_return(:body => "fubar")
|
148
|
+
stub_request(:get, "#{@api}.yaml").to_return(:body => "fubar")
|
144
149
|
@command.handle_options([])
|
145
150
|
@command.execute
|
146
151
|
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'lib/rubygems/commands/yank_command'
|
3
|
+
|
4
|
+
class YankCommandTest < CommandTest
|
5
|
+
context "yanking" do
|
6
|
+
setup do
|
7
|
+
@gem = "MyGem"
|
8
|
+
@version = '0.1.0'
|
9
|
+
@command = Gem::Commands::YankCommand.new
|
10
|
+
stub(@command).say
|
11
|
+
end
|
12
|
+
|
13
|
+
%w[-v --version].each do |option|
|
14
|
+
should "raise an error with no version with #{option}" do
|
15
|
+
assert_raise OptionParser::MissingArgument do
|
16
|
+
@command.handle_options([@gem, option])
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'yanking a gem' do
|
22
|
+
setup do
|
23
|
+
stub_api_key("key")
|
24
|
+
@api = "https://rubygems.org/api/v1/gems/yank"
|
25
|
+
stub_request(:delete, @api).to_return(:body => "Successfully yanked")
|
26
|
+
@command.handle_options([@gem, "-v", @version])
|
27
|
+
end
|
28
|
+
|
29
|
+
should 'say gem was yanked' do
|
30
|
+
@command.execute
|
31
|
+
assert_received(@command) do |command|
|
32
|
+
command.say("Yanking gem from Gemcutter...")
|
33
|
+
command.say("Successfully yanked")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
should 'invoke yank_gem' do
|
38
|
+
stub(@command).yank_gem(@version)
|
39
|
+
@command.execute
|
40
|
+
assert_received(@command) do |command|
|
41
|
+
command.yank_gem(@version)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
should 'delete to api' do
|
46
|
+
@command.execute
|
47
|
+
assert_requested(:delete, @api,
|
48
|
+
:times => 1)
|
49
|
+
assert_requested(:delete, @api,
|
50
|
+
:headers => { 'Authorization' => 'key' })
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context 'unyanking a gem' do
|
55
|
+
setup do
|
56
|
+
stub_api_key("key")
|
57
|
+
@api = "https://rubygems.org/api/v1/gems/unyank"
|
58
|
+
stub_request(:put, @api).to_return(:body => "Successfully unyanked")
|
59
|
+
@command.handle_options([@gem, "-v", @version, "--undo"])
|
60
|
+
end
|
61
|
+
|
62
|
+
should 'say gem was unyanked' do
|
63
|
+
@command.execute
|
64
|
+
assert_received(@command) do |command|
|
65
|
+
command.say("Re-indexing gem")
|
66
|
+
command.say("Successfully unyanked")
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
should 'invoke unyank_gem' do
|
71
|
+
stub(@command).unyank_gem(@version)
|
72
|
+
@command.execute
|
73
|
+
assert_received(@command) do |command|
|
74
|
+
command.unyank_gem(@version)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
should 'put to api' do
|
79
|
+
@command.execute
|
80
|
+
assert_requested(:put, @api, :times => 1)
|
81
|
+
assert_requested(:put, @api, :headers => { 'Authorization' => 'key' })
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gemcutter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 7
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
8
|
+
- 6
|
9
|
+
- 0
|
10
|
+
version: 0.6.0
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Nick Quaranto
|
@@ -14,81 +15,79 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
+
date: 2010-07-17 00:00:00 -05:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
|
-
name:
|
22
|
+
name: rake
|
22
23
|
prerelease: false
|
23
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
24
26
|
requirements:
|
25
27
|
- - ">="
|
26
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
27
30
|
segments:
|
28
31
|
- 0
|
29
32
|
version: "0"
|
30
|
-
type: :
|
33
|
+
type: :development
|
31
34
|
version_requirements: *id001
|
32
35
|
- !ruby/object:Gem::Dependency
|
33
|
-
name:
|
36
|
+
name: shoulda
|
34
37
|
prerelease: false
|
35
38
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
36
40
|
requirements:
|
37
41
|
- - ">="
|
38
42
|
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
39
44
|
segments:
|
40
45
|
- 0
|
41
46
|
version: "0"
|
42
47
|
type: :development
|
43
48
|
version_requirements: *id002
|
44
49
|
- !ruby/object:Gem::Dependency
|
45
|
-
name:
|
50
|
+
name: activesupport
|
46
51
|
prerelease: false
|
47
52
|
requirement: &id003 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
48
54
|
requirements:
|
49
55
|
- - ">="
|
50
56
|
- !ruby/object:Gem::Version
|
57
|
+
hash: 3
|
51
58
|
segments:
|
52
59
|
- 0
|
53
60
|
version: "0"
|
54
61
|
type: :development
|
55
62
|
version_requirements: *id003
|
56
63
|
- !ruby/object:Gem::Dependency
|
57
|
-
name:
|
64
|
+
name: webmock
|
58
65
|
prerelease: false
|
59
66
|
requirement: &id004 !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
60
68
|
requirements:
|
61
69
|
- - ">="
|
62
70
|
- !ruby/object:Gem::Version
|
71
|
+
hash: 3
|
63
72
|
segments:
|
64
73
|
- 0
|
65
74
|
version: "0"
|
66
75
|
type: :development
|
67
76
|
version_requirements: *id004
|
68
77
|
- !ruby/object:Gem::Dependency
|
69
|
-
name:
|
78
|
+
name: rr
|
70
79
|
prerelease: false
|
71
80
|
requirement: &id005 !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
72
82
|
requirements:
|
73
83
|
- - ">="
|
74
84
|
- !ruby/object:Gem::Version
|
85
|
+
hash: 3
|
75
86
|
segments:
|
76
87
|
- 0
|
77
88
|
version: "0"
|
78
89
|
type: :development
|
79
90
|
version_requirements: *id005
|
80
|
-
- !ruby/object:Gem::Dependency
|
81
|
-
name: rr
|
82
|
-
prerelease: false
|
83
|
-
requirement: &id006 !ruby/object:Gem::Requirement
|
84
|
-
requirements:
|
85
|
-
- - ">="
|
86
|
-
- !ruby/object:Gem::Version
|
87
|
-
segments:
|
88
|
-
- 0
|
89
|
-
version: "0"
|
90
|
-
type: :development
|
91
|
-
version_requirements: *id006
|
92
91
|
description: Adds several commands to RubyGems for managing gems and more on RubyGems.org.
|
93
92
|
email: nick@quaran.to
|
94
93
|
executables: []
|
@@ -100,12 +99,13 @@ extra_rdoc_files: []
|
|
100
99
|
files:
|
101
100
|
- MIT-LICENSE
|
102
101
|
- Rakefile
|
103
|
-
- lib/
|
104
|
-
- lib/rubygems/commands/
|
105
|
-
- lib/rubygems/commands/
|
106
|
-
- lib/rubygems/commands/
|
102
|
+
- lib/rubygems/commands/migrate_command.rb
|
103
|
+
- lib/rubygems/commands/tumble_command.rb
|
104
|
+
- lib/rubygems/commands/webhook_command.rb
|
105
|
+
- lib/rubygems/commands/yank_command.rb
|
107
106
|
- lib/rubygems_plugin.rb
|
108
107
|
- test/webhook_command_test.rb
|
108
|
+
- test/yank_command_test.rb
|
109
109
|
has_rdoc: true
|
110
110
|
homepage: http://rubygems.org
|
111
111
|
licenses: []
|
@@ -116,9 +116,10 @@ post_install_message: |+
|
|
116
116
|
|
117
117
|
Thanks for installing Gemcutter! You can now run:
|
118
118
|
|
119
|
-
|
120
|
-
|
121
|
-
|
119
|
+
gem push merged into RubyGems 1.3.6
|
120
|
+
gem owner merged into RubyGems 1.3.6
|
121
|
+
gem webhook register urls to be pinged when gems are pushed
|
122
|
+
gem yank remove a specific version of a gem from RubyGems.org
|
122
123
|
|
123
124
|
========================================================================
|
124
125
|
|
@@ -127,23 +128,27 @@ rdoc_options:
|
|
127
128
|
require_paths:
|
128
129
|
- lib
|
129
130
|
required_ruby_version: !ruby/object:Gem::Requirement
|
131
|
+
none: false
|
130
132
|
requirements:
|
131
133
|
- - ">="
|
132
134
|
- !ruby/object:Gem::Version
|
135
|
+
hash: 3
|
133
136
|
segments:
|
134
137
|
- 0
|
135
138
|
version: "0"
|
136
139
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
140
|
+
none: false
|
137
141
|
requirements:
|
138
142
|
- - ">="
|
139
143
|
- !ruby/object:Gem::Version
|
144
|
+
hash: 3
|
140
145
|
segments:
|
141
146
|
- 0
|
142
147
|
version: "0"
|
143
148
|
requirements: []
|
144
149
|
|
145
150
|
rubyforge_project:
|
146
|
-
rubygems_version: 1.3.
|
151
|
+
rubygems_version: 1.3.7
|
147
152
|
signing_key:
|
148
153
|
specification_version: 3
|
149
154
|
summary: Commands to interact with RubyGems.org
|