ruby-bitly 0.2.1 → 3.0.0.rc1

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.
@@ -1,3 +1,3 @@
1
1
  module BitlyGem
2
- VERSION = '0.2.1'
2
+ VERSION = '3.0.0.rc1'
3
3
  end
@@ -5,20 +5,21 @@ Gem::Specification.new do |s|
5
5
  s.name = "ruby-bitly"
6
6
  s.version = BitlyGem::VERSION
7
7
  s.authors = ["dx7"]
8
- s.email = ["dx7@protonmail.ch"]
8
+ s.email = ["dx7@pm.me"]
9
9
  s.homepage = "http://github.com/dx7/ruby-bitly"
10
10
  s.summary = %q{A simple bit.ly ruby client to shorten URLs, expand or get number of clicks on a bitlink}
11
11
  s.description = %q{A simple bit.ly ruby client to shorten URLs, expand or get number of clicks on a bitlink.}
12
12
  s.files = `git ls-files`.split("\n")
13
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
13
+ s.test_files = `git ls-files -- {spec,fixtures,gemfiles}/*`.split("\n")
14
14
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
15
15
  s.require_paths = ["lib"]
16
16
  s.licenses = ['MIT']
17
17
  s.required_ruby_version = '>= 2.0.0'
18
- s.add_dependency('rest-client', '~> 2.0')
19
- s.add_development_dependency('byebug')
18
+ s.add_runtime_dependency('rest-client', '~> 2.0')
20
19
  s.add_development_dependency('rake')
21
- s.add_development_dependency('rspec', '~> 3.5')
22
- s.add_development_dependency('vcr', '~> 3.0')
23
- s.add_development_dependency('webmock', '~> 2.1')
20
+ s.add_development_dependency('rspec')
21
+ s.add_development_dependency('vcr')
22
+ s.add_development_dependency('webmock')
23
+ s.add_development_dependency('public_suffix', '< 3') # it is a webmock dependency. it is neccessary to run tests on ruby 2.0
24
+ s.add_development_dependency('wwtd')
24
25
  end
@@ -26,20 +26,7 @@ describe 'RubyBitly' do
26
26
  describe 'shorten' do
27
27
  context 'using local config' do
28
28
  before do
29
- Bitly.config { |c| c.login = 'invalid login'; c.api_key = 'invalid api_key' }
30
- end
31
-
32
- it 'shorten long url using old API' do
33
- response = VCR.use_cassette('shorten_long_url') do
34
- Bitly.shorten('http://google.com', login, api_key)
35
- end
36
-
37
- expect(response.status_txt).to eq('OK')
38
- expect(response.status_code).to eq(200)
39
- expect(response.new_hash).to eq(0)
40
- expect(response.global_hash).not_to be_empty
41
- expect(response.hash_path.length).not_to eq(0)
42
- expect(response.url).to match(/^http:\/\/bit\.ly\/[A-Za-z0-9]*/)
29
+ Bitly.config { |c| c.login = 'any login'; c.api_key = 'any api_key' }
43
30
  end
44
31
 
45
32
  it 'shorten long url using new API' do
@@ -47,12 +34,12 @@ describe 'RubyBitly' do
47
34
  Bitly.shorten(:long_url => 'http://google.com', :login => login, :api_key => api_key)
48
35
  end
49
36
 
50
- expect(response.status_txt).to eq('OK')
51
- expect(response.status_code).to eq(200)
52
- expect(response.new_hash).to eq(0)
37
+ expect(response.success?).to eq(true)
38
+ expect(response.error).to eq(nil)
39
+ expect(response.new_hash?).to eq(false)
53
40
  expect(response.global_hash).not_to be_empty
54
- expect(response.hash_path.length).not_to eq(0)
55
- expect(response.url).to match(/^http:\/\/bit\.ly\/[A-Za-z0-9]*/)
41
+ expect(response.user_hash.length).not_to eq(0)
42
+ expect(response.short_url).to match(/^http:\/\/bit\.ly\/[A-Za-z0-9]*/)
56
43
  end
