bitly 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/History.txt CHANGED
@@ -1,3 +1,10 @@
1
+ === 0.10.0 / 2014-2-23
2
+
3
+ * 2 major updates
4
+
5
+ * Updates OAuth2 gem dependency to include version 0.9.x
6
+ * Adds support for generic OAuth2 access token in V3 API, thanks to fzagarzazu (issue #47)
7
+
1
8
  === 0.9.0 / 2013-4-28
2
9
 
3
10
  * 2 major updates
data/README.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  ## DESCRIPTION:
4
4
 
5
- A Ruby API for [http://bit.ly](http://bit.ly)
5
+ A Ruby API for [http://bitly.com](http://bitly.com)
6
6
 
7
- [http://code.google.com/p/bitly-api/wiki/ApiDocumentation](http://code.google.com/p/bitly-api/wiki/ApiDocumentation)
7
+ [http://dev.bitly.com](http://dev.bitly.com)
8
8
 
9
9
  ## NOTE:
10
10
 
@@ -14,7 +14,7 @@ To move to using the version 3 API, call:
14
14
 
15
15
  Bitly.use_api_version_3
16
16
 
17
- Then, when you call ``Bitly.new(username, api_key)`` you will get a ``Bitly::V3::Client`` instead, which provides the version 3 api calls (``shorten``, ``expand``, ``clicks``, ``validate`` and ``bitly_pro_domain``). See [http://api.bit.ly](http://api.bit.ly) for details.
17
+ Then, when you call ``Bitly.new(username, api_key)`` you will get a ``Bitly::V3::Client`` instead, which provides the version 3 api calls (``shorten``, ``expand``, ``clicks``, ``validate`` and ``bitly_pro_domain``). See [http://dev.bitly.com](http://dev.bitly.com) for details.
18
18
 
19
19
  Eventually, this will become the default version used and finally, the V3 module will disappear, with the version 3 classes replacing the version 2 classes.
20
20
 
data/Rakefile CHANGED
@@ -11,7 +11,7 @@ Echoe.new('bitly', Bitly::VERSION) do |p|
11
11
  p.extra_deps = [
12
12
  ['multi_json', '~> 1.3'],
13
13
  ['httparty', '>= 0.7.6'],
14
- ['oauth2', '>= 0.5.0', '< 0.9']
14
+ ['oauth2', '>= 0.5.0', '< 0.10']
15
15
  ]
16
16
  p.development_dependencies = [
17
17
  ['echoe'],
data/bitly.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "bitly"
5
- s.version = "0.9.0"
5
+ s.version = "0.10.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Phil Nash"]
9
- s.date = "2013-04-28"
9
+ s.date = "2014-02-23"
10
10
  s.description = "Use the bit.ly API to shorten or expand URLs"
11
11
  s.email = "philnash@gmail.com"
12
12
  s.extra_rdoc_files = ["README.md", "lib/bitly.rb", "lib/bitly/client.rb", "lib/bitly/config.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"]
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
25
25
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
26
26
  s.add_runtime_dependency(%q<multi_json>, ["~> 1.3"])
27
27
  s.add_runtime_dependency(%q<httparty>, [">= 0.7.6"])
28
- s.add_runtime_dependency(%q<oauth2>, ["< 0.9", ">= 0.5.0"])
28
+ s.add_runtime_dependency(%q<oauth2>, ["< 0.10", ">= 0.5.0"])
29
29
  s.add_development_dependency(%q<echoe>, [">= 0"])
30
30
  s.add_development_dependency(%q<rake>, [">= 0"])
31
31
  s.add_development_dependency(%q<shoulda>, [">= 0"])
@@ -34,7 +34,7 @@ Gem::Specification.new do |s|
34
34
  else
35
35
  s.add_dependency(%q<multi_json>, ["~> 1.3"])
36
36
  s.add_dependency(%q<httparty>, [">= 0.7.6"])
37
- s.add_dependency(%q<oauth2>, ["< 0.9", ">= 0.5.0"])
37
+ s.add_dependency(%q<oauth2>, ["< 0.10", ">= 0.5.0"])
38
38
  s.add_dependency(%q<echoe>, [">= 0"])
39
39
  s.add_dependency(%q<rake>, [">= 0"])
40
40
  s.add_dependency(%q<shoulda>, [">= 0"])
@@ -44,7 +44,7 @@ Gem::Specification.new do |s|
44
44
  else
45
45
  s.add_dependency(%q<multi_json>, ["~> 1.3"])
46
46
  s.add_dependency(%q<httparty>, [">= 0.7.6"])
47
- s.add_dependency(%q<oauth2>, ["< 0.9", ">= 0.5.0"])
47
+ s.add_dependency(%q<oauth2>, ["< 0.10", ">= 0.5.0"])
48
48
  s.add_dependency(%q<echoe>, [">= 0"])
49
49
  s.add_dependency(%q<rake>, [">= 0"])
50
50
  s.add_dependency(%q<shoulda>, [">= 0"])
data/lib/bitly/client.rb CHANGED
@@ -7,7 +7,7 @@ module Bitly
7
7
  API_URL = 'http://api.bit.ly/'
8
8
  API_VERSION = '2.0.1'
9
9
 
10
- def self.new(login, api_key, timeout=nil)
10
+ def self.new(login, api_key = nil, timeout=nil)
11
11
  if @version == 3
12
12
  Bitly::V3::Client.new(login, api_key, timeout)
13
13
  else
data/lib/bitly/config.rb CHANGED
@@ -11,6 +11,9 @@ module Bitly
11
11
 
12
12
  attr_accessor *OPTION_KEYS
13
13
 
14
+ alias_method :access_token, :login
15
+ alias_method :access_token=, :login=
16
+
14
17
  def configure
15
18
  yield self
16
19
  self
@@ -4,14 +4,29 @@ module Bitly
4
4
  # username and API key and then you will be able to use the client to perform
5
5
  # all the rest of the actions available through the API.
6
6
  class Client
7
+ API_URL_SSL = 'https://api-ssl.bitly.com/v3/'
7
8
  include HTTParty
8
- base_uri 'http://api.bit.ly/v3/'
9
+ base_uri 'http://api.bitly.com/v3/'
9
10
 
10
- # Requires a login and api key. Get yours from your account page at https://bitly.com/a/your_api_key
11
+ # Requires a generic OAuth2 access token or -deprecated- login and api key.
12
+ # http://dev.bitly.com/authentication.html#apikey
13
+ # Generic OAuth2 access token: https://bitly.com/a/oauth_apps
14
+ # ApiKey: Get yours from your account page at https://bitly.com/a/your_api_key
11
15
  # Visit your account at http://bit.ly/a/account
12
- def initialize(login, api_key, timeout=nil)
13
- @default_query_opts = { :login => login, :apiKey => api_key }
14
- self.timeout = timeout
16
+ def initialize(*args)
17
+ args.compact!
18
+ self.timeout = args.last.is_a?(Fixnum) ? args.pop : nil
19
+ if args.count == 1
20
+ # Set generic OAuth2 access token and change base URI (use SSL)
21
+ @default_query_opts = { :access_token => args.first }
22
+ self.class.base_uri API_URL_SSL
23
+ else
24
+ # Deprecated ApiKey authentication
25
+ @default_query_opts = {
26
+ :login => args[0],
27
+ :apiKey => args[1]
28
+ }
29
+ end
15
30
  end
16
31
 
17
32
  # Validates a login and api key
@@ -12,7 +12,7 @@ module Bitly
12
12
  @client ||= ::OAuth2::Client.new(
13
13
  @consumer_token,
14
14
  @consumer_secret,
15
- :site => 'https://api-ssl.bit.ly',
15
+ :site => 'https://api-ssl.bitly.com',
16
16
  :token_url => '/oauth/access_token'
17
17
  )
18
18
  end
@@ -36,4 +36,4 @@ module Bitly
36
36
  end
37
37
  end
38
38
  end
39
- end
39
+ end
data/lib/bitly/v3/url.rb CHANGED
@@ -114,6 +114,10 @@ module Bitly
114
114
  @clicks_by_day
115
115
  end
116
116
 
117
+ def jmp_url
118
+ @short_url.nil? ? nil : @short_url.gsub(/bit\.ly/,'j.mp')
119
+ end
120
+
117
121
  # QR code is automatically created and can be incorporated
118
122
  # into mobile applications.
119
123
  def qrcode_url(opts={})
data/lib/bitly/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Bitly
2
- VERSION = '0.9.0'
2
+ VERSION = '0.10.0'
3
3
  end
@@ -7,6 +7,11 @@ class TestClient < Test::Unit::TestCase
7
7
  assert_equal Bitly::Client, b.class
8
8
  end
9
9
 
10
+ should "create a new bitly client with generic OAuth2 access token" do
11
+ b = Bitly.new(access_token)
12
+ assert_equal Bitly::Client, b.class
13
+ end
14
+
10
15
  should "create a new bitly client and configure with a block" do
11
16
  Bitly.configure do |config|
12
17
  config.api_key = api_key
data/test/test_helper.rb CHANGED
@@ -27,6 +27,9 @@ end
27
27
  def login
28
28
  'test_account'
29
29
  end
30
+ def access_token
31
+ 'test_access_token'
32
+ end
30
33
 
31
34
  class Test::Unit::TestCase
32
35
  def teardown
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bitly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-28 00:00:00.000000000 Z
12
+ date: 2014-02-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
16
- requirement: &70227825351380 !ruby/object:Gem::Requirement
16
+ requirement: &70201536191400 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '1.3'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70227825351380
24
+ version_requirements: *70201536191400
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: httparty
27
- requirement: &70227825350880 !ruby/object:Gem::Requirement
27
+ requirement: &70201536190980 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.7.6
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70227825350880
35
+ version_requirements: *70201536190980
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: oauth2
38
- requirement: &70227825350180 !ruby/object:Gem::Requirement
38
+ requirement: &70201536190560 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,13 +43,13 @@ dependencies:
43
43
  version: 0.5.0
44
44
  - - <
45
45
  - !ruby/object:Gem::Version
46
- version: '0.9'
46
+ version: '0.10'
47
47
  type: :runtime
48
48
  prerelease: false
49
- version_requirements: *70227825350180
49
+ version_requirements: *70201536190560
50
50
  - !ruby/object:Gem::Dependency
51
51
  name: echoe
52
- requirement: &70227825349200 !ruby/object:Gem::Requirement
52
+ requirement: &70201536189920 !ruby/object:Gem::Requirement
53
53
  none: false
54
54
  requirements:
55
55
  - - ! '>='
@@ -57,10 +57,10 @@ dependencies:
57
57
  version: '0'
58
58
  type: :development
59
59
  prerelease: false
60
- version_requirements: *70227825349200
60
+ version_requirements: *70201536189920
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: rake
63
- requirement: &70227825348580 !ruby/object:Gem::Requirement
63
+ requirement: &70201536189520 !ruby/object:Gem::Requirement
64
64
  none: false
65
65
  requirements:
66
66
  - - ! '>='
@@ -68,10 +68,10 @@ dependencies:
68
68
  version: '0'
69
69
  type: :development
70
70
  prerelease: false
71
- version_requirements: *70227825348580
71
+ version_requirements: *70201536189520
72
72
  - !ruby/object:Gem::Dependency
73
73
  name: shoulda
74
- requirement: &70227825347860 !ruby/object:Gem::Requirement
74
+ requirement: &70201536189120 !ruby/object:Gem::Requirement
75
75
  none: false
76
76
  requirements:
77
77
  - - ! '>='
@@ -79,10 +79,10 @@ dependencies:
79
79
  version: '0'
80
80
  type: :development
81
81
  prerelease: false
82
- version_requirements: *70227825347860
82
+ version_requirements: *70201536189120
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: flexmock
85
- requirement: &70227825347240 !ruby/object:Gem::Requirement
85
+ requirement: &70201536188700 !ruby/object:Gem::Requirement
86
86
  none: false
87
87
  requirements:
88
88
  - - ! '>='
@@ -90,10 +90,10 @@ dependencies:
90
90
  version: '0'
91
91
  type: :development
92
92
  prerelease: false
93
- version_requirements: *70227825347240
93
+ version_requirements: *70201536188700
94
94
  - !ruby/object:Gem::Dependency
95
95
  name: fakeweb
96
- requirement: &70227825346600 !ruby/object:Gem::Requirement
96
+ requirement: &70201536188300 !ruby/object:Gem::Requirement
97
97
  none: false
98
98
  requirements:
99
99
  - - ! '>='
@@ -101,7 +101,7 @@ dependencies:
101
101
  version: '0'
102
102
  type: :development
103
103
  prerelease: false
104
- version_requirements: *70227825346600
104
+ version_requirements: *70201536188300
105
105
  description: Use the bit.ly API to shorten or expand URLs
106
106
  email: philnash@gmail.com
107
107
  executables: []