bitly 1.1.1 → 1.1.2
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.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/Rakefile +1 -1
- data/lib/bitly/client.rb +1 -1
- data/lib/bitly/config.rb +1 -1
- data/lib/bitly/v3/client.rb +15 -15
- data/lib/bitly/v3/user.rb +1 -2
- data/lib/bitly/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a8801e0af73bf65ac762477c11eab29bf2fb3fe
|
4
|
+
data.tar.gz: 654ce50db6081aa03e871ebfc3cfb7db1c529d2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eeba81429fdfc4d65107890ae8bb0f6c5c17b924256bfb19d9640ed08aa38fd06ad1d9e4ea42a0a9e29c51b10a2c8b166232fe375767168a974ecbc29b1d2176
|
7
|
+
data.tar.gz: d3b5f93048e1d511a7449a7c647c9d1ed44d9e14e54cd62fcd36f6b7cd739c66414a0ff61b5a42a1602981cbeeb1d6ce6d1e2be82296a2e6e05ba61307455ef4
|
data/.travis.yml
CHANGED
data/Rakefile
CHANGED
data/lib/bitly/client.rb
CHANGED
@@ -36,7 +36,7 @@ module Bitly
|
|
36
36
|
class Client
|
37
37
|
|
38
38
|
include Bitly::Utils
|
39
|
-
attr_accessor
|
39
|
+
attr_accessor(*Config::OPTION_KEYS)
|
40
40
|
|
41
41
|
def initialize(login,api_key)
|
42
42
|
warn "[DEPRECATION] The bit.ly version 2 API has been superseded by version 3 and will be removed. See the README for details"
|
data/lib/bitly/config.rb
CHANGED
data/lib/bitly/v3/client.rb
CHANGED
@@ -79,22 +79,22 @@ module Bitly
|
|
79
79
|
# Returns the results in the order they were entered
|
80
80
|
def lookup(input)
|
81
81
|
input = arrayize(input)
|
82
|
-
query = input.inject([]) { |
|
82
|
+
query = input.inject([]) { |q, i| q << "url=#{CGI.escape(i)}" }
|
83
83
|
query = "/lookup?" + query.join('&')
|
84
84
|
response = get(query)
|
85
|
-
results = response['data']['lookup'].inject([]) do |
|
85
|
+
results = response['data']['lookup'].inject([]) do |rs, url|
|
86
86
|
url['long_url'] = url['url']
|
87
87
|
url['url'] = nil
|
88
88
|
if url['error'].nil?
|
89
89
|
# builds the results array in the same order as the input
|
90
|
-
|
90
|
+
rs[input.index(url['long_url'])] = Bitly::V3::Url.new(self, url)
|
91
91
|
# remove the key from the original array, in case the same hash/url was entered twice
|
92
92
|
input[input.index(url['long_url'])] = nil
|
93
93
|
else
|
94
|
-
|
94
|
+
rs[input.index(url['long_url'])] = Bitly::V3::MissingUrl.new(url)
|
95
95
|
input[input.index(url['long_url'])] = nil
|
96
96
|
end
|
97
|
-
|
97
|
+
rs
|
98
98
|
end
|
99
99
|
return results.length > 1 ? results : results[0]
|
100
100
|
end
|
@@ -156,7 +156,7 @@ module Bitly
|
|
156
156
|
end
|
157
157
|
|
158
158
|
def is_a_short_url?(input)
|
159
|
-
input.match(/^
|
159
|
+
input.match(/^https?:\/\//)
|
160
160
|
end
|
161
161
|
|
162
162
|
def get_single_method(method, input)
|
@@ -173,30 +173,30 @@ module Bitly
|
|
173
173
|
|
174
174
|
def get_method(method, input, opts={})
|
175
175
|
input = arrayize(input)
|
176
|
-
query = input.inject([]) do |
|
176
|
+
query = input.inject([]) do |q, i|
|
177
177
|
if is_a_short_url?(i)
|
178
|
-
|
178
|
+
q << "shortUrl=#{CGI.escape(i)}"
|
179
179
|
else
|
180
|
-
|
180
|
+
q << "hash=#{CGI.escape(i)}"
|
181
181
|
end
|
182
182
|
end
|
183
|
-
query = opts.inject(query) do |
|
184
|
-
|
183
|
+
query = opts.inject(query) do |q, (k,v)|
|
184
|
+
q<< "#{k}=#{v}"
|
185
185
|
end
|
186
186
|
query = "/#{method}?" + query.join('&')
|
187
187
|
response = get(query)
|
188
|
-
results = response['data'][method.to_s].inject([]) do |
|
188
|
+
results = response['data'][method.to_s].inject([]) do |rs, url|
|
189
189
|
result_index = input.index(url['short_url'] || url['hash']) || input.index(url['global_hash'])
|
190
190
|
if url['error'].nil?
|
191
191
|
# builds the results array in the same order as the input
|
192
|
-
|
192
|
+
rs[result_index] = Bitly::V3::Url.new(self, url)
|
193
193
|
# remove the key from the original array, in case the same hash/url was entered twice
|
194
194
|
input[result_index] = nil
|
195
195
|
else
|
196
|
-
|
196
|
+
rs[result_index] = Bitly::V3::MissingUrl.new(url)
|
197
197
|
input[result_index] = nil
|
198
198
|
end
|
199
|
-
|
199
|
+
rs
|
200
200
|
end
|
201
201
|
return results.length > 1 ? results : results[0]
|
202
202
|
end
|
data/lib/bitly/v3/user.rb
CHANGED
@@ -107,12 +107,11 @@ module Bitly
|
|
107
107
|
opts.merge!(:access_token => @access_token.token)
|
108
108
|
result = self.class.get("/user/#{method.to_s}", :query => opts)
|
109
109
|
if result['status_code'] == 200
|
110
|
-
|
110
|
+
result['data'][method.to_s].map do |rs|
|
111
111
|
rs.inject([]) do |results, obj|
|
112
112
|
results << klass.new(obj)
|
113
113
|
end
|
114
114
|
end
|
115
|
-
return results
|
116
115
|
else
|
117
116
|
raise BitlyError.new(result['status_txt'], result['status_code'])
|
118
117
|
end
|
data/lib/bitly/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bitly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Phil Nash
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|