Class: TwitterImages::Authorizer

Inherits:
Object
  • Object
show all
Defined in:
lib/twitter_images/authorizer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#access_secretObject (readonly)

Returns the value of attribute access_secret.



3
4
5
# File 'lib/twitter_images/authorizer.rb', line 3

def access_secret
  @access_secret
end

#access_tokenObject (readonly)

Returns the value of attribute access_token.



3
4
5
# File 'lib/twitter_images/authorizer.rb', line 3

def access_token
  @access_token
end

#access_token_objectObject (readonly)

Returns the value of attribute access_token_object.



3
4
5
# File 'lib/twitter_images/authorizer.rb', line 3

def access_token_object
  @access_token_object
end

#oauthObject (readonly)

Returns the value of attribute oauth.



3
4
5
# File 'lib/twitter_images/authorizer.rb', line 3

def oauth
  @oauth
end

#pinObject (readonly)

Returns the value of attribute pin.



3
4
5
# File 'lib/twitter_images/authorizer.rb', line 3

def pin
  @pin
end

#request_tokenObject (readonly)

Returns the value of attribute request_token.



3
4
5
# File 'lib/twitter_images/authorizer.rb', line 3

def request_token
  @request_token
end

Instance Method Details

#assign_credentialsObject



15
16
17
18
19
20
# File 'lib/twitter_images/authorizer.rb', line 15

def assign_credentials
  if File.exist?(ENV["HOME"] + "/.twitter_imagesrc")
    @access_token = IO.readlines(ENV["HOME"] + "/.twitter_imagesrc")[0].chomp
    @access_secret = IO.readlines(ENV["HOME"] + "/.twitter_imagesrc")[1].chomp
  end
end

#authorizeObject



5
6
7
8
9
10
11
12
13
# File 'lib/twitter_images/authorizer.rb', line 5

def authorize
  get_request_token
  visit_url
  get_pin
  authorize_with_pin
  write_credentials
  assign_credentials
  puts "Authorization successful. Credentials have been written to #{ENV['HOME']}/.twitter_imagesrc"
end