57
44
 
58
45
  it 'shorten long url with a preferred domain' do
@@ -60,21 +47,31 @@ describe 'RubyBitly' do
60
47
  Bitly.shorten(:long_url => 'http://google.com', :domain => 'j.mp', :login => login, :api_key => api_key)
61
48
  end
62
49
 
63
- expect(response.status_txt).to eq('OK')
64
- expect(response.status_code).to eq(200)
65
- expect(response.new_hash).to eq(0)
50
+ expect(response.success?).to eq(true)
51
+ expect(response.error).to eq(nil)
52
+ expect(response.error).to eq(nil)
53
+ expect(response.new_hash?).to eq(false)
66
54
  expect(response.global_hash).not_to be_empty
67
- expect(response.hash_path.length).not_to eq(0)
68
- expect(response.url).to match(/^http:\/\/j\.mp\/[A-Za-z0-9]*/)
55
+ expect(response.user_hash.length).not_to eq(0)
56
+ expect(response.short_url).to match(/^http:\/\/j\.mp\/[A-Za-z0-9]*/)
69
57
  end
70
58
 
71
59
  it 'shorten bitly url' do
72
60
  response = VCR.use_cassette('shorten_bitly_url') do
73
- Bitly.shorten('http://bit.ly/bcvNe5', login, api_key)
61
+ Bitly.shorten(long_url: 'http://bit.ly/bcvNe5', login: login, api_key: api_key)
74
62
  end
75
63
 
76
- expect(response.status_txt).to eq('ALREADY_A_BITLY_LINK')
77
- expect(response.status_code).to eq(500)
64
+ expect(response.success?).to eq(false)
65
+ expect(response.error).to eq('ALREADY_A_BITLY_LINK')
66
+ end
67
+
68
+ it 'uses invalid login' do
69
+ response = VCR.use_cassette('shorten_using_invalid_login') do
70
+ Bitly.shorten(long_url: 'http://bit.ly/bcvNe5', login: login, api_key: api_key)
71
+ end
72
+
73
+ expect(response.success?).to eq(false)
74
+ expect(response.error).to eq('INVALID_LOGIN')
78
75
  end
79
76
  end
80
77
 
@@ -83,30 +80,16 @@ describe 'RubyBitly' do
83
80
  Bitly.config { |c| c.login = login; c.api_key = api_key }
84
81
  end
85
82
 
86
- it 'shorten long url using old API' do
87
- response = VCR.use_cassette('shorten_long_url') do
88
- Bitly.shorten('http://google.com')
89
- end
90
-
91
- expect(response.status_txt).to eq('OK')
92
- expect(response.status_code).to eq(200)
93
- expect(response.new_hash).to eq(0)
94
- expect(response.global_hash).not_to be_empty
95
- expect(response.hash_path.length).not_to eq(0)
96
- expect(response.url).to match(/^http:\/\/bit\.ly\/[A-Za-z0-9]*/)
97
- end
98
-
99
83
  it 'shorten long url using global config' do
100
84
  response = VCR.use_cassette('shorten_long_url') do
101
85
  Bitly.shorten(:long_url => 'http://google.com')
102
86
  end
103
87
 
104
- expect(response.status_txt).to eq('OK')
105
- expect(response.status_code).to eq(200)
106
- expect(response.new_hash).to eq(0)
88
+ expect(response.success?).to eq(true)
89
+ expect(response.new_hash?).to eq(false)
107
90
  expect(response.global_hash).not_to be_empty
108
- expect(response.hash_path.length).not_to eq(0)
109
- expect(response.url).to match(/^http:\/\/bit\.ly\/[A-Za-z0-9]*/)
91
+ expect(response.user_hash.length).not_to eq(0)
92
+ expect(response.short_url).to match(/^http:\/\/bit\.ly\/[A-Za-z0-9]*/)
110
93
  end
111
94
  end
