bitly 0.10.4 → 1.0.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c137650fcf36f5135ae2283ab1246bd75b3ce505
4
+ data.tar.gz: df43c50f72e8b841f0749c01d890b592d28ced82
5
+ SHA512:
6
+ metadata.gz: daaacffdcf70c390ddb2b39d4ad82102ce6275d33c416619e8ffd46c7f07273f2e70121022420d2290c2bba4d2c006da966e230bd6f43f359495e2bec3639f27
7
+ data.tar.gz: 5c0c02ea1ff855597a65986710ec75864a613eff42135f9e91e28d3843fbd023e53e877ff50833365a92f8d5a5169bc1c173232e1611e02bd00f5f8347dd0966
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2016 Phil Nash
2
+
3
+ ### MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Manifest CHANGED
@@ -1,9 +1,9 @@
1
1
  Gemfile
2
2
  History.txt
3
+ LICENSE.md
3
4
  Manifest
4
5
  README.md
5
6
  Rakefile
6
- bitly.gemspec
7
7
  lib/bitly.rb
8
8
  lib/bitly/client.rb
9
9
  lib/bitly/config.rb
data/README.md CHANGED
@@ -77,7 +77,7 @@ If you want to configure bitly through an initializer (e.g. `config/initializers
77
77
 
78
78
  ```ruby
79
79
  Bitly.use_api_version_3
80
-
80
+
81
81
  Bitly.configure do |config|
82
82
  config.api_version = 3
83
83
  config.access_token = "API_KEY"
@@ -89,28 +89,3 @@ Instead of using `Bitly.new(username, api_key)` to get the client, use `Bitly.cl
89
89
  ```ruby
90
90
  Bitly.client.shorten('http://www.google.com')
91
91
  ```
92
-
93
- ## LICENSE:
94
-
95
- > (The MIT License)
96
- >
97
- > Copyright (c) 2009 Phil Nash
98
- >
99
- > Permission is hereby granted, free of charge, to any person obtaining
100
- > a copy of this software and associated documentation files (the
101
- > 'Software'), to deal in the Software without restriction, including
102
- > without limitation the rights to use, copy, modify, merge, publish,
103
- > distribute, sublicense, and/or sell copies of the Software, and to
104
- > permit persons to whom the Software is furnished to do so, subject to
105
- > the following conditions:
106
- >
107
- > The above copyright notice and this permission notice shall be
108
- > included in all copies or substantial portions of the Software.
109
- >
110
- > THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
111
- > EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
112
- > MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
113
- > IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
114
- > CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
115
- > TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
116
- > SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile CHANGED
@@ -19,6 +19,7 @@ Echoe.new('bitly', Bitly::VERSION) do |p|
19
19
  ['shoulda'],
20
20
  ['flexmock'],
21
21
  ['fakeweb'],
22
- ['activesupport', '~> 3.2']
22
+ ['activesupport', '~> 3.2'],
23
+ ['minitest', '~> 5.8.3']
23
24
  ]
24
25
  end
@@ -1,57 +1,61 @@
1
1
  # -*- encoding: utf-8 -*-
2
+ # stub: bitly 1.0.0 ruby lib
2
3
 
3
4
  Gem::Specification.new do |s|
4
- s.name = "bitly"
5
- s.version = "0.10.4"
5
+ s.name = "bitly".freeze
6
+ s.version = "1.0.0"
6
7
 
7
- s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Phil Nash"]
9
- s.date = "2015-01-09"
10
- s.description = "Use the bit.ly API to shorten or expand URLs"
11
- s.email = "philnash@gmail.com"
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"]
13
- s.files = ["Gemfile", "History.txt", "Manifest", "README.md", "Rakefile", "bitly.gemspec", "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", "test/bitly/test_client.rb", "test/bitly/test_config.rb", "test/bitly/test_url.rb", "test/bitly/test_utils.rb", "test/fixtures/cnn.json", "test/fixtures/cnn_and_google.json", "test/fixtures/expand_cnn.json", "test/fixtures/expand_cnn_and_google.json", "test/fixtures/google_and_cnn_info.json", "test/fixtures/google_info.json", "test/fixtures/google_stats.json", "test/fixtures/shorten_error.json", "test/test_helper.rb"]
14
- s.homepage = "http://github.com/philnash/bitly"
15
- s.rdoc_options = ["--line-numbers", "--title", "Bitly", "--main", "README.md"]
16
- s.require_paths = ["lib"]
17
- s.rubyforge_project = "bitly"
18
- s.rubygems_version = "1.8.23.2"
19
- s.summary = "Use the bit.ly API to shorten or expand URLs"
20
- s.test_files = ["test/bitly/test_client.rb", "test/bitly/test_config.rb", "test/bitly/test_url.rb", "test/bitly/test_utils.rb", "test/test_helper.rb"]
8
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2".freeze) if s.respond_to? :required_rubygems_version=
9
+ s.require_paths = ["lib".freeze]
10
+ s.authors = ["Phil Nash".freeze]
11
+ s.date = "2016-10-21"
12
+ s.description = "Use the bit.ly API to shorten or expand URLs".freeze
13
+ s.email = "philnash@gmail.com".freeze
14
+ s.extra_rdoc_files = ["LICENSE.md".freeze, "README.md".freeze, "lib/bitly.rb".freeze, "lib/bitly/client.rb".freeze, "lib/bitly/config.rb".freeze, "lib/bitly/url.rb".freeze, "lib/bitly/utils.rb".freeze, "lib/bitly/v3.rb".freeze, "lib/bitly/v3/bitly.rb".freeze, "lib/bitly/v3/client.rb".freeze, "lib/bitly/v3/country.rb".freeze, "lib/bitly/v3/day.rb".freeze, "lib/bitly/v3/missing_url.rb".freeze, "lib/bitly/v3/oauth.rb".freeze, "lib/bitly/v3/realtime_link.rb".freeze, "lib/bitly/v3/referrer.rb".freeze, "lib/bitly/v3/url.rb".freeze, "lib/bitly/v3/user.rb".freeze, "lib/bitly/version.rb".freeze]
15
+ s.files = ["Gemfile".freeze, "History.txt".freeze, "LICENSE.md".freeze, "Manifest".freeze, "README.md".freeze, "Rakefile".freeze, "bitly.gemspec".freeze, "lib/bitly.rb".freeze, "lib/bitly/client.rb".freeze, "lib/bitly/config.rb".freeze, "lib/bitly/url.rb".freeze, "lib/bitly/utils.rb".freeze, "lib/bitly/v3.rb".freeze, "lib/bitly/v3/bitly.rb".freeze, "lib/bitly/v3/client.rb".freeze, "lib/bitly/v3/country.rb".freeze, "lib/bitly/v3/day.rb".freeze, "lib/bitly/v3/missing_url.rb".freeze, "lib/bitly/v3/oauth.rb".freeze, "lib/bitly/v3/realtime_link.rb".freeze, "lib/bitly/v3/referrer.rb".freeze, "lib/bitly/v3/url.rb".freeze, "lib/bitly/v3/user.rb".freeze, "lib/bitly/version.rb".freeze, "test/bitly/test_client.rb".freeze, "test/bitly/test_config.rb".freeze, "test/bitly/test_url.rb".freeze, "test/bitly/test_utils.rb".freeze, "test/fixtures/cnn.json".freeze, "test/fixtures/cnn_and_google.json".freeze, "test/fixtures/expand_cnn.json".freeze, "test/fixtures/expand_cnn_and_google.json".freeze, "test/fixtures/google_and_cnn_info.json".freeze, "test/fixtures/google_info.json".freeze, "test/fixtures/google_stats.json".freeze, "test/fixtures/shorten_error.json".freeze, "test/test_helper.rb".freeze]
16
+ s.homepage = "http://github.com/philnash/bitly".freeze
17
+ s.rdoc_options = ["--line-numbers".freeze, "--title".freeze, "Bitly".freeze, "--main".freeze, "README.md".freeze]
18
+ s.rubyforge_project = "bitly".freeze
19
+ s.rubygems_version = "2.6.6".freeze
20
+ s.summary = "Use the bit.ly API to shorten or expand URLs".freeze
21
+ s.test_files = ["test/bitly/test_client.rb".freeze, "test/bitly/test_config.rb".freeze, "test/bitly/test_url.rb".freeze, "test/bitly/test_utils.rb".freeze, "test/test_helper.rb".freeze]
21
22
 
22
23
  if s.respond_to? :specification_version then
23
- s.specification_version = 3
24
+ s.specification_version = 4
24
25
 
25
26
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
26
- s.add_runtime_dependency(%q<multi_json>, ["~> 1.3"])
27
- s.add_runtime_dependency(%q<httparty>, [">= 0.7.6"])
28
- s.add_runtime_dependency(%q<oauth2>, ["< 2.0", ">= 0.5.0"])
29
- s.add_development_dependency(%q<echoe>, [">= 0"])
30
- s.add_development_dependency(%q<rake>, [">= 0"])
31
- s.add_development_dependency(%q<shoulda>, [">= 0"])
32
- s.add_development_dependency(%q<flexmock>, [">= 0"])
33
- s.add_development_dependency(%q<fakeweb>, [">= 0"])
34
- s.add_development_dependency(%q<activesupport>, ["~> 3.2"])
27
+ s.add_runtime_dependency(%q<multi_json>.freeze, ["~> 1.3"])
28
+ s.add_runtime_dependency(%q<httparty>.freeze, [">= 0.7.6"])
29
+ s.add_runtime_dependency(%q<oauth2>.freeze, ["< 2.0", ">= 0.5.0"])
30
+ s.add_development_dependency(%q<echoe>.freeze, [">= 0"])
31
+ s.add_development_dependency(%q<rake>.freeze, [">= 0"])
32
+ s.add_development_dependency(%q<shoulda>.freeze, [">= 0"])
33
+ s.add_development_dependency(%q<flexmock>.freeze, [">= 0"])
34
+ s.add_development_dependency(%q<fakeweb>.freeze, [">= 0"])
35
+ s.add_development_dependency(%q<activesupport>.freeze, ["~> 3.2"])
36
+ s.add_development_dependency(%q<minitest>.freeze, ["~> 5.8.3"])
35
37
  else
36
- s.add_dependency(%q<multi_json>, ["~> 1.3"])
37
- s.add_dependency(%q<httparty>, [">= 0.7.6"])
38
- s.add_dependency(%q<oauth2>, ["< 2.0", ">= 0.5.0"])
39
- s.add_dependency(%q<echoe>, [">= 0"])
40
- s.add_dependency(%q<rake>, [">= 0"])
41
- s.add_dependency(%q<shoulda>, [">= 0"])
42
- s.add_dependency(%q<flexmock>, [">= 0"])
43
- s.add_dependency(%q<fakeweb>, [">= 0"])
44
- s.add_dependency(%q<activesupport>, ["~> 3.2"])
38
+ s.add_dependency(%q<multi_json>.freeze, ["~> 1.3"])
39
+ s.add_dependency(%q<httparty>.freeze, [">= 0.7.6"])
40
+ s.add_dependency(%q<oauth2>.freeze, ["< 2.0", ">= 0.5.0"])
41
+ s.add_dependency(%q<echoe>.freeze, [">= 0"])
42
+ s.add_dependency(%q<rake>.freeze, [">= 0"])
43
+ s.add_dependency(%q<shoulda>.freeze, [">= 0"])
44
+ s.add_dependency(%q<flexmock>.freeze, [">= 0"])
45
+ s.add_dependency(%q<fakeweb>.freeze, [">= 0"])
46
+ s.add_dependency(%q<activesupport>.freeze, ["~> 3.2"])
47
+ s.add_dependency(%q<minitest>.freeze, ["~> 5.8.3"])
45
48
  end
46
49
  else
47
- s.add_dependency(%q<multi_json>, ["~> 1.3"])
48
- s.add_dependency(%q<httparty>, [">= 0.7.6"])
49
- s.add_dependency(%q<oauth2>, ["< 2.0", ">= 0.5.0"])
50
- s.add_dependency(%q<echoe>, [">= 0"])
51
- s.add_dependency(%q<rake>, [">= 0"])
52
- s.add_dependency(%q<shoulda>, [">= 0"])
53
- s.add_dependency(%q<flexmock>, [">= 0"])
54
- s.add_dependency(%q<fakeweb>, [">= 0"])
55
- s.add_dependency(%q<activesupport>, ["~> 3.2"])
50
+ s.add_dependency(%q<multi_json>.freeze, ["~> 1.3"])
51
+ s.add_dependency(%q<httparty>.freeze, [">= 0.7.6"])
52
+ s.add_dependency(%q<oauth2>.freeze, ["< 2.0", ">= 0.5.0"])
53
+ s.add_dependency(%q<echoe>.freeze, [">= 0"])
54
+ s.add_dependency(%q<rake>.freeze, [">= 0"])
55
+ s.add_dependency(%q<shoulda>.freeze, [">= 0"])
56
+ s.add_dependency(%q<flexmock>.freeze, [">= 0"])
57
+ s.add_dependency(%q<fakeweb>.freeze, [">= 0"])
58
+ s.add_dependency(%q<activesupport>.freeze, ["~> 3.2"])
59
+ s.add_dependency(%q<minitest>.freeze, ["~> 5.8.3"])
56
60
  end
57
61
  end
@@ -4,11 +4,11 @@ require 'uri'
4
4
 
5
5
  module Bitly
6
6
  extend Config
7
- API_URL = 'http://api.bit.ly/'
7
+ API_URL = 'https://api-ssl.bitly.com/'
8
8
  API_VERSION = '2.0.1'
9
9
 
10
10
  def self.new(login, api_key = nil, timeout=nil)
11
- if @version == 3
11
+ if api_version == 3
12
12
  Bitly::V3::Client.new(login, api_key, timeout)
13
13
  else
14
14
  Bitly::Client.new(login,api_key)
@@ -16,11 +16,11 @@ module Bitly
16
16
  end
17
17
 
18
18
  def self.use_api_version_3
19
- @version = 3
19
+ api_version = 3
20
20
  end
21
21
 
22
22
  def self.use_api_version_2
23
- @version = 2
23
+ api_version = 2
24
24
  end
25
25
 
26
26
  # get and initialize a client if configured using Config
@@ -9,11 +9,11 @@ module Bitly
9
9
  tr("-", "_").
10
10
  downcase
11
11
  end
12
-
12
+
13
13
  def create_hash_from_url(url)
14
14
  url.gsub(/^.*(bit\.ly|j\.mp)\//,'')
15
15
  end
16
-
16
+
17
17
  def attr_define(k,v)
18
18
  instance_variable_set("@#{k}", v)
19
19
  meta = class << self; self; end
@@ -31,7 +31,7 @@ module Bitly
31
31
  end
32
32
  end
33
33
  end
34
-
34
+
35
35
  def create_url(resource="",args={})
36
36
  args = args.merge({:login => @login, :apiKey => @api_key, :version => API_VERSION})
37
37
  url = URI.join(API_URL,resource)
@@ -40,7 +40,7 @@ module Bitly
40
40
  url.query << "&" + long_urls.map { |long_url| "longUrl=#{CGI.escape(long_url)}" }.join("&") unless long_urls.nil?
41
41
  url
42
42
  end
43
-
43
+
44
44
  def get_result(request)
45
45
  begin
46
46
  json = Net::HTTP.get(request)
@@ -55,6 +55,6 @@ module Bitly
55
55
  raise BitlyError.new(result['errorMessage'],result['errorCode'])
56
56
  end
57
57
  end
58
-
58
+
59
59
  end
60
60
  end
@@ -84,9 +84,8 @@ module Bitly
84
84
  @client ||= Bitly::V3::Client.new(login, api_key)
85
85
  end
86
86
 
87
- # OAuth 2 endpoint that OAuth 2 endpoint that provides a given user's link
88
- # shortening history, in reverse chronological order (most recent to least
89
- # recent).
87
+ # OAuth 2 endpoint that provides a given user's link shortening history,
88
+ # in reverse chronological order (most recent to least recent).
90
89
  def link_history(opts={})
91
90
  opts.merge!(:access_token => @access_token.token)
92
91
  result = self.class.get("/user/link_history", :query => opts)
@@ -133,4 +132,4 @@ module Bitly
133
132
  end
134
133
  end
135
134
  end
136
- end
135
+ end
@@ -1,3 +1,3 @@
1
1
  module Bitly
2
- VERSION = '0.10.4'
2
+ VERSION = '1.0.0'
3
3
  end
@@ -1,6 +1,6 @@
1
1
  require File.join(File.dirname(__FILE__), '..', 'test_helper.rb')
2
2
 
3
- class TestClient < Test::Unit::TestCase
3
+ class TestClient < Minitest::Test
4
4
  context "bitly module" do
5
5
  should "create a new bitly client" do
6
6
  b = Bitly.new(login, api_key)
@@ -43,7 +43,7 @@ class TestClient < Test::Unit::TestCase
43
43
  context "shortening" do
44
44
  context "a single link" do
45
45
  setup do
46
- stub_get(/^http:\/\/api.bit.ly\/shorten\?.*longUrl=.*cnn.com.*$/,"cnn.json")
46
+ stub_get(/^https:\/\/api-ssl\.bitly\.com\/shorten\?.*longUrl=.*cnn.com.*$/,"cnn.json")
47
47
  @url = @bitly.shorten('http://cnn.com')
48
48
  end
49
49
  should "return a Bitly::Url" do
@@ -62,7 +62,7 @@ class TestClient < Test::Unit::TestCase
62
62
  end
63
63
  context "multiple links" do
64
64
  setup do
65
- stub_get(/^http:\/\/api.bit.ly\/shorten\?.*longUrl=.*longUrl=.*$/,"cnn_and_google.json")
65
+ stub_get(/^https:\/\/api-ssl\.bitly\.com\/shorten\?.*longUrl=.*longUrl=.*$/,"cnn_and_google.json")
66
66
  @urls = @bitly.shorten(['http://cnn.com', 'http://google.com'])
67
67
  end
68
68
  should "return an array of Bitly::Urls" do
@@ -80,7 +80,7 @@ class TestClient < Test::Unit::TestCase
80
80
  end
81
81
  context "no links" do
82
82
  should "raise an ArgumentError" do
83
- assert_raise ArgumentError do
83
+ assert_raises ArgumentError do
84
84
  @bitly.shorten
85
85
  end
86
86
  end
@@ -89,7 +89,7 @@ class TestClient < Test::Unit::TestCase
89
89
  context "expanding" do
90
90
  context "a hash" do
91
91
  setup do
92
- stub_get(/^http:\/\/api.bit.ly\/expand\?.*hash=31IqMl.*$/,"expand_cnn.json")
92
+ stub_get(/^https:\/\/api-ssl\.bitly\.com\/expand\?.*hash=31IqMl.*$/,"expand_cnn.json")
93
93
  @url = @bitly.expand("31IqMl")
94
94
  end
95
95
  should "return a Bitly::Url" do
@@ -107,7 +107,7 @@ class TestClient < Test::Unit::TestCase
107
107
  end
108
108
  context "a short bitly url" do
109
109
  setup do
110
- stub_get(/^http:\/\/api.bit.ly\/expand\?.*hash=31IqMl.*$/,"expand_cnn.json")
110
+ stub_get(/^https:\/\/api-ssl\.bitly\.com\/expand\?.*hash=31IqMl.*$/,"expand_cnn.json")
111
111
  @url = @bitly.expand("http://bit.ly/31IqMl")
112
112
  end
113
113
  should "return a Bitly::Url" do
@@ -128,7 +128,7 @@ class TestClient < Test::Unit::TestCase
128
128
  end
129
129
  context "a short jmp url" do
130
130
  setup do
131
- stub_get(/^http:\/\/api.bit.ly\/expand\?.*hash=31IqMl.*$/,"expand_cnn.json")
131
+ stub_get(/^https:\/\/api-ssl\.bitly\.com\/expand\?.*hash=31IqMl.*$/,"expand_cnn.json")
132
132
  @url = @bitly.expand("http://j.mp/31IqMl")
133
133
  end
134
134
  should "return a Bitly::Url" do
@@ -149,7 +149,7 @@ class TestClient < Test::Unit::TestCase
149
149
  end
150
150
  context "multiple hashes" do
151
151
  setup do
152
- stub_get(/^http:\/\/api.bit.ly\/expand\?.*hash=15DlK.*3j4ir4.*$/,"expand_cnn_and_google.json")
152
+ stub_get(/^https:\/\/api-ssl\.bitly\.com\/expand\?.*hash=15DlK.*3j4ir4.*$/,"expand_cnn_and_google.json")
153
153
  @urls = @bitly.expand(["15DlK","3j4ir4"])
154
154
  end
155
155
  should "return an array of Bitly::Urls" do
@@ -170,70 +170,70 @@ class TestClient < Test::Unit::TestCase
170
170
  context "to get info on" do
171
171
  context "a single link" do
172
172
  setup do
173
- stub_get(/^http:\/\/api.bit.ly\/info\?.*hash=3j4ir4.*$/,"google_info.json")
173
+ stub_get(/^https:\/\/api-ssl\.bitly\.com\/info\?.*hash=3j4ir4.*$/,"google_info.json")
174
174
  @url = @bitly.info('http://bit.ly/3j4ir4')
175
175
  end
176
176
  should "return a Bitly::Url" do
177
177
  assert_kind_of Bitly::Url, @url
178
178
  end
179
179
  should "return an info object with the url" do
180
- assert_not_nil @url.info
180
+ assert !@url.info.nil?
181
181
  end
182
182
  end
183
183
  context "a single hash" do
184
184
  setup do
185
- stub_get(/^http:\/\/api.bit.ly\/info\?.*hash=3j4ir4.*$/,"google_info.json")
185
+ stub_get(/^https:\/\/api-ssl\.bitly\.com\/info\?.*hash=3j4ir4.*$/,"google_info.json")
186
186
  @url = @bitly.info('3j4ir4')
187
187
  end
188
188
  should "return a Bitly::Url" do
189
189
  assert_kind_of Bitly::Url, @url
190
190
  end
191
191
  should "return an info object with the url" do
192
- assert_not_nil @url.info
192
+ assert !@url.info.nil?
193
193
  end
194
194
  end
195
195
  context "a list of hashes" do
196
196
  setup do
197
- stub_get(/^http:\/\/api.bit.ly\/info\?.*hash=3j4ir4.*31IqMl.*$/,"google_and_cnn_info.json")
197
+ stub_get(/^https:\/\/api-ssl\.bitly\.com\/info\?.*hash=3j4ir4.*31IqMl.*$/,"google_and_cnn_info.json")
198
198
  @urls = @bitly.info(['3j4ir4','31IqMl'])
199
199
  end
200
200
  should "return a Bitly::Url" do
201
201
  assert_kind_of Array, @urls
202
202
  end
203
203
  should "return an info object with the url" do
204
- assert_not_nil @urls[0].info
205
- assert_not_nil @urls[1].info
204
+ assert !@urls[0].info.nil?
205
+ assert !@urls[1].info.nil?
206
206
  end
207
207
  end
208
208
  end
209
209
  context "to get stats on" do
210
210
  context "a single link" do
211
211
  setup do
212
- stub_get(/^http:\/\/api.bit.ly\/stats\?.*hash=3j4ir4.*$/,"google_stats.json")
212
+ stub_get(/^https:\/\/api-ssl\.bitly\.com\/stats\?.*hash=3j4ir4.*$/,"google_stats.json")
213
213
  @url = @bitly.stats('http://bit.ly/3j4ir4')
214
214
  end
215
215
  should "return a Bitly::Url" do
216
216
  assert_kind_of Bitly::Url, @url
217
217
  end
218
218
  should "return an stats object" do
219
- assert_not_nil @url.stats
219
+ assert !@url.stats.nil?
220
220
  end
221
221
  end
222
222
  context "a single hash" do
223
223
  setup do
224
- stub_get(/^http:\/\/api.bit.ly\/stats\?.*hash=3j4ir4.*$/,"google_stats.json")
224
+ stub_get(/^https:\/\/api-ssl\.bitly\.com\/stats\?.*hash=3j4ir4.*$/,"google_stats.json")
225
225
  @url = @bitly.stats('3j4ir4')
226
226
  end
227
227
  should "return a Bitly::Url" do
228
228
  assert_kind_of Bitly::Url, @url
229
229
  end
230
230
  should "return an stats object" do
231
- assert_not_nil @url.stats
231
+ assert !@url.stats.nil?
232
232
  end
233
233
  end
234
234
  context "a list of hashes" do
235
235
  should "return an argument error" do
236
- assert_raise ArgumentError do
236
+ assert_raises ArgumentError do
237
237
  @bitly.stats(['3j4ir4','31IqMl'])
238
238
  end
239
239
  end
@@ -1,6 +1,6 @@
1
1
  require File.join(File.dirname(__FILE__), '..', 'test_helper.rb')
2
2
 
3
- class TestConfig < Test::Unit::TestCase
3
+ class TestConfig < Minitest::Test
4
4
  context "bitly module" do
5
5
  should "create a new bitly v3 client through initializer" do
6
6
  # configure
@@ -1,22 +1,16 @@
1
1
  require File.join(File.dirname(__FILE__), '..', 'test_helper.rb')
2
2
 
3
- class TestUrl < Test::Unit::TestCase
3
+ class TestUrl < Minitest::Test
4
4
  context "a new Bitly::Url" do
5
5
  should "require a login and api_key" do
6
- assert_raise ArgumentError do Bitly::Url.new end
7
- assert_raise ArgumentError do Bitly::Url.new(login) end
8
- assert_raise ArgumentError do Bitly::Url.new(nil, api_key) end
9
- assert_nothing_raised do
10
- Bitly::Url.new(login, api_key)
11
- Bitly::Url.new(login, api_key, :hash => '3j4ir4')
12
- Bitly::Url.new(login, api_key, :short_url => 'http://bit.ly/3j4ir4')
13
- Bitly::Url.new(login, api_key, :long_url => 'http://google.com/')
14
- end
6
+ assert_raises ArgumentError do Bitly::Url.new end
7
+ assert_raises ArgumentError do Bitly::Url.new(login) end
8
+ assert_raises ArgumentError do Bitly::Url.new(nil, api_key) end
15
9
  end
16
10
  context "shortening" do
17
11
  context "with a long url" do
18
12
  setup do
19
- stub_get(/^http:\/\/api.bit.ly\/shorten\?.*longUrl=.*cnn.com.*$/,"cnn.json")
13
+ stub_get(/^https:\/\/api-ssl\.bitly\.com\/shorten\?.*longUrl=.*cnn.com.*$/,"cnn.json")
20
14
  @url = Bitly::Url.new(login, api_key, :long_url => 'http://cnn.com/')
21
15
  end
22
16
  should "return a short url" do
@@ -33,7 +27,7 @@ class TestUrl < Test::Unit::TestCase
33
27
  @url = Bitly::Url.new(login, api_key)
34
28
  end
35
29
  should "raise an error" do
36
- assert_raise ArgumentError do
30
+ assert_raises ArgumentError do
37
31
  @url.shorten
38
32
  end
39
33
  end
@@ -51,7 +45,7 @@ class TestUrl < Test::Unit::TestCase
51
45
  context "expanding" do
52
46
  context "with a hash" do
53
47
  setup do
54
- stub_get(/^http:\/\/api.bit.ly\/expand\?.*hash=31IqMl.*$/,"expand_cnn.json")
48
+ stub_get(/^https:\/\/api-ssl\.bitly\.com\/expand\?.*hash=31IqMl.*$/,"expand_cnn.json")
55
49
  @url = Bitly::Url.new(login, api_key, :hash => '31IqMl')
56
50
  end
57
51
  should "return an expanded url" do
@@ -60,7 +54,7 @@ class TestUrl < Test::Unit::TestCase
60
54
  end
61
55
  context "with a short url" do
62
56
  setup do
63
- stub_get(/^http:\/\/api.bit.ly\/expand\?.*hash=31IqMl.*$/,"expand_cnn.json")
57
+ stub_get(/^https:\/\/api-ssl\.bitly\.com\/expand\?.*hash=31IqMl.*$/,"expand_cnn.json")
64
58
  @url = Bitly::Url.new(login, api_key, :short_url => 'http://bit.ly/31IqMl')
65
59
  end
66
60
  should "return an expanded url" do
@@ -72,7 +66,7 @@ class TestUrl < Test::Unit::TestCase
72
66
  @url = Bitly::Url.new(login, api_key)
73
67
  end
74
68
  should "raise an error" do
75
- assert_raise ArgumentError do
69
+ assert_raises ArgumentError do
76
70
  @url.expand
77
71
  end
78
72
  end
@@ -90,7 +84,7 @@ class TestUrl < Test::Unit::TestCase
90
84
  context "info" do
91
85
  context "with a hash" do
92
86
  setup do
93
- stub_get(/^http:\/\/api.bit.ly\/info\?.*hash=3j4ir4.*$/,"google_info.json")
87
+ stub_get(/^https:\/\/api-ssl\.bitly\.com\/info\?.*hash=3j4ir4.*$/,"google_info.json")
94
88
  @url = Bitly::Url.new(login, api_key, :hash => '3j4ir4')
95
89
  end
96
90
  should "return info" do
@@ -99,7 +93,7 @@ class TestUrl < Test::Unit::TestCase
99
93
  end
100
94
  context "with a short url" do
101
95
  setup do
102
- stub_get(/^http:\/\/api.bit.ly\/info\?.*hash=3j4ir4.*$/,"google_info.json")
96
+ stub_get(/^https:\/\/api-ssl\.bitly\.com\/info\?.*hash=3j4ir4.*$/,"google_info.json")
103
97
  @url = Bitly::Url.new(login, api_key, :short_url => 'http://bit.ly/3j4ir4')
104
98
  end
105
99
  should "return an expanded url" do
@@ -111,14 +105,14 @@ class TestUrl < Test::Unit::TestCase
111
105
  @url = Bitly::Url.new(login, api_key, :long_url => 'http://google.com')
112
106
  end
113
107
  should "raise an error" do
114
- assert_raise ArgumentError do
108
+ assert_raises ArgumentError do
115
109
  @url.info
116
110
  end
117
111
  end
118
112
  end
119
113
  context "with info already" do
120
114
  setup do
121
- stub_get(/^http:\/\/api.bit.ly\/info\?.*hash=3j4ir4.*$/,"google_info.json")
115
+ stub_get(/^https:\/\/api-ssl\.bitly\.com\/info\?.*hash=3j4ir4.*$/,"google_info.json")
122
116
  @url = Bitly::Url.new(login, api_key, :short_url => 'http://bit.ly/3j4ir4')
123
117
  @url.info
124
118
  end
@@ -131,7 +125,7 @@ class TestUrl < Test::Unit::TestCase
131
125
  context "stats" do
132
126
  context "with a hash" do
133
127
  setup do
134
- stub_get(/^http:\/\/api.bit.ly\/stats\?.*hash=3j4ir4.*$/,"google_stats.json")
128
+ stub_get(/^https:\/\/api-ssl\.bitly\.com\/stats\?.*hash=3j4ir4.*$/,"google_stats.json")
135
129
  @url = Bitly::Url.new(login, api_key, :hash => '3j4ir4')
136
130
  end
137
131
  should "return info" do
@@ -140,7 +134,7 @@ class TestUrl < Test::Unit::TestCase
140
134
  end
141
135
  context "with a short url" do
142
136
  setup do
143
- stub_get(/^http:\/\/api.bit.ly\/stats\?.*hash=3j4ir4.*$/,"google_stats.json")
137
+ stub_get(/^https:\/\/api-ssl\.bitly\.com\/stats\?.*hash=3j4ir4.*$/,"google_stats.json")
144
138
  @url = Bitly::Url.new(login, api_key, :short_url => 'http://bit.ly/3j4ir4')
145
139
  end
146
140
  should "return an expanded url" do
@@ -152,14 +146,14 @@ class TestUrl < Test::Unit::TestCase
152
146
  @url = Bitly::Url.new(login, api_key, :long_url => 'http://google.com')
153
147
  end
154
148
  should "raise an error" do
155
- assert_raise ArgumentError do
149
+ assert_raises ArgumentError do
156
150
  @url.stats
157
151
  end
158
152
  end
159
153
  end
160
154
  context "with info already" do
161
155
  setup do
162
- stub_get(/^http:\/\/api.bit.ly\/stats\?.*hash=3j4ir4.*$/,"google_stats.json")
156
+ stub_get(/^https:\/\/api-ssl\.bitly\.com\/stats\?.*hash=3j4ir4.*$/,"google_stats.json")
163
157
  @url = Bitly::Url.new(login, api_key, :short_url => 'http://bit.ly/3j4ir4')
164
158
  @url.stats
165
159
  end
@@ -170,4 +164,4 @@ class TestUrl < Test::Unit::TestCase
170
164
  end
171
165
  end
172
166
  end
173
- end
167
+ end
@@ -1,9 +1,9 @@
1
1
  require File.join(File.dirname(__FILE__), '..', 'test_helper.rb')
2
2
 
3
- class TestUtils < Test::Unit::TestCase
3
+ class TestUtils < Minitest::Test
4
4
  include Bitly::Utils
5
5
  API_VERSION = '2.0.1'
6
-
6
+
7
7
  context "text utils" do
8
8
  should "underscore a word" do
9
9
  assert_equal "hello_world", underscore("HelloWorld")
@@ -15,24 +15,24 @@ class TestUtils < Test::Unit::TestCase
15
15
  assert_equal "hello", create_hash_from_url("http://j.mp/hello")
16
16
  end
17
17
  end
18
-
18
+
19
19
  context "class utils" do
20
20
  should "turn a key value pair into an instance variable" do
21
21
  attr_define('hello','goodbye')
22
22
  assert_equal @hello, "goodbye"
23
23
  end
24
-
24
+
25
25
  should "turn a hash into instance variables" do
26
26
  instance_variablise({'hello' => 'goodbye'}, ['hello'])
27
27
  assert_equal @hello, "goodbye"
28
28
  end
29
-
29
+
30
30
  should "not turn nonspecified variables into instance variables" do
31
31
  instance_variablise({'hello' => 'goodbye'}, [])
32
32
  assert_nil @hello
33
33
  end
34
34
  end
35
-
35
+
36
36
  context "creating a url" do
37
37
  setup do
38
38
  @api_key = api_key
@@ -40,7 +40,7 @@ class TestUtils < Test::Unit::TestCase
40
40
  end
41
41
  should "contain all the basic information" do
42
42
  url = create_url.to_s
43
- assert url.include?('http://api.bit.ly/')
43
+ assert url.include?('https://api-ssl.bitly.com/')
44
44
  assert url.include?("version=#{API_VERSION}")
45
45
  assert url.include?("apiKey=#{api_key}")
46
46
  assert url.include?("login=#{login}")
@@ -54,7 +54,7 @@ class TestUtils < Test::Unit::TestCase
54
54
  assert url.include?("longUrl=#{CGI.escape('http://google.com')}")
55
55
  end
56
56
  end
57
-
57
+
58
58
  context "fetching a url" do
59
59
  context "successfully" do
60
60
  setup do
@@ -70,10 +70,10 @@ class TestUtils < Test::Unit::TestCase
70
70
  stub_get("http://example.com", 'shorten_error.json')
71
71
  end
72
72
  should "raise BitlyError" do
73
- assert_raise BitlyError do
74
- result = get_result(URI.join("http://example.com"))
73
+ assert_raises BitlyError do
74
+ get_result(URI.join("http://example.com"))
75
75
  end
76
76
  end
77
77
  end
78
78
  end
79
- end
79
+ end
@@ -1,7 +1,7 @@
1
- require 'test/unit'
1
+ require 'minitest/autorun'
2
2
  require 'rubygems'
3
3
  require 'shoulda'
4
- require 'flexmock/test_unit'
4
+ require 'flexmock/minitest'
5
5
  require 'fakeweb'
6
6
 
7
7
  require File.join(File.dirname(__FILE__), '..', 'lib', 'bitly')
@@ -31,7 +31,7 @@ def access_token
31
31
  'test_access_token'
32
32
  end
33
33
 
34
- class Test::Unit::TestCase
34
+ class Minitest::Test
35
35
  def teardown
36
36
  FakeWeb.clean_registry
37
37
  end
metadata CHANGED
@@ -1,171 +1,167 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bitly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.4
5
- prerelease:
4
+ version: 1.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Phil Nash
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2015-01-09 00:00:00.000000000 Z
11
+ date: 2016-10-21 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: multi_json
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: '1.3'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: '1.3'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: httparty
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: 0.7.6
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: 0.7.6
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: oauth2
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: 0.5.0
54
- - - <
48
+ - - "<"
55
49
  - !ruby/object:Gem::Version
56
50
  version: '2.0'
57
51
  type: :runtime
58
52
  prerelease: false
59
53
  version_requirements: !ruby/object:Gem::Requirement
60
- none: false
61
54
  requirements:
62
- - - ! '>='
55
+ - - ">="
63
56
  - !ruby/object:Gem::Version
64
57
  version: 0.5.0
65
- - - <
58
+ - - "<"
66
59
  - !ruby/object:Gem::Version
67
60
  version: '2.0'
68
61
  - !ruby/object:Gem::Dependency
69
62
  name: echoe
70
63
  requirement: !ruby/object:Gem::Requirement
71
- none: false
72
64
  requirements:
73
- - - ! '>='
65
+ - - ">="
74
66
  - !ruby/object:Gem::Version
75
67
  version: '0'
76
68
  type: :development
77
69
  prerelease: false
78
70
  version_requirements: !ruby/object:Gem::Requirement
79
- none: false
80
71
  requirements:
81
- - - ! '>='
72
+ - - ">="
82
73
  - !ruby/object:Gem::Version
83
74
  version: '0'
84
75
  - !ruby/object:Gem::Dependency
85
76
  name: rake
86
77
  requirement: !ruby/object:Gem::Requirement
87
- none: false
88
78
  requirements:
89
- - - ! '>='
79
+ - - ">="
90
80
  - !ruby/object:Gem::Version
91
81
  version: '0'
92
82
  type: :development
93
83
  prerelease: false
94
84
  version_requirements: !ruby/object:Gem::Requirement
95
- none: false
96
85
  requirements:
97
- - - ! '>='
86
+ - - ">="
98
87
  - !ruby/object:Gem::Version
99
88
  version: '0'
100
89
  - !ruby/object:Gem::Dependency
101
90
  name: shoulda
102
91
  requirement: !ruby/object:Gem::Requirement
103
- none: false
104
92
  requirements:
105
- - - ! '>='
93
+ - - ">="
106
94
  - !ruby/object:Gem::Version
107
95
  version: '0'
108
96
  type: :development
109
97
  prerelease: false
110
98
  version_requirements: !ruby/object:Gem::Requirement
111
- none: false
112
99
  requirements:
113
- - - ! '>='
100
+ - - ">="
114
101
  - !ruby/object:Gem::Version
115
102
  version: '0'
116
103
  - !ruby/object:Gem::Dependency
117
104
  name: flexmock
118
105
  requirement: !ruby/object:Gem::Requirement
119
- none: false
120
106
  requirements:
121
- - - ! '>='
107
+ - - ">="
122
108
  - !ruby/object:Gem::Version
123
109
  version: '0'
124
110
  type: :development
125
111
  prerelease: false
126
112
  version_requirements: !ruby/object:Gem::Requirement
127
- none: false
128
113
  requirements:
129
- - - ! '>='
114
+ - - ">="
130
115
  - !ruby/object:Gem::Version
131
116
  version: '0'
132
117
  - !ruby/object:Gem::Dependency
133
118
  name: fakeweb
134
119
  requirement: !ruby/object:Gem::Requirement
135
- none: false
136
120
  requirements:
137
- - - ! '>='
121
+ - - ">="
138
122
  - !ruby/object:Gem::Version
139
123
  version: '0'
140
124
  type: :development
141
125
  prerelease: false
142
126
  version_requirements: !ruby/object:Gem::Requirement
143
- none: false
144
127
  requirements:
145
- - - ! '>='
128
+ - - ">="
146
129
  - !ruby/object:Gem::Version
147
130
  version: '0'
148
131
  - !ruby/object:Gem::Dependency
149
132
  name: activesupport
150
133
  requirement: !ruby/object:Gem::Requirement
151
- none: false
152
134
  requirements:
153
- - - ~>
135
+ - - "~>"
154
136
  - !ruby/object:Gem::Version
155
137
  version: '3.2'
156
138
  type: :development
157
139
  prerelease: false
158
140
  version_requirements: !ruby/object:Gem::Requirement
159
- none: false
160
141
  requirements:
161
- - - ~>
142
+ - - "~>"
162
143
  - !ruby/object:Gem::Version
163
144
  version: '3.2'
145
+ - !ruby/object:Gem::Dependency
146
+ name: minitest
147
+ requirement: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - "~>"
150
+ - !ruby/object:Gem::Version
151
+ version: 5.8.3
152
+ type: :development
153
+ prerelease: false
154
+ version_requirements: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - "~>"
157
+ - !ruby/object:Gem::Version
158
+ version: 5.8.3
164
159
  description: Use the bit.ly API to shorten or expand URLs
165
160
  email: philnash@gmail.com
166
161
  executables: []
167
162
  extensions: []
168
163
  extra_rdoc_files:
164
+ - LICENSE.md
169
165
  - README.md
170
166
  - lib/bitly.rb
171
167
  - lib/bitly/client.rb
@@ -187,6 +183,7 @@ extra_rdoc_files:
187
183
  files:
188
184
  - Gemfile
189
185
  - History.txt
186
+ - LICENSE.md
190
187
  - Manifest
191
188
  - README.md
192
189
  - Rakefile
@@ -223,32 +220,31 @@ files:
223
220
  - test/test_helper.rb
224
221
  homepage: http://github.com/philnash/bitly
225
222
  licenses: []
223
+ metadata: {}
226
224
  post_install_message:
227
225
  rdoc_options:
228
- - --line-numbers
229
- - --title
226
+ - "--line-numbers"
227
+ - "--title"
230
228
  - Bitly
231
- - --main
229
+ - "--main"
232
230
  - README.md
233
231
  require_paths:
234
232
  - lib
235
233
  required_ruby_version: !ruby/object:Gem::Requirement
236
- none: false
237
234
  requirements:
238
- - - ! '>='
235
+ - - ">="
239
236
  - !ruby/object:Gem::Version
240
237
  version: '0'
241
238
  required_rubygems_version: !ruby/object:Gem::Requirement
242
- none: false
243
239
  requirements:
244
- - - ! '>='
240
+ - - ">="
245
241
  - !ruby/object:Gem::Version
246
242
  version: '1.2'
247
243
  requirements: []
248
244
  rubyforge_project: bitly
249
- rubygems_version: 1.8.23.2
245
+ rubygems_version: 2.6.6
250
246
  signing_key:
251
- specification_version: 3
247
+ specification_version: 4
252
248
  summary: Use the bit.ly API to shorten or expand URLs
253
249
  test_files:
254
250
  - test/bitly/test_client.rb