qrush-gemcutter 0.0.9 → 0.1.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/lib/commands/abstract_command.rb +2 -0
- data/lib/commands/owner.rb +89 -0
- data/lib/rubygems_plugin.rb +1 -1
- metadata +5 -4
@@ -0,0 +1,89 @@
|
|
1
|
+
class Gem::Commands::OwnerCommand < Gem::AbstractCommand
|
2
|
+
def description
|
3
|
+
'Manage gem owners on Gemcutter.'
|
4
|
+
end
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
super 'owner', description
|
8
|
+
defaults.merge!(:add => [], :remove => [])
|
9
|
+
|
10
|
+
add_option('-a', '--add EMAIL', 'Add an owner') do |value, options|
|
11
|
+
options[:add] << value
|
12
|
+
end
|
13
|
+
|
14
|
+
add_option('-r', '--remove EMAIL', 'Remove an owner') do |value, options|
|
15
|
+
options[:remove] << value
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def execute
|
20
|
+
setup
|
21
|
+
name = get_one_gem_name
|
22
|
+
|
23
|
+
add_owners name, options[:add]
|
24
|
+
remove_owners name, options[:remove]
|
25
|
+
show_owners name
|
26
|
+
end
|
27
|
+
|
28
|
+
def add_owners(name, owners)
|
29
|
+
owners.each do |owner|
|
30
|
+
response = make_request(:post, "gems/#{name}/owners.json") do |request|
|
31
|
+
request.set_form_data(:email => owner)
|
32
|
+
request.add_field("Authorization", api_key)
|
33
|
+
end
|
34
|
+
|
35
|
+
case response
|
36
|
+
when Net::HTTPSuccess
|
37
|
+
say "Added owner: #{owner}"
|
38
|
+
else
|
39
|
+
say "Error adding owner: #{owner}"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def remove_owners(name, owners)
|
45
|
+
owners.each do |owner|
|
46
|
+
response = make_request(:delete, "gems/#{name}/owners.json") do |request|
|
47
|
+
request.set_form_data(:email => owner)
|
48
|
+
request.add_field("Authorization", api_key)
|
49
|
+
end
|
50
|
+
|
51
|
+
case response
|
52
|
+
when Net::HTTPSuccess
|
53
|
+
say "Removed owner: #{owner}"
|
54
|
+
else
|
55
|
+
say "Error removing owner: #{owner}"
|
56
|
+
end
|
57
|
+
end end
|
58
|
+
|
59
|
+
def show_owners(name)
|
60
|
+
require 'json'
|
61
|
+
response = make_request(:get, "gems/#{name}/owners.json") do |request|
|
62
|
+
request.add_field("Authorization", api_key)
|
63
|
+
end
|
64
|
+
|
65
|
+
case response
|
66
|
+
when Net::HTTPSuccess
|
67
|
+
begin
|
68
|
+
owners = JSON.parse(response.body)
|
69
|
+
|
70
|
+
say "Owners for gem: #{name}"
|
71
|
+
owners.each do |owner|
|
72
|
+
say "- #{owner['email']}"
|
73
|
+
end
|
74
|
+
rescue JSON::ParserError => json_error
|
75
|
+
say "There was a problem parsing the data: #{json_error}"
|
76
|
+
terminate_interaction
|
77
|
+
end
|
78
|
+
when Net::HTTPNotFound
|
79
|
+
say "This gem is currently not hosted on Gemcutter."
|
80
|
+
terminate_interaction
|
81
|
+
when Net::HTTPUnauthorized
|
82
|
+
say "You do not have permission to manage this gem."
|
83
|
+
terminate_interaction
|
84
|
+
else
|
85
|
+
say "There was a problem processing your request."
|
86
|
+
terminate_interaction
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
data/lib/rubygems_plugin.rb
CHANGED
@@ -3,7 +3,7 @@ $:.unshift File.dirname(__FILE__) # For use/testing when no gem is installed
|
|
3
3
|
require 'rubygems/command_manager'
|
4
4
|
require 'commands/abstract_command'
|
5
5
|
|
6
|
-
%w[migrate push tumble].each do |command|
|
6
|
+
%w[migrate owner push tumble].each do |command|
|
7
7
|
require "commands/#{command}"
|
8
8
|
Gem::CommandManager.instance.register_command command.to_sym
|
9
9
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qrush-gemcutter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Quaranto
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-08-
|
12
|
+
date: 2009-08-18 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -43,6 +43,7 @@ extra_rdoc_files:
|
|
43
43
|
files:
|
44
44
|
- lib/commands/abstract_command.rb
|
45
45
|
- lib/commands/migrate.rb
|
46
|
+
- lib/commands/owner.rb
|
46
47
|
- lib/commands/push.rb
|
47
48
|
- lib/commands/tumble.rb
|
48
49
|
- lib/rubygems_plugin.rb
|
@@ -86,7 +87,7 @@ specification_version: 3
|
|
86
87
|
summary: Commands to interact with gemcutter.org
|
87
88
|
test_files:
|
88
89
|
- test/command_helper.rb
|
89
|
-
- test/commands/abstract_command_test.rb
|
90
90
|
- test/commands/migrate_command_test.rb
|
91
|
-
- test/commands/push_command_test.rb
|
92
91
|
- test/commands/tumble_command_test.rb
|
92
|
+
- test/commands/push_command_test.rb
|
93
|
+
- test/commands/abstract_command_test.rb
|