112
95
  end
@@ -114,16 +97,15 @@ describe 'RubyBitly' do
114
97
  describe 'expand' do
115
98
  context 'using local config' do
116
99
  before do
117
- Bitly.config { |c| c.login = 'invalid login'; c.api_key = 'invalid api_key' }
100
+ Bitly.config { |c| c.login = 'any login'; c.api_key = 'any api_key' }
118
101
  end
119
102
 
120
103
  it 'expand a short url to its long url old API' do
121
104
  response = VCR.use_cassette('expand_a_short_url_to_it_long_url') do
122
- Bitly.expand('http://bit.ly/bcvNe5', login, api_key)
105
+ Bitly.expand(short_url: 'http://bit.ly/bcvNe5', login: login, api_key: api_key)
123
106
  end
124
107
 
125
- expect(response.status_txt).to eq('OK')
126
- expect(response.status_code).to eq(200)
108
+ expect(response.success?).to eq(true)
127
109
  expect(response.long_url).to eq('http://google.com')
128
110
  expect(response.short_url).to eq('http://bit.ly/bcvNe5')
129
111
  expect(response.user_hash).to eq('bcvNe5')
@@ -134,8 +116,7 @@ describe 'RubyBitly' do
134
116
  Bitly.expand({ :short_url => 'http://bit.ly/bcvNe5', :login => login, :api_key => api_key })
135
117
  end
136
118
 
137
- expect(response.status_txt).to eq('OK')
138
- expect(response.status_code).to eq(200)
119
+ expect(response.success?).to eq(true)
139
120
  expect(response.long_url).to eq('http://google.com')
140
121
  expect(response.short_url).to eq('http://bit.ly/bcvNe5')
141
122
  expect(response.user_hash).to eq('bcvNe5')
@@ -143,11 +124,10 @@ describe 'RubyBitly' do
143
124
 
144
125
  it 'expand a long url should result an error' do
145
126
  response = VCR.use_cassette('expand_a_long_url_should_result_an_error') do
146
- Bitly.expand('http://google.com', login, api_key)
127
+ Bitly.expand(short_url: 'http://google.com', login: login, api_key: api_key)
147
128
  end
148
129
 
149
- expect(response.status_txt).to eq('OK')
150
- expect(response.status_code).to eq(200)
130
+ expect(response.success?).to eq(true)
151
131
  expect(response.long_url).to eq('NOT_FOUND')
152
132
  expect(response.short_url).to eq('http://google.com')
153
133
  end
@@ -158,25 +138,12 @@ describe 'RubyBitly' do
158
138
  Bitly.config { |c| c.login = login; c.api_key = api_key }
159
139
  end
160
140
 
161
- it 'expand a short url to its long url old API' do
162
- response = VCR.use_cassette('expand_a_short_url_to_it_long_url') do
163
- Bitly.expand('http://bit.ly/bcvNe5')
164
- end
165
-
166
- expect(response.status_txt).to eq('OK')
167
- expect(response.status_code).to eq(200)
168
- expect(response.long_url).to eq('http://google.com')
169
- expect(response.short_url).to eq('http://bit.ly/bcvNe5')
170
- expect(response.user_hash).to eq('bcvNe5')
171
- end
172
-
173
141
  it 'expand a short url to its long url using global config' do
174
142
  response = VCR.use_cassette('expand_a_short_url_to_it_long_url') do
175
143
  Bitly.expand({ :short_url => 'http://bit.ly/bcvNe5' })
176
144
  end
177
145
 
178
- expect(response.status_txt).to eq('OK')
179
- expect(response.status_code).to eq(200)
146
+ expect(response.success?).to eq(true)
180
147
  expect(response.long_url).to eq('http://google.com')
181
148
  expect(response.short_url).to eq('http://bit.ly/bcvNe5')
182
149
  expect(response.user_hash).to eq('bcvNe5')
@@ -188,21 +155,7 @@ describe 'RubyBitly' do
188
155
  describe 'get clicks' do
