git-trend 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -117,7 +117,7 @@ RSpec.describe GitTrend::Scraper do
117
117
  context 'with objective-c++ (including + sign)' do
118
118
  before do
119
119
  @scraper = Scraper.new
120
- stub_request_get("trending?l=#{language}")
120
+ stub_request_get("trending?l=objective-c%2B%2B")
121
121
  end
122
122
  let(:language) {'objective-c++'}
123
123
 
@@ -155,6 +155,134 @@ RSpec.describe GitTrend::Scraper do
155
155
  end
156
156
  end
157
157
  end
158
+
159
+ describe 'with -s option' do
160
+ context 'with weekly' do
161
+ before do
162
+ @scraper = Scraper.new
163
+ stub_request_get("trending?since=#{since}")
164
+ end
165
+ let(:since) {'weekly'}
166
+
167
+ it 'display daily ranking since weekly' do
168
+ res = <<-'EOS'.unindent
169
+ |No. Name Lang Star Fork
170
+ |--- -------------------------------------------------- ------------ ------ -----
171
+ | 1 numbbbbb/the-swift-programming-language-in-chinese JavaScript 2495 679
172
+ | 2 jessepollak/card CSS 2177 153
173
+ | 3 grant/swift-cheat-sheet JavaScript 1906 122
174
+ | 4 tictail/bounce.js CSS 1540 74
175
+ | 5 fullstackio/FlappySwift Swift 1125 401
176
+ | 6 GoogleCloudPlatform/kubernetes Go 1001 97
177
+ | 7 andlabs/ui Go 1004 36
178
+ | 8 facebook/Haxl Haskell 911 53
179
+ | 9 greatfire/wiki 683 196
180
+ | 10 interagent/http-api-design 757 42
181
+ | 11 prat0318/json_resume Ruby 717 50
182
+ | 12 lafikl/steady.js JavaScript 717 20
183
+ | 13 dotcloud/docker Go 617 119
184
+ | 14 dmytrodanylyk/circular-progress-button Java 608 69
185
+ | 15 docker/libswarm Go 606 20
186
+ | 16 watilde/beeplay JavaScript 594 23
187
+ | 17 austinzheng/swift-2048 Swift 518 116
188
+ | 18 Flolagale/mailin Python 543 14
189
+ | 19 hiphopapp/hiphop CoffeeScript 507 71
190
+ | 20 rpicard/explore-flask Python 454 27
191
+ | 21 addyosmani/psi JavaScript 443 8
192
+ | 22 twbs/bootstrap CSS 290 189
193
+ | 23 angular/angular.js JavaScript 268 194
194
+ | 24 mbostock/d3 JavaScript 307 113
195
+ | 25 maxpow4h/swiftz Swift 350 20
196
+ EOS
197
+ expect { @scraper.get(nil, since) }.to output(res).to_stdout
198
+ end
199
+ end
200
+
201
+ context 'with monthly' do
202
+ before do
203
+ @scraper = Scraper.new
204
+ stub_request_get("trending?since=#{since}")
205
+ end
206
+ let(:since) {'monthly'}
207
+
208
+ it 'display daily ranking since monthly' do
209
+ res = <<-'EOS'.unindent
210
+ |No. Name Lang Star Fork
211
+ |--- -------------------------------------------------- ------------ ------ -----
212
+ | 1 fullstackio/FlappySwift Swift 5753 1530
213
+ | 2 interagent/http-api-design 4735 214
214
+ | 3 jessepollak/card CSS 3944 257
215
+ | 4 numbbbbb/the-swift-programming-language-in-chinese JavaScript 3159 831
216
+ | 5 calmh/syncthing Go 2738 123
217
+ | 6 grant/swift-cheat-sheet JavaScript 2254 136
218
+ | 7 atom/atom CoffeeScript 1761 285
219
+ | 8 angular/angular.js JavaScript 1389 842
220
+ | 9 schneiderandre/popping Objective-C 1681 129
221
+ | 10 quilljs/quill CoffeeScript 1655 75
222
+ | 11 twbs/bootstrap CSS 1235 887
223
+ | 12 tictail/bounce.js CSS 1553 74
224
+ | 13 venmo/synx Ruby 1545 40
225
+ | 14 lovell/sharp JavaScript 1528 39
226
+ | 15 mbostock/d3 JavaScript 1101 424
227
+ | 16 facebook/jest JavaScript 1287 50
228
+ | 17 octobercms/october PHP 1190 192
229
+ | 18 buunguyen/octotree JavaScript 1228 90
230
+ | 19 felipernb/algorithms.js JavaScript 1206 90
231
+ | 20 strongloop/loopback JavaScript 1198 61
232
+ | 21 greatfire/wiki 1067 254
233
+ | 22 austinzheng/swift-2048 Swift 1083 218
234
+ | 23 dotcloud/docker Go 1057 269
235
+ | 24 julianshapiro/velocity JavaScript 1081 71
236
+ | 25 babun/babun Shell 1068 46
237
+ EOS
238
+ expect { @scraper.get(nil, since) }.to output(res).to_stdout
239
+ end
240
+ end
241
+ end
242
+
243
+ describe 'with -l and -s option' do
244
+ context 'with ruby and weekly' do
245
+ before do
246
+ @scraper = Scraper.new
247
+ stub_request_get("trending?l=#{language}&since=#{since}")
248
+ end
249
+ let(:language) {'ruby'}
250
+ let(:since) {'weekly'}
251
+
252
+ it 'display daily ranking since weekly' do
253
+ res = <<-'EOS'.unindent
254
+ |No. Name Lang Star Fork
255
+ |--- ---------------------------------------- ---------- ------ -----
256
+ | 1 prat0318/json_resume Ruby 717 50
257
+ | 2 dawn/dawn Ruby 349 11
258
+ | 3 newrelic/centurion Ruby 213 6
259
+ | 4 Homebrew/homebrew Ruby 107 74
260
+ | 5 rails/rails Ruby 100 74
261
+ | 6 code-mancers/invoker Ruby 97 2
262
+ | 7 CanCanCommunity/cancancan Ruby 92 5
263
+ | 8 etsy/nagios-herald Ruby 89 0
264
+ | 9 jekyll/jekyll Ruby 74 25
265
+ | 10 venmo/synx Ruby 82 2
266
+ | 11 interagent/prmd Ruby 74 5
267
+ | 12 discourse/discourse Ruby 64 22
268
+ | 13 gitlabhq/gitlabhq Ruby 56 21
269
+ | 14 vigetlabs/sass-json-vars Ruby 65 0
270
+ | 15 caskroom/homebrew-cask Ruby 49 30
271
+ | 16 mitchellh/vagrant Ruby 53 19
272
+ | 17 harrystech/seed_migration Ruby 57 0
273
+ | 18 twbs/bootstrap-sass Ruby 47 17
274
+ | 19 opal/opal Ruby 50 2
275
+ | 20 plataformatec/devise Ruby 39 22
276
+ | 21 sass/sass Ruby 43 12
277
+ | 22 nickjj/orats Ruby 46 2
278
+ | 23 chrishunt/desktop Ruby 39 3
279
+ | 24 chloerei/campo Ruby 35 9
280
+ | 25 jordansissel/fpm Ruby 35 4
281
+ EOS
282
+ expect { @scraper.get(language, since) }.to output(res).to_stdout
283
+ end
284
+ end
285
+ end
158
286
  end
