Class: Client
- Inherits:
-
Object
- Object
- Client
- Defined in:
- lib/gripst/client.rb
Constant Summary collapse
- PATH =
ENV['HOME'] + '/.gripst'
Instance Attribute Summary collapse
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Class Method Summary collapse
Instance Method Summary collapse
- #authorize ⇒ Object
-
#initialize ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize ⇒ Client
Returns a new instance of Client.
35 36 37 38 |
# File 'lib/gripst/client.rb', line 35 def initialize @username = get_username @password = get_password end |
Instance Attribute Details
#password ⇒ Object (readonly)
Returns the value of attribute password.
32 33 34 |
# File 'lib/gripst/client.rb', line 32 def password @password end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
32 33 34 |
# File 'lib/gripst/client.rb', line 32 def username @username end |
Class Method Details
.get_auth_token ⇒ Object
7 8 9 10 11 |
# File 'lib/gripst/client.rb', line 7 def get_auth_token return oauth_from_file if oauth_from_file = Client.new . end |
.login_with_oauth(oauth_token) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/gripst/client.rb', line 13 def login_with_oauth(oauth_token) client = Octokit::Client.new :access_token => oauth_token client.user.login client rescue Octokit::Unauthorized puts '---' puts '---' puts '---' puts 'Unable to create personal access token on github. Is the gripst application already set? https://github.com/settings/tokens' exit end |
Instance Method Details
#authorize ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/gripst/client.rb', line 40 def begin auth_token = client. :scopes => ['gists'], :note => 'gripst' rescue Octokit::OneTimePasswordRequired otp = get_otp auth_token = otp rescue Octokit::Unauthorized puts '---' puts '---' puts '---' puts 'Username or password was incorrect' exit end write_auth_token auth_token auth_token end |