189
156
  context 'using local config' do
190
157
  before do
191
- Bitly.config { |c| c.login = 'invalid login'; c.api_key = 'invalid api_key' }
192
- end
193
-
194
- it 'get clicks by short_url using old API' do
195
- bitly = VCR.use_cassette('get_clicks_by_short_url') do
196
- Bitly.get_clicks('http://bit.ly/xlii42', login, api_key)
197
- end
198
-
199
- expect(bitly.status_txt).to eq('OK')
200
- expect(bitly.status_code).to eq(200)
201
- expect(bitly.global_clicks).to be_an Integer
202
- expect(bitly.user_clicks).to be_an Integer
203
- expect(bitly.short_url).to eq('http://bit.ly/xlii42')
204
- expect(bitly.global_hash).to eq('cunZEP')
205
- expect(bitly.user_hash).to eq('cT1Izu')
158
+ Bitly.config { |c| c.login = 'any login'; c.api_key = 'any api_key' }
206
159
  end
207
160
 
208
161
  it 'get clicks by short_url using options API' do
@@ -210,8 +163,7 @@ describe 'RubyBitly' do
210
163
  Bitly.get_clicks(:short_url => 'http://bit.ly/xlii42', :login => login, :api_key => api_key)
211
164
  end
212
165
 
213
- expect(bitly.status_txt).to eq('OK')
214
- expect(bitly.status_code).to eq(200)
166
+ expect(bitly.success?).to eq(true)
215
167
  expect(bitly.global_clicks).to be_an Integer
216
168
  expect(bitly.user_clicks).to be_an Integer
217
169
  expect(bitly.short_url).to eq('http://bit.ly/xlii42')
@@ -225,27 +177,12 @@ describe 'RubyBitly' do
225
177
  Bitly.config { |c| c.login = login; c.api_key = api_key }
226
178
  end
227
179
 
228
- it 'get clicks by short_url using old API' do
229
- bitly = VCR.use_cassette('get_clicks_by_short_url') do
230
- Bitly.get_clicks('http://bit.ly/xlii42')
231
- end
232
-
233
- expect(bitly.status_txt).to eq('OK')
234
- expect(bitly.status_code).to eq(200)
235
- expect(bitly.global_clicks).to be_an Integer
236
- expect(bitly.user_clicks).to be_an Integer
237
- expect(bitly.short_url).to eq('http://bit.ly/xlii42')
238
- expect(bitly.global_hash).to eq('cunZEP')
239
- expect(bitly.user_hash).to eq('cT1Izu')
240
- end
241
-
242
180
  it 'get clicks by short_url using global config' do
243
181
  bitly = VCR.use_cassette('get_clicks_by_short_url') do
244
182
  Bitly.get_clicks(:short_url => 'http://bit.ly/xlii42')
245
183
  end
246
184
 
247
- expect(bitly.status_txt).to eq('OK')
248
- expect(bitly.status_code).to eq(200)
185
+ expect(bitly.success?).to eq(true)
249
186
  expect(bitly.global_clicks).to be_an Integer
250
187
  expect(bitly.user_clicks).to be_an Integer
251
188
  expect(bitly.short_url).to eq('http://bit.ly/xlii42')
@@ -286,8 +223,7 @@ describe 'RubyBitly' do
286
223
  Bitly.get_clicks(:short_url => 'http://bit.ly/xlii42', :login => login, :api_key => api_key)
287
224
  end
288
225
 
289
- expect(bitly.status_txt).to eq('OK')
290
- expect(bitly.status_code).to eq(200)
226
+ expect(bitly.success?).to eq(true)
291
227
  end
292
228
  end
293
229
  end
@@ -1,6 +1,5 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
2
2
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
- require 'byebug'
4
3
  require 'ruby-bitly'
5
4
  require 'rspec'
