twurl 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,8 +11,10 @@ module Twurl
11
11
  def load_from_options(options)
12
12
  if rcfile.has_oauth_profile_for_username_with_consumer_key?(options.username, options.consumer_key)
13
13
  load_client_for_username_and_consumer_key(options.username, options.consumer_key)
14
+ elsif options.username || (options.command == 'authorize')
15
+ load_new_client_from_options(options)
14
16
  else
15
- options.username ? load_new_client_from_options(options) : load_default_client
17
+ load_default_client
16
18
  end
17
19
  end
18
20
 
@@ -109,8 +111,12 @@ module Twurl
109
111
  {:oauth_callback => 'oob'}
110
112
  end
111
113
 
114
+ def fetch_verify_credentials
115
+ access_token.get('/1/account/verify_credentials.json')
116
+ end
117
+
112
118
  def authorized?
113
- oauth_response = access_token.get('/1/account/verify_credentials.json')
119
+ oauth_response = fetch_verify_credentials
114
120
  oauth_response.class == Net::HTTPOK
115
121
  end
116
122
 
@@ -119,9 +125,18 @@ module Twurl
119
125
  end
120
126
 
121
127
  def save
128
+ verify_has_username
122
129
  self.class.rcfile << self
123
130
  end
124
131
 
132
+ def verify_has_username
133
+ if username.nil? || username == ''
134
+ oauth_response = fetch_verify_credentials
135
+ oauth_response.body =~ /"screen_name"\s*:\s*"(.*?)"/
136
+ @username = $1
137
+ end
138
+ end
139
+
125
140
  def to_hash
126
141
  OAUTH_CLIENT_OPTIONS.inject({}) do |hash, attribute|
127
142
  if value = send(attribute)
@@ -141,13 +156,11 @@ module Twurl
141
156
 
142
157
  def consumer
143
158
  @consumer ||=
144
- begin
145
159
  OAuth::Consumer.new(
146
160
  consumer_key,
147
161
  consumer_secret,
148
162
  :site => Twurl.options.base_url
149
163
  )
150
- end
151
164
  end
152
165
 
153
166
  def access_token
data/lib/twurl/version.rb CHANGED
@@ -2,9 +2,9 @@ module Twurl
2
2
  module VERSION
3
3
  MAJOR = '0'
4
4
  MINOR = '6'
5
- TINY = '0'
5
+ TINY = '1'
6
6
  BETA = nil # Time.now.to_i.to_s
7
7
  end
8
8
 
9
9
  Version = [VERSION::MAJOR, VERSION::MINOR, VERSION::TINY, VERSION::BETA].compact * '.'
10
- end
10
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 6
8
- - 0
9
- version: 0.6.0
8
+ - 1
9
+ version: 0.6.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Marcel Molina
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-04-20 00:00:00 -07:00
18
+ date: 2010-04-22 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency