Class: Pod::Command::Trunk::Register
Constant Summary
BASE_URL, SCHEME_AND_HOST
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(argv) ⇒ Register
Returns a new instance of Register.
41
42
43
44
45
46
|
# 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
|
Class Method Details
.options ⇒ Object
33
34
35
36
37
38
39
|
# 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
|
Instance Method Details
#run ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# 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, ))
save_token(json['token'])
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) ⇒ Object
71
72
73
74
|
# File 'lib/pod/command/trunk/register.rb', line 71
def save_token(token)
netrc['trunk.cocoapods.org'] = @email, token
netrc.save
end
|
#validate! ⇒ Object
48
49
50
51
52
53
|
# File 'lib/pod/command/trunk/register.rb', line 48
def validate!
super
unless @email
help! 'Specify at least your email address.'
end
end
|