Permalink
Browse files

Updates Oauth2 gem and uses extra detail in user model.

  • Loading branch information...
1 parent 9b10bdf commit cf764ff1c019def1b947f5a8eb3b26e3f8be0d24 @philnash philnash committed Jan 12, 2011
Showing with 26 additions and 11 deletions.
  1. +6 −0 History.txt
  2. +1 −1 Rakefile
  3. +6 −7 bitly.gemspec
  4. +3 −2 lib/bitly/v3/oauth.rb
  5. +9 −0 lib/bitly/v3/user.rb
  6. +1 −1 lib/bitly/version.rb
View
@@ -1,3 +1,9 @@
+=== 0.6.1 / 2011-01-12
+
+* 1 minor enhancement
+
+ * Updated OAuth2 gem and used extra information to save login and api_key to user objects
+
=== 0.6.0 / 2011-01-03
* 1 major enhancement
View
@@ -8,6 +8,6 @@ Echoe.new('bitly', Bitly::VERSION) do |p|
p.url = "http://github.com/philnash/bitly"
p.author = "Phil Nash"
p.email = "philnash@gmail.com"
- p.extra_deps = [['crack', '>= 0.1.4'], ['httparty', '>= 0.5.2'], ['oauth2', '>= 0']]
+ p.extra_deps = [['crack', '>= 0.1.4'], ['httparty', '>= 0.5.2'], ['oauth2', '>= 0.1.1']]
p.development_dependencies = []
end
View
@@ -2,11 +2,11 @@
Gem::Specification.new do |s|
s.name = %q{bitly}
- s.version = "0.6.0"
+ s.version = "0.6.1"
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
s.authors = ["Phil Nash"]
- s.date = %q{2011-01-03}
+ s.date = %q{2011-01-12}
s.description = %q{Use the bit.ly API to shorten or expand URLs}
s.email = %q{philnash@gmail.com}
s.extra_rdoc_files = ["README.txt", "lib/bitly.rb", "lib/bitly/client.rb", "lib/bitly/url.rb", "lib/bitly/utils.rb", "lib/bitly/v3.rb", "lib/bitly/v3/bitly.rb", "lib/bitly/v3/client.rb", "lib/bitly/v3/country.rb", "lib/bitly/v3/day.rb", "lib/bitly/v3/missing_url.rb", "lib/bitly/v3/oauth.rb", "lib/bitly/v3/realtime_link.rb", "lib/bitly/v3/referrer.rb", "lib/bitly/v3/url.rb", "lib/bitly/v3/user.rb", "lib/bitly/version.rb"]
@@ -15,26 +15,25 @@ Gem::Specification.new do |s|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Bitly", "--main", "README.txt"]
s.require_paths = ["lib"]
s.rubyforge_project = %q{bitly}
- s.rubygems_version = %q{1.3.7}
+ s.rubygems_version = %q{1.4.1}
s.summary = %q{Use the bit.ly API to shorten or expand URLs}
s.test_files = ["test/bitly/test_client.rb", "test/bitly/test_url.rb", "test/bitly/test_utils.rb", "test/test_helper.rb"]
if s.respond_to? :specification_version then
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
s.specification_version = 3
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<crack>, [">= 0.1.4"])
s.add_runtime_dependency(%q<httparty>, [">= 0.5.2"])
- s.add_runtime_dependency(%q<oauth2>, [">= 0"])
+ s.add_runtime_dependency(%q<oauth2>, [">= 0.1.1"])
else
s.add_dependency(%q<crack>, [">= 0.1.4"])
s.add_dependency(%q<httparty>, [">= 0.5.2"])
- s.add_dependency(%q<oauth2>, [">= 0"])
+ s.add_dependency(%q<oauth2>, [">= 0.1.1"])
end
else
s.add_dependency(%q<crack>, [">= 0.1.4"])
s.add_dependency(%q<httparty>, [">= 0.5.2"])
- s.add_dependency(%q<oauth2>, [">= 0"])
+ s.add_dependency(%q<oauth2>, [">= 0.1.1"])
end
end
View
@@ -25,8 +25,9 @@ def get_access_token_from_code(code,redirect_url)
end
# If you already have a user token, this method gets the access token
- def get_access_token_from_token(token)
- @access_token ||= ::OAuth2::AccessToken.new(client, token)
+ def get_access_token_from_token(token, params={})
+ params = params.inject({}) { |options, (key, value)| options[key.to_s] = value; options }
+ @access_token ||= ::OAuth2::AccessToken.new(client, token, nil, nil, params)
end
end
end
View
@@ -16,8 +16,12 @@ module V3
#
# u=Bitly::V3::User.new(o.access_token)
class User
+ attr_accessor :login, :api_key
+
def initialize(access_token)
@access_token = access_token
+ @login = access_token['login'] || access_token['username']
+ @api_key = access_token['apiKey'] || access_token['api_key']
end
# OAuth 2 endpoint that provides a list of top referrers (up to 500 per
@@ -71,6 +75,11 @@ def total_clicks(opts={})
get_clicks(opts)
@total_clicks
end
+
+ # Returns a Bitly Client using the credentials of the user.
+ def client
+ @client ||= Bitly::V3::Client.new(login, api_key)
+ end
private
View
@@ -1,3 +1,3 @@
module Bitly
- VERSION = '0.6.0'
+ VERSION = '0.6.1'
end

0 comments on commit cf764ff

Please sign in to comment.