gemcutter 0.0.9 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -58,6 +58,8 @@ class Gem::AbstractCommand < Gem::Command
58
58
  proxy_class::Post
59
59
  when :put
60
60
  proxy_class::Put
61
+ when :delete
62
+ proxy_class::Delete
61
63
  else
62
64
  raise ArgumentError
63
65
  end
@@ -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
@@ -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: gemcutter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
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-17 00:00:00 -04:00
12
+ date: 2009-08-18 00:00:00 -04: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
@@ -81,13 +82,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
82
  requirements: []
82
83
 
83
84
  rubyforge_project: gemcutter
84
- rubygems_version: 1.3.4
85
+ rubygems_version: 1.3.5
85
86
  signing_key:
86
87
  specification_version: 3
87
88
  summary: Commands to interact with gemcutter.org
88
89
  test_files:
89
90
  - test/command_helper.rb
90
- - test/commands/abstract_command_test.rb
91
91
  - test/commands/migrate_command_test.rb
92
- - test/commands/push_command_test.rb
93
92
  - test/commands/tumble_command_test.rb
93
+ - test/commands/push_command_test.rb
94
+ - test/commands/abstract_command_test.rb