class Pod::Command::Trunk::Register

@CocoaPods 0.33.0

Public Class Methods

new(argv) click to toggle source
Calls superclass method
# File lib/pod/command/trunk/register.rb, line 41
def initialize(argv)
  @session_description = argv.option('description')
  @email = argv.shift_argument
  @name = argv.shift_argument
  super
end
options() click to toggle source
Calls superclass method
# File lib/pod/command/trunk/register.rb, line 33
def self.options
  [
    ['--description=DESCRIPTION', 'An arbitrary description to ' \
                                      'easily identify your session ' \
                                      'later on.'],
  ].concat(super)
end

Public Instance Methods

run() click to toggle source
# File lib/pod/command/trunk/register.rb, line 55
def run
  body = {
    'email' => @email,
    'name' => @name,
    'description' => @session_description,
  }.to_json
  json = json(request_path(:post, 'sessions', body, default_headers))
  save_token(json['token'])
  # TODO UI.notice inserts an empty line :/
  UI.puts '[!] Please verify the session by clicking the link in the ' \
          "verification email that has been sent to #{@email}".yellow
rescue REST::Error => e
  raise Informative, 'There was an error registering with trunk: ' \
                         "#{e.message}"
end
save_token(token) click to toggle source
# File lib/pod/command/trunk/register.rb, line 71
def save_token(token)
  netrc['trunk.cocoapods.org'] = @email, token
  netrc.save
end
validate!() click to toggle source
Calls superclass method
# File lib/pod/command/trunk/register.rb, line 48
def validate!
  super
  unless @email
    help! 'Specify at least your email address.'
  end
end