google-short-links 0.0.1 → 0.1.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/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +9 -0
- data/VERSION +1 -1
- data/google-short-links.gemspec +16 -2
- data/lib/google_short_links.rb +2 -0
- data/lib/google_short_links/client.rb +89 -0
- data/lib/google_short_links/parser.rb +10 -0
- data/spec/google_short_links/client_spec.rb +287 -0
- data/spec/google_short_links/parser_spec.rb +27 -0
- data/spec/spec_helper.rb +2 -0
- metadata +49 -11
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -3,11 +3,16 @@ GEM
|
|
3
3
|
specs:
|
4
4
|
diff-lcs (1.1.3)
|
5
5
|
git (1.2.5)
|
6
|
+
httparty (0.8.1)
|
7
|
+
multi_json
|
8
|
+
multi_xml
|
6
9
|
jeweler (1.6.4)
|
7
10
|
bundler (~> 1.0)
|
8
11
|
git (>= 1.2.5)
|
9
12
|
rake
|
10
13
|
json (1.6.1)
|
14
|
+
multi_json (1.0.3)
|
15
|
+
multi_xml (0.4.1)
|
11
16
|
rake (0.9.2.2)
|
12
17
|
rcov (0.9.11)
|
13
18
|
rdoc (3.11)
|
@@ -20,12 +25,16 @@ GEM
|
|
20
25
|
rspec-expectations (2.7.0)
|
21
26
|
diff-lcs (~> 1.1.2)
|
22
27
|
rspec-mocks (2.7.0)
|
28
|
+
timecop (0.3.5)
|
23
29
|
|
24
30
|
PLATFORMS
|
25
31
|
ruby
|
26
32
|
|
27
33
|
DEPENDENCIES
|
34
|
+
httparty
|
28
35
|
jeweler
|
36
|
+
multi_json
|
29
37
|
rcov
|
30
38
|
rdoc
|
31
39
|
rspec
|
40
|
+
timecop
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
data/google-short-links.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{google-short-links}
|
8
|
-
s.version = "0.0
|
8
|
+
s.version = "0.1.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Benjamin Manns"]
|
12
|
-
s.date = %q{2011-11-
|
12
|
+
s.date = %q{2011-11-18}
|
13
13
|
s.description = %q{Ruby wrapper for Google Short Links.}
|
14
14
|
s.email = %q{benmanns@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -20,6 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
".document",
|
21
21
|
".rspec",
|
22
22
|
".rvmrc",
|
23
|
+
".travis.yml",
|
23
24
|
"Gemfile",
|
24
25
|
"Gemfile.lock",
|
25
26
|
"LICENSE.txt",
|
@@ -28,6 +29,10 @@ Gem::Specification.new do |s|
|
|
28
29
|
"VERSION",
|
29
30
|
"google-short-links.gemspec",
|
30
31
|
"lib/google_short_links.rb",
|
32
|
+
"lib/google_short_links/client.rb",
|
33
|
+
"lib/google_short_links/parser.rb",
|
34
|
+
"spec/google_short_links/client_spec.rb",
|
35
|
+
"spec/google_short_links/parser_spec.rb",
|
31
36
|
"spec/google_short_links_spec.rb",
|
32
37
|
"spec/spec_helper.rb"
|
33
38
|
]
|
@@ -41,21 +46,30 @@ Gem::Specification.new do |s|
|
|
41
46
|
s.specification_version = 3
|
42
47
|
|
43
48
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
49
|
+
s.add_runtime_dependency(%q<httparty>, [">= 0"])
|
50
|
+
s.add_runtime_dependency(%q<multi_json>, [">= 0"])
|
44
51
|
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
45
52
|
s.add_development_dependency(%q<rcov>, [">= 0"])
|
46
53
|
s.add_development_dependency(%q<rdoc>, [">= 0"])
|
47
54
|
s.add_development_dependency(%q<rspec>, [">= 0"])
|
55
|
+
s.add_development_dependency(%q<timecop>, [">= 0"])
|
48
56
|
else
|
57
|
+
s.add_dependency(%q<httparty>, [">= 0"])
|
58
|
+
s.add_dependency(%q<multi_json>, [">= 0"])
|
49
59
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
50
60
|
s.add_dependency(%q<rcov>, [">= 0"])
|
51
61
|
s.add_dependency(%q<rdoc>, [">= 0"])
|
52
62
|
s.add_dependency(%q<rspec>, [">= 0"])
|
63
|
+
s.add_dependency(%q<timecop>, [">= 0"])
|
53
64
|
end
|
54
65
|
else
|
66
|
+
s.add_dependency(%q<httparty>, [">= 0"])
|
67
|
+
s.add_dependency(%q<multi_json>, [">= 0"])
|
55
68
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
56
69
|
s.add_dependency(%q<rcov>, [">= 0"])
|
57
70
|
s.add_dependency(%q<rdoc>, [">= 0"])
|
58
71
|
s.add_dependency(%q<rspec>, [">= 0"])
|
72
|
+
s.add_dependency(%q<timecop>, [">= 0"])
|
59
73
|
end
|
60
74
|
end
|
61
75
|
|
data/lib/google_short_links.rb
CHANGED
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
require 'base64'
|
3
|
+
require 'digest/sha1'
|
4
|
+
require 'openssl'
|
5
|
+
require 'uri'
|
6
|
+
|
7
|
+
require 'httparty'
|
8
|
+
|
9
|
+
class GoogleShortLinks::Client
|
10
|
+
include HTTParty
|
11
|
+
|
12
|
+
attr_accessor :server, :secret, :email
|
13
|
+
|
14
|
+
parser GoogleShortLinks::Parser
|
15
|
+
|
16
|
+
def initialize options={}
|
17
|
+
self.server = options[:server]
|
18
|
+
self.secret = options[:secret]
|
19
|
+
self.email = options[:email]
|
20
|
+
end
|
21
|
+
|
22
|
+
def get_or_create_hash_url url, params={}
|
23
|
+
request_path = request_path(:get_or_create_hash)
|
24
|
+
|
25
|
+
query = params_to_query(base_params.merge(:url => url).merge(params))
|
26
|
+
|
27
|
+
digest_url(request_path, query)
|
28
|
+
end
|
29
|
+
|
30
|
+
def get_or_create_shortlink_url url, shortcut, params={}
|
31
|
+
request_path = request_path(:get_or_create_shortlink)
|
32
|
+
|
33
|
+
query = params_to_query(base_params.merge(:url => url, :shortcut => shortcut).merge(params))
|
34
|
+
|
35
|
+
digest_url(request_path, query)
|
36
|
+
end
|
37
|
+
|
38
|
+
def get_details_url shortcut, params={}
|
39
|
+
request_path = request_path(:get_details)
|
40
|
+
|
41
|
+
query = params_to_query(base_params.merge(:shortcut => shortcut).merge(params))
|
42
|
+
|
43
|
+
digest_url(request_path, query)
|
44
|
+
end
|
45
|
+
|
46
|
+
def get_or_create_hash url, params={}
|
47
|
+
self.class.get(get_or_create_hash_url(url, params)).parsed_response
|
48
|
+
end
|
49
|
+
|
50
|
+
def get_or_create_shortlink url, shortcut, params={}
|
51
|
+
self.class.get(get_or_create_shortlink_url(url, shortcut, params)).parsed_response
|
52
|
+
end
|
53
|
+
|
54
|
+
def get_details shortcut, params={}
|
55
|
+
self.class.get(get_details_url(shortcut, params)).parsed_response
|
56
|
+
end
|
57
|
+
|
58
|
+
protected
|
59
|
+
|
60
|
+
def request_path action
|
61
|
+
"http://#{server}/js/#{action}"
|
62
|
+
end
|
63
|
+
|
64
|
+
def base_params
|
65
|
+
{
|
66
|
+
:oauth_signature_method => 'HMAC-SHA1',
|
67
|
+
:timestamp => Time.now.to_i.to_f,
|
68
|
+
:user => email,
|
69
|
+
}
|
70
|
+
end
|
71
|
+
|
72
|
+
def params_to_query params
|
73
|
+
params.to_a.sort_by { |param| param.to_s }.map { |(key, value)| "#{CGI.escape(key.to_s)}=#{CGI.escape(value.to_s)}" }.join('&')
|
74
|
+
end
|
75
|
+
|
76
|
+
def digest request_path, query
|
77
|
+
content = "GET&#{CGI.escape(request_path)}&#{CGI.escape(query)}"
|
78
|
+
|
79
|
+
digest = OpenSSL::Digest::Digest.new('sha1')
|
80
|
+
digest_raw = OpenSSL::HMAC.digest(digest, secret, content)
|
81
|
+
CGI.escape(Base64.encode64(digest_raw).chomp)
|
82
|
+
end
|
83
|
+
|
84
|
+
def digest_url request_path, query
|
85
|
+
request_uri = URI.parse(request_path)
|
86
|
+
request_uri.query = "#{query}&oauth_signature=#{digest(request_path, query)}"
|
87
|
+
request_uri.to_s
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,287 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
2
|
+
|
3
|
+
describe GoogleShortLinks::Client do
|
4
|
+
subject { GoogleShortLinks::Client }
|
5
|
+
|
6
|
+
it { should <= HTTParty }
|
7
|
+
|
8
|
+
describe '#initialize' do
|
9
|
+
subject { GoogleShortLinks::Client.new @params }
|
10
|
+
|
11
|
+
context 'with options { :server => "a", :secret => "b", :email => "c" }' do
|
12
|
+
before :each do
|
13
|
+
@params = { :server => 'a', :secret => 'b', :email => 'c' }
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'sets server to a' do
|
17
|
+
subject.server.should == 'a'
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'sets secret to b' do
|
21
|
+
subject.secret.should == 'b'
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'sets email to c' do
|
25
|
+
subject.email.should == 'c'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'with options { :email => "c" }' do
|
30
|
+
before :each do
|
31
|
+
@params = { :email => 'c' }
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'leaves server nil' do
|
35
|
+
subject.server.should be_nil
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'leaves secret nil' do
|
39
|
+
subject.secret.should be_nil
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'sets email to c' do
|
43
|
+
subject.email.should == 'c'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'with options {}' do
|
48
|
+
before :each do
|
49
|
+
@params = {}
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'leaves server nil' do
|
53
|
+
subject.server.should be_nil
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'leaves secret nil' do
|
57
|
+
subject.secret.should be_nil
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'leaves email nil' do
|
61
|
+
subject.email.should be_nil
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe '#get_or_create_hash_url' do
|
67
|
+
subject { GoogleShortLinks::Client.new(@options).get_or_create_hash_url(@url, @params) }
|
68
|
+
|
69
|
+
context 'at 2011-11-17 13:04:15 -0500' do
|
70
|
+
before :each do
|
71
|
+
@now = Time.at(1321553055)
|
72
|
+
Timecop.freeze(@now)
|
73
|
+
end
|
74
|
+
|
75
|
+
after :each do
|
76
|
+
Timecop.return
|
77
|
+
end
|
78
|
+
|
79
|
+
context 'with server a, secret b, and email c' do
|
80
|
+
before :each do
|
81
|
+
@options = { :server => 'a', :secret => 'b', :email => 'c' }
|
82
|
+
end
|
83
|
+
|
84
|
+
context 'with url d' do
|
85
|
+
before :each do
|
86
|
+
@url = 'd'
|
87
|
+
end
|
88
|
+
|
89
|
+
context 'with empty params' do
|
90
|
+
before :each do
|
91
|
+
@params = {}
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'should return a url with host a, path get_or_create_hash, signature method HMAC-SHA1, a current timestamp, url d, and user c, that is signed' do
|
95
|
+
subject.should == "http://a/js/get_or_create_hash?oauth_signature_method=HMAC-SHA1×tamp=#{Time.now.to_f}&url=d&user=c&oauth_signature=H8ugo%2B8%2FHLIORPo9LjntVSClZXY%3D"
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
context 'with params oauth_signature_method HMAC-MD5, blah 123' do
|
100
|
+
before :each do
|
101
|
+
@params = { :oauth_signature_method => 'HMAC-MD5', :blah => 123 }
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'should return a url with host a, path get_or_create_hash, signature method HMAC-MD5, a current timestamp, url d, user c, and extra parameter blah 123, that is signed' do
|
105
|
+
subject.should == "http://a/js/get_or_create_hash?blah=123&oauth_signature_method=HMAC-MD5×tamp=#{Time.now.to_f}&url=d&user=c&oauth_signature=SHidraLOaaGtSP08qTXITZRk4nk%3D"
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
describe '#get_or_create_shortlink_url' do
|
114
|
+
subject { GoogleShortLinks::Client.new(@options).get_or_create_shortlink_url(@url, @shortcut, @params) }
|
115
|
+
|
116
|
+
context 'at 2011-11-17 13:04:15 -0500' do
|
117
|
+
before :each do
|
118
|
+
@now = Time.at(1321553055)
|
119
|
+
Timecop.freeze(@now)
|
120
|
+
end
|
121
|
+
|
122
|
+
after :each do
|
123
|
+
Timecop.return
|
124
|
+
end
|
125
|
+
|
126
|
+
context 'with server a, secret b, and email c' do
|
127
|
+
before :each do
|
128
|
+
@options = { :server => 'a', :secret => 'b', :email => 'c' }
|
129
|
+
end
|
130
|
+
|
131
|
+
context 'with url d' do
|
132
|
+
before :each do
|
133
|
+
@url = 'd'
|
134
|
+
end
|
135
|
+
|
136
|
+
context 'with a shortcut e' do
|
137
|
+
before :each do
|
138
|
+
@shortcut = 'e'
|
139
|
+
end
|
140
|
+
|
141
|
+
context 'with empty params' do
|
142
|
+
before :each do
|
143
|
+
@params = {}
|
144
|
+
end
|
145
|
+
|
146
|
+
it 'should return a url with host a, path get_or_create_shortlink, signature method HMAC-SHA1, shortcut e, a current timestamp, url d, and user c, that is signed' do
|
147
|
+
subject.should == "http://a/js/get_or_create_shortlink?oauth_signature_method=HMAC-SHA1&shortcut=e×tamp=#{Time.now.to_f}&url=d&user=c&oauth_signature=Hf23Wj%2FoHARH4oyqy7FCgzUQrSk%3D"
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
context 'with params oauth_signature_method HMAC-MD5, blah 123' do
|
152
|
+
before :each do
|
153
|
+
@params = { :oauth_signature_method => 'HMAC-MD5', :blah => 123 }
|
154
|
+
end
|
155
|
+
|
156
|
+
it 'should return a url with host a, path get_or_create_shortlink, signature method HMAC-MD5, shortcut e, a current timestamp, url d, user c, and extra parameter blah 123, that is signed' do
|
157
|
+
subject.should == "http://a/js/get_or_create_shortlink?blah=123&oauth_signature_method=HMAC-MD5&shortcut=e×tamp=#{Time.now.to_f}&url=d&user=c&oauth_signature=bdfkqZPbuqsKqalwou08oImutV0%3D"
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
describe '#get_details_url' do
|
167
|
+
subject { GoogleShortLinks::Client.new(@options).get_details_url(@shortcut, @params) }
|
168
|
+
|
169
|
+
context 'at 2011-11-17 13:04:15 -0500' do
|
170
|
+
before :each do
|
171
|
+
@now = Time.at(1321553055)
|
172
|
+
Timecop.freeze(@now)
|
173
|
+
end
|
174
|
+
|
175
|
+
after :each do
|
176
|
+
Timecop.return
|
177
|
+
end
|
178
|
+
|
179
|
+
context 'with server a, secret b, and email c' do
|
180
|
+
before :each do
|
181
|
+
@options = { :server => 'a', :secret => 'b', :email => 'c' }
|
182
|
+
end
|
183
|
+
|
184
|
+
context 'with a shortcut e' do
|
185
|
+
before :each do
|
186
|
+
@shortcut = 'e'
|
187
|
+
end
|
188
|
+
|
189
|
+
context 'with empty params' do
|
190
|
+
before :each do
|
191
|
+
@params = {}
|
192
|
+
end
|
193
|
+
|
194
|
+
it 'should return a url with host a, path get_details, signature method HMAC-SHA1, shortcut e, a current timestamp, and user c, that is signed' do
|
195
|
+
subject.should == "http://a/js/get_details?oauth_signature_method=HMAC-SHA1&shortcut=e×tamp=#{Time.now.to_f}&user=c&oauth_signature=4uyxm8VBpvqEjoorn9Z60OhNsr8%3D"
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
context 'with params oauth_signature_method HMAC-MD5, blah 123' do
|
200
|
+
before :each do
|
201
|
+
@params = { :oauth_signature_method => 'HMAC-MD5', :blah => 123 }
|
202
|
+
end
|
203
|
+
|
204
|
+
it 'should return a url with host a, path get_details, signature method HMAC-MD5, shortcut e, a current timestamp, user c, and extra parameter blah 123, that is signed' do
|
205
|
+
subject.should == "http://a/js/get_details?blah=123&oauth_signature_method=HMAC-MD5&shortcut=e×tamp=#{Time.now.to_f}&user=c&oauth_signature=iXvjBSxA87X45ShYk4JRb7W%2BcOw%3D"
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
describe '#get_or_create_hash' do
|
214
|
+
let(:client) { GoogleShortLinks::Client.new }
|
215
|
+
|
216
|
+
subject { client.get_or_create_hash(nil) }
|
217
|
+
|
218
|
+
context 'with get_or_create_hash_url returning http://www.example.org/' do
|
219
|
+
before :each do
|
220
|
+
client.stub!(:get_or_create_hash_url).and_return('http://www.example.org/')
|
221
|
+
end
|
222
|
+
|
223
|
+
it 'should call get with http://www.example.org/' do
|
224
|
+
GoogleShortLinks::Client.should_receive(:get).with('http://www.example.org/').and_return(mock(:parsed_response => nil))
|
225
|
+
subject
|
226
|
+
end
|
227
|
+
|
228
|
+
context 'when get returns a parsed response { "a" => "b" }' do
|
229
|
+
before :each do
|
230
|
+
GoogleShortLinks::Client.stub!(:get).with('http://www.example.org/').and_return(mock(:parsed_response => { 'a' => 'b'}))
|
231
|
+
end
|
232
|
+
|
233
|
+
it { should == { 'a' => 'b' } }
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
describe '#get_or_create_shortlink' do
|
239
|
+
let(:client) { GoogleShortLinks::Client.new }
|
240
|
+
|
241
|
+
subject { client.get_or_create_shortlink(nil, nil) }
|
242
|
+
|
243
|
+
context 'with get_or_create_shortlink_url returning http://www.example.org/' do
|
244
|
+
before :each do
|
245
|
+
client.stub!(:get_or_create_shortlink_url).and_return('http://www.example.org/')
|
246
|
+
end
|
247
|
+
|
248
|
+
it 'should call get with http://www.example.org/' do
|
249
|
+
GoogleShortLinks::Client.should_receive(:get).with('http://www.example.org/').and_return(mock(:parsed_response => nil))
|
250
|
+
subject
|
251
|
+
end
|
252
|
+
|
253
|
+
context 'when get returns a parsed response { "a" => "b" }' do
|
254
|
+
before :each do
|
255
|
+
GoogleShortLinks::Client.stub!(:get).with('http://www.example.org/').and_return(mock(:parsed_response => { 'a' => 'b'}))
|
256
|
+
end
|
257
|
+
|
258
|
+
it { should == { 'a' => 'b' } }
|
259
|
+
end
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
describe '#get_details' do
|
264
|
+
let(:client) { GoogleShortLinks::Client.new }
|
265
|
+
|
266
|
+
subject { client.get_details(nil) }
|
267
|
+
|
268
|
+
context 'with get_details_url returning http://www.example.org/' do
|
269
|
+
before :each do
|
270
|
+
client.stub!(:get_details_url).and_return('http://www.example.org/')
|
271
|
+
end
|
272
|
+
|
273
|
+
it 'should call get with http://www.example.org/' do
|
274
|
+
GoogleShortLinks::Client.should_receive(:get).with('http://www.example.org/').and_return(mock(:parsed_response => nil))
|
275
|
+
subject
|
276
|
+
end
|
277
|
+
|
278
|
+
context 'when get returns a parsed response { "a" => "b" }' do
|
279
|
+
before :each do
|
280
|
+
GoogleShortLinks::Client.stub!(:get).with('http://www.example.org/').and_return(mock(:parsed_response => { 'a' => 'b'}))
|
281
|
+
end
|
282
|
+
|
283
|
+
it { should == { 'a' => 'b' } }
|
284
|
+
end
|
285
|
+
end
|
286
|
+
end
|
287
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
2
|
+
|
3
|
+
describe GoogleShortLinks::Parser do
|
4
|
+
subject { GoogleShortLinks::Parser }
|
5
|
+
|
6
|
+
it { should <= HTTParty::Parser }
|
7
|
+
|
8
|
+
it('should support format :json') { should be_supports_format :json }
|
9
|
+
|
10
|
+
describe '#call' do
|
11
|
+
subject { GoogleShortLinks::Parser.call @body, @format }
|
12
|
+
|
13
|
+
context 'with a format of :json' do
|
14
|
+
before :each do
|
15
|
+
@format = :json
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'with an body of {"a":"b"}' do
|
19
|
+
before :each do
|
20
|
+
@body = '{"a":"b"}'
|
21
|
+
end
|
22
|
+
|
23
|
+
it { should == {'a' => 'b'} }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-short-links
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,34 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-11-
|
12
|
+
date: 2011-11-18 00:00:00.000000000 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: httparty
|
17
|
+
requirement: &22456740 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *22456740
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: multi_json
|
28
|
+
requirement: &22456100 !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: *22456100
|
15
37
|
- !ruby/object:Gem::Dependency
|
16
38
|
name: jeweler
|
17
|
-
requirement: &
|
39
|
+
requirement: &22455460 !ruby/object:Gem::Requirement
|
18
40
|
none: false
|
19
41
|
requirements:
|
20
42
|
- - ! '>='
|
@@ -22,10 +44,10 @@ dependencies:
|
|
22
44
|
version: '0'
|
23
45
|
type: :development
|
24
46
|
prerelease: false
|
25
|
-
version_requirements: *
|
47
|
+
version_requirements: *22455460
|
26
48
|
- !ruby/object:Gem::Dependency
|
27
49
|
name: rcov
|
28
|
-
requirement: &
|
50
|
+
requirement: &22454860 !ruby/object:Gem::Requirement
|
29
51
|
none: false
|
30
52
|
requirements:
|
31
53
|
- - ! '>='
|
@@ -33,10 +55,10 @@ dependencies:
|
|
33
55
|
version: '0'
|
34
56
|
type: :development
|
35
57
|
prerelease: false
|
36
|
-
version_requirements: *
|
58
|
+
version_requirements: *22454860
|
37
59
|
- !ruby/object:Gem::Dependency
|
38
60
|
name: rdoc
|
39
|
-
requirement: &
|
61
|
+
requirement: &22454260 !ruby/object:Gem::Requirement
|
40
62
|
none: false
|
41
63
|
requirements:
|
42
64
|
- - ! '>='
|
@@ -44,10 +66,21 @@ dependencies:
|
|
44
66
|
version: '0'
|
45
67
|
type: :development
|
46
68
|
prerelease: false
|
47
|
-
version_requirements: *
|
69
|
+
version_requirements: *22454260
|
48
70
|
- !ruby/object:Gem::Dependency
|
49
71
|
name: rspec
|
50
|
-
requirement: &
|
72
|
+
requirement: &22453640 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
type: :development
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: *22453640
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: timecop
|
83
|
+
requirement: &22453020 !ruby/object:Gem::Requirement
|
51
84
|
none: false
|
52
85
|
requirements:
|
53
86
|
- - ! '>='
|
@@ -55,7 +88,7 @@ dependencies:
|
|
55
88
|
version: '0'
|
56
89
|
type: :development
|
57
90
|
prerelease: false
|
58
|
-
version_requirements: *
|
91
|
+
version_requirements: *22453020
|
59
92
|
description: Ruby wrapper for Google Short Links.
|
60
93
|
email: benmanns@gmail.com
|
61
94
|
executables: []
|
@@ -67,6 +100,7 @@ files:
|
|
67
100
|
- .document
|
68
101
|
- .rspec
|
69
102
|
- .rvmrc
|
103
|
+
- .travis.yml
|
70
104
|
- Gemfile
|
71
105
|
- Gemfile.lock
|
72
106
|
- LICENSE.txt
|
@@ -75,6 +109,10 @@ files:
|
|
75
109
|
- VERSION
|
76
110
|
- google-short-links.gemspec
|
77
111
|
- lib/google_short_links.rb
|
112
|
+
- lib/google_short_links/client.rb
|
113
|
+
- lib/google_short_links/parser.rb
|
114
|
+
- spec/google_short_links/client_spec.rb
|
115
|
+
- spec/google_short_links/parser_spec.rb
|
78
116
|
- spec/google_short_links_spec.rb
|
79
117
|
- spec/spec_helper.rb
|
80
118
|
has_rdoc: true
|
@@ -93,7 +131,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
93
131
|
version: '0'
|
94
132
|
segments:
|
95
133
|
- 0
|
96
|
-
hash:
|
134
|
+
hash: 2703034883636259662
|
97
135
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
136
|
none: false
|
99
137
|
requirements:
|