Class: Pod::Command::Trunk::AddOwner

Inherits:
Pod::Command::Trunk show all
Defined in:
lib/pod/command/trunk/add_owner.rb

Constant Summary

Constants inherited from Pod::Command::Trunk

BASE_URL, SCHEME_AND_HOST

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ AddOwner

Returns a new instance of AddOwner.



20
21
22
23
24
# File 'lib/pod/command/trunk/add_owner.rb', line 20

def initialize(argv)
  @pod = argv.shift_argument
  @email = argv.shift_argument
  super
end

Instance Method Details

#runObject



36
37
38
39
40
41
42
43
# File 'lib/pod/command/trunk/add_owner.rb', line 36

def run
  body = { 'email' => @email }.to_json
  json = json(request_path(:patch, "pods/#{@pod}/owners", body, auth_headers))
  UI.labeled 'Owners', json.map { |o| "#{o['name']} <#{o['email']}>" }
rescue REST::Error => e
  raise Informative, "There was an error adding #{@email} to " \
                           "#{@pod} on trunk: #{e.message}"
end

#validate!Object



26
27
28
29
30
31
32
33
34
# File 'lib/pod/command/trunk/add_owner.rb', line 26

def validate!
  super
  unless token
    help! 'You need to register a session first.'
  end
  unless @pod && @email
    help! 'Specify the pod name and the new owner’s email address.'
  end
end