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 +7 -0
- data/README.md +3 -3
- data/Rakefile +1 -1
- data/bitly.gemspec +5 -5
- data/lib/bitly/client.rb +1 -1
- data/lib/bitly/config.rb +3 -0
- data/lib/bitly/v3/client.rb +20 -5
- data/lib/bitly/v3/oauth.rb +2 -2
- data/lib/bitly/v3/url.rb +4 -0
- data/lib/bitly/version.rb +1 -1
- data/test/bitly/test_client.rb +5 -0
- data/test/test_helper.rb +3 -0
- metadata +19 -19
data/History.txt
CHANGED
data/README.md
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
## DESCRIPTION:
|
4
4
|
|
5
|
-
A Ruby API for [http://
|
5
|
+
A Ruby API for [http://bitly.com](http://bitly.com)
|
6
6
|
|
7
|
-
[http://
|
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://
|
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
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.
|
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 = "
|
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.
|
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.
|
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.
|
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
data/lib/bitly/config.rb
CHANGED
data/lib/bitly/v3/client.rb
CHANGED
@@ -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.
|
9
|
+
base_uri 'http://api.bitly.com/v3/'
|
9
10
|
|
10
|
-
# Requires a
|
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(
|
13
|
-
|
14
|
-
self.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
|
data/lib/bitly/v3/oauth.rb
CHANGED
@@ -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.
|
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
data/test/bitly/test_client.rb
CHANGED
@@ -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
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.
|
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:
|
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: &
|
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: *
|
24
|
+
version_requirements: *70201536191400
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: httparty
|
27
|
-
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: *
|
35
|
+
version_requirements: *70201536190980
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: oauth2
|
38
|
-
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.
|
46
|
+
version: '0.10'
|
47
47
|
type: :runtime
|
48
48
|
prerelease: false
|
49
|
-
version_requirements: *
|
49
|
+
version_requirements: *70201536190560
|
50
50
|
- !ruby/object:Gem::Dependency
|
51
51
|
name: echoe
|
52
|
-
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: *
|
60
|
+
version_requirements: *70201536189920
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: rake
|
63
|
-
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: *
|
71
|
+
version_requirements: *70201536189520
|
72
72
|
- !ruby/object:Gem::Dependency
|
73
73
|
name: shoulda
|
74
|
-
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: *
|
82
|
+
version_requirements: *70201536189120
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: flexmock
|
85
|
-
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: *
|
93
|
+
version_requirements: *70201536188700
|
94
94
|
- !ruby/object:Gem::Dependency
|
95
95
|
name: fakeweb
|
96
|
-
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: *
|
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: []
|