159
287
 
160
288
  describe '#list_all_languages' do
@@ -351,7 +479,9 @@ RSpec.describe GitTrend::Scraper do
351
479
  |zimpl
352
480
  |
353
481
  |183 languages
354
- |you can get only selected language list with '-l' option
482
+ |you can get only selected language list with '-l' option.
483
+ |if languages is unknown, you can specify 'unkown'.
484
+ |
355
485
  EOS
356
486
  expect { @scraper.list_all_languages }.to output(res).to_stdout
357
487
  end
@@ -359,14 +489,16 @@ RSpec.describe GitTrend::Scraper do
359
489
  end
360
490
 
361
491
  private
362
- def stub_request_get(stub_file)
363
- params = stub_file.match(/trending\?(.+)/).to_a[1]
364
- url = "#{Scraper::BASE_URL}"
365
- url << "?#{CGI.escape(params)}" if params
366
- stub_request(:get, url).
492
+ def stub_request_get(stub_url)
493
+ url = Scraper::BASE_HOST.dup
494
+ url << "/#{stub_url}" if stub_url
495
+ uri = URI.parse(url)
496
+
497
+ stub_request(:get, uri).
367
498
  to_return(
368
499
  :status => 200,
369
500
  :headers => {content_type: 'text/html'},
370
- :body => load_http_stub(stub_file))
501
+ :body => load_http_stub(stub_url))
371
502
  end
503
+
372
504
  end
@@ -14,6 +14,9 @@
14
14
  # users commonly want.
15
15
  #
16
16
  # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
17
+ require 'coveralls'
18
+ Coveralls.wear!
19
+
17
20
  require 'rspec/its'
18
21
  require 'webmock/rspec'
19
22
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-trend
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - rochefort
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-09 00:00:00.000000000 Z
11
+ date: 2014-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: 1.18.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: coveralls
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
125
139
  description: cli based; show Trending repository on github
126
140
  email:
127
141
  - terasawan@gmail.com
@@ -130,6 +144,7 @@ executables:
130
144
  extensions: []
131
145
  extra_rdoc_files: []
132
146
  files:
147
+ - ".coveralls.yml"
133
148
  - ".gitignore"
134
149
  - ".rspec"
135
150
  - CHANGELOG.md
@@ -146,8 +161,11 @@ files:
146
161
  - lib/git_trend/scraper.rb
147
162
  - lib/git_trend/version.rb
148
163
  - spec/fixtures/trending
149
- - spec/fixtures/trending?l=objective-c++
164
+ - spec/fixtures/trending?l=objective-c%2B%2B
150
165
  - spec/fixtures/trending?l=ruby
166
+ - spec/fixtures/trending?l=ruby&since=weekly
167
+ - spec/fixtures/trending?since=monthly
168
+ - spec/fixtures/trending?since=weekly
151
169
  - spec/git_trend/scraper_spec.rb
152
170
  - spec/spec_helper.rb
153
171
  homepage: https://github.com/rochefort/github-trend
@@ -176,7 +194,10 @@ specification_version: 4
176
194
  summary: cli based; show Trending repository on github
177
195
  test_files:
178
196
  - spec/fixtures/trending
179
- - spec/fixtures/trending?l=objective-c++
197
+ - spec/fixtures/trending?l=objective-c%2B%2B
180
198
  - spec/fixtures/trending?l=ruby
199
+ - spec/fixtures/trending?l=ruby&since=weekly
200
+ - spec/fixtures/trending?since=monthly
201
+ - spec/fixtures/trending?since=weekly
181
202
  - spec/git_trend/scraper_spec.rb
182
203
  - spec/spec_helper.rb