Class Gem::Commands::OwnerCommand
In: lib/rubygems/commands/owner_command.rb
Parent: Gem::Command

Methods

Included Modules

Gem::LocalRemoteOptions Gem::GemcutterUtilities

Public Class methods

[Source]

    # File lib/rubygems/commands/owner_command.rb, line 17
17:   def initialize
18:     super 'owner', description
19:     add_proxy_option
20:     add_key_option
21:     defaults.merge! :add => [], :remove => []
22: 
23:     add_option '-a', '--add EMAIL', 'Add an owner' do |value, options|
24:       options[:add] << value
25:     end
26: 
27:     add_option '-r', '--remove EMAIL', 'Remove an owner' do |value, options|
28:       options[:remove] << value
29:     end
30:   end

Public Instance methods

[Source]

    # File lib/rubygems/commands/owner_command.rb, line 56
56:   def add_owners name, owners
57:     manage_owners :post, name, owners
58:   end

[Source]

    # File lib/rubygems/commands/owner_command.rb, line 32
32:   def execute
33:     sign_in
34:     name = get_one_gem_name
35: 
36:     add_owners    name, options[:add]
37:     remove_owners name, options[:remove]
38:     show_owners   name
39:   end

[Source]

    # File lib/rubygems/commands/owner_command.rb, line 64
64:   def manage_owners method, name, owners
65:     owners.each do |owner|
66:       response = rubygems_api_request method, "api/v1/gems/#{name}/owners" do |request|
67:         request.set_form_data 'email' => owner
68:         request.add_field "Authorization", api_key
69:       end
70: 
71:       with_response response
72:     end
73:   end

[Source]

    # File lib/rubygems/commands/owner_command.rb, line 60
60:   def remove_owners name, owners
61:     manage_owners :delete, name, owners
62:   end

[Source]

    # File lib/rubygems/commands/owner_command.rb, line 41
41:   def show_owners name
42:     response = rubygems_api_request :get, "api/v1/gems/#{name}/owners.yaml" do |request|
43:       request.add_field "Authorization", api_key
44:     end
45: 
46:     with_response response do |resp|
47:       owners = YAML.load resp.body
48: 
49:       say "Owners for gem: #{name}"
50:       owners.each do |owner|
51:         say "- #{owner['email']}"
52:       end
53:     end
54:   end

[Validate]