Class: EasyAuto::Authorize
Instance Attribute Summary collapse
Instance Method Summary
collapse
#config_manager
#check_install, #cli_send, #os
#ask, #hidden_input
Instance Attribute Details
#email ⇒ Object
Returns the value of attribute email.
11
12
13
|
# File 'lib/easy_auto/authorize.rb', line 11
def email
@email
end
|
#password ⇒ Object
Returns the value of attribute password.
12
13
14
|
# File 'lib/easy_auto/authorize.rb', line 12
def password
@password
end
|
#token ⇒ Object
Returns the value of attribute token.
13
14
15
|
# File 'lib/easy_auto/authorize.rb', line 13
def token
@token
end
|
Instance Method Details
#generate_token ⇒ Object
43
44
45
|
# File 'lib/easy_auto/authorize.rb', line 43
def generate_token
self.token = JSON.parse(github_curl)['token']
end
|
#get_credentials ⇒ Object
28
29
30
31
|
# File 'lib/easy_auto/authorize.rb', line 28
def get_credentials
self.email = get_email
self.password = get_password
end
|
#get_email ⇒ Object
33
34
35
36
|
# File 'lib/easy_auto/authorize.rb', line 33
def get_email
puts "what is your github email account?"
gets.strip
end
|
#get_password ⇒ Object
38
39
40
41
|
# File 'lib/easy_auto/authorize.rb', line 38
def get_password
puts "enter your password for #{email}. this will not be stored."
hidden_input
end
|
#github_curl ⇒ Object
47
48
49
|
# File 'lib/easy_auto/authorize.rb', line 47
def github_curl
cli_send %Q(curl -u '#{email}:#{password}' -d '{"scopes": ["repo"], "notes": "Easy Auto"}' https://api.github.com/authorizations)
end
|
#run ⇒ Object
15
16
17
18
19
|
# File 'lib/easy_auto/authorize.rb', line 15
def run
get_credentials
generate_token
store_token
end
|
#store_token ⇒ Object
21
22
23
24
25
26
|
# File 'lib/easy_auto/authorize.rb', line 21
def store_token
GeneralStore.create '~/.easy-auto' do |gs|
gs.github_email = email
gs.github_token = token
end
end
|