Class: Client

Inherits:
Object
  • Object
show all
Defined in:
lib/gripst/client.rb

Constant Summary collapse

PATH =
ENV['HOME'] + '/.gripst'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeClient

Returns a new instance of Client.



24
25
26
27
# File 'lib/gripst/client.rb', line 24

def initialize
  @username = get_username
  @password = get_password
end

Instance Attribute Details

#passwordObject (readonly)

Returns the value of attribute password.



21
22
23
# File 'lib/gripst/client.rb', line 21

def password
  @password
end

#usernameObject (readonly)

Returns the value of attribute username.



21
22
23
# File 'lib/gripst/client.rb', line 21

def username
  @username
end

Class Method Details

.get_auth_tokenObject



8
9
10
11
12
# File 'lib/gripst/client.rb', line 8

def get_auth_token
  return oauth_from_file if oauth_from_file
  authorizer = Client.new
  authorizer.authorize
end

Instance Method Details

#authorizeObject



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/gripst/client.rb', line 29

def authorize

  begin
    auth_token = client.create_authorization :scopes => ['gists'], :note => 'gripst'
  rescue Octokit::OneTimePasswordRequired
    otp = get_otp
    auth_token = authorize_with_otp otp
  end

  write_auth_token auth_token
   auth_token
end