6
5
  require 'vcr'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-bitly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 3.0.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - dx7
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-14 00:00:00.000000000 Z
11
+ date: 2019-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: byebug
28
+ name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rake
42
+ name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -53,51 +53,65 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rspec
56
+ name: vcr
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '3.5'
61
+ version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '3.5'
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: vcr
70
+ name: webmock
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: '3.0'
75
+ version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: '3.0'
82
+ version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: webmock
84
+ name: public_suffix
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - "<"
88
88
  - !ruby/object:Gem::Version
89
- version: '2.1'
89
+ version: '3'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - "<"
95
95
  - !ruby/object:Gem::Version
96
- version: '2.1'
96
+ version: '3'
97
+ - !ruby/object:Gem::Dependency
98
+ name: wwtd
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  description: A simple bit.ly ruby client to shorten URLs, expand or get number of
98
112
  clicks on a bitlink.
99
113
  email:
100
- - dx7@protonmail.ch
114
+ - dx7@pm.me
101
115
  executables:
102
116
  - bitly
103
117
  extensions: []
@@ -120,6 +134,13 @@ files:
120
134
  - fixtures/vcr_cassettes/shorten_bitly_url.yml
121
135
  - fixtures/vcr_cassettes/shorten_long_url.yml
122
136
  - fixtures/vcr_cassettes/shorten_long_url_with_preferred_domain.yml
137
+ - fixtures/vcr_cassettes/shorten_using_invalid_login.yml
138
+ - gemfiles/rest-client-2.0.1.gemfile
139
+ - gemfiles/rest-client-2.0.1.gemfile.lock
140
+ - gemfiles/rest-client-2.0.2.gemfile
141
+ - gemfiles/rest-client-2.0.2.gemfile.lock
142
+ - gemfiles/rest-client-2.1.0.rc1.gemfile
143
+ - gemfiles/rest-client-2.1.0.rc1.gemfile.lock
123
144
  - lib/ruby-bitly.rb
124
145
  - lib/ruby-bitly/version.rb
125
146
  - ruby-bitly.gemspec
@@ -140,16 +161,29 @@ required_ruby_version: !ruby/object:Gem::Requirement
140
161
  version: 2.0.0
141
162
  required_rubygems_version: !ruby/object:Gem::Requirement
142
163
  requirements:
143
- - - ">="
164
+ - - ">"
144
165
  - !ruby/object:Gem::Version
145
- version: '0'
166
+ version: 1.3.1
146
167
  requirements: []
147
- rubyforge_project:
148
- rubygems_version: 2.6.10
168
+ rubygems_version: 3.0.3
149
169
  signing_key:
150
170
  specification_version: 4
151
171
  summary: A simple bit.ly ruby client to shorten URLs, expand or get number of clicks
152
172
  on a bitlink
153
173
  test_files:
174
+ - fixtures/vcr_cassettes/expand_a_long_url_should_result_an_error.yml
175
+ - fixtures/vcr_cassettes/expand_a_short_url_to_it_long_url.yml
176
+ - fixtures/vcr_cassettes/get_clicks_by_short_url.yml
177
+ - fixtures/vcr_cassettes/get_clicks_by_short_url_without_ssl.yml
178
+ - fixtures/vcr_cassettes/shorten_bitly_url.yml
179
+ - fixtures/vcr_cassettes/shorten_long_url.yml
180
+ - fixtures/vcr_cassettes/shorten_long_url_with_preferred_domain.yml
181
+ - fixtures/vcr_cassettes/shorten_using_invalid_login.yml
182
+ - gemfiles/rest-client-2.0.1.gemfile
183
+ - gemfiles/rest-client-2.0.1.gemfile.lock
184
+ - gemfiles/rest-client-2.0.2.gemfile
185
+ - gemfiles/rest-client-2.0.2.gemfile.lock
186
+ - gemfiles/rest-client-2.1.0.rc1.gemfile
187
+ - gemfiles/rest-client-2.1.0.rc1.gemfile.lock
154
188
  - spec/ruby-bitly_spec.rb
155
189
  - spec/spec_helper.rb