git-trend 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +43 -0
- data/lib/git_trend.rb +2 -0
- data/lib/git_trend/cli.rb +7 -2
- data/lib/git_trend/ext.rb +1 -0
- data/lib/git_trend/ext/string.rb +29 -0
- data/lib/git_trend/rendering.rb +50 -17
- data/lib/git_trend/scraper.rb +2 -3
- data/lib/git_trend/version.rb +1 -1
- data/spec/git_trend/cli_spec.rb +474 -0
- data/spec/git_trend/scraper_spec.rb +2 -478
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb88dded6fe3fa21e8c0f12b9ee9b1d365446871
|
4
|
+
data.tar.gz: 536158a6cc332f6a476b9850950de30cd8a759af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a05d2b5baaa522177f9783c08449b81790a223799702891f9ff6f6252c1a59e5f2e25867917b15dfccc01cb1eaf398eeed44c644b1c5ae654d53f7ac45169756
|
7
|
+
data.tar.gz: 8b7288853a1c3841788b4620c4ac263b1c9f5361b1b6ef0d0ff71a6a5df12a785ad9782d612929c152b3ce4b7270eb010816ef2b7b241a59891ba58143c64abf
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -102,6 +102,49 @@ No. Name Lang Star Fork
|
|
102
102
|
25 jordansissel/fpm Ruby 6 0
|
103
103
|
```
|
104
104
|
|
105
|
+
### weekly/monthly trending
|
106
|
+
|
107
|
+
git trend -s weekly
|
108
|
+
git trend -s w
|
109
|
+
|
110
|
+
or
|
111
|
+
|
112
|
+
git trend -s monthly
|
113
|
+
git trend -s m
|
114
|
+
|
115
|
+
e.g.:
|
116
|
+
|
117
|
+
```
|
118
|
+
$ git trend -s weekly
|
119
|
+
No. Name Lang Star Fork
|
120
|
+
--- -------------------------------------------------- ---------- ------ -----
|
121
|
+
1 numbbbbb/the-swift-programming-language-in-chinese JavaScript 4161 1201
|
122
|
+
2 justjavac/Google-IPs 1499 650
|
123
|
+
3 tictail/bounce.js CSS 1779 90
|
124
|
+
4 grant/swift-cheat-sheet JavaScript 1432 109
|
125
|
+
5 GoogleCloudPlatform/kubernetes Go 1224 124
|
126
|
+
6 jessepollak/card CSS 1109 88
|
127
|
+
7 facebook/Haxl Haskell 1003 62
|
128
|
+
8 greatfire/wiki 845 252
|
129
|
+
9 docker/libchan Go 945 34
|
130
|
+
10 lafikl/steady.js JavaScript 783 21
|
131
|
+
11 dotcloud/docker Go 660 137
|
132
|
+
12 fullstackio/FlappySwift Swift 603 233
|
133
|
+
13 docker/libswarm Go 691 27
|
134
|
+
14 uutils/coreutils Rust 610 33
|
135
|
+
15 watilde/beeplay JavaScript 542 24
|
136
|
+
16 dmytrodanylyk/circular-progress-button Java 510 63
|
137
|
+
17 mooz/percol Python 511 15
|
138
|
+
18 fengsp/plan Python 496 25
|
139
|
+
19 interagent/http-api-design 481 30
|
140
|
+
20 rpicard/explore-flask Python 477 31
|
141
|
+
21 jdorn/json-editor JavaScript 387 28
|
142
|
+
22 twbs/bootstrap CSS 288 200
|
143
|
+
23 google/cadvisor Go 371 23
|
144
|
+
24 irssi/irssi C 351 27
|
145
|
+
25 mbostock/d3 JavaScript 288 132
|
146
|
+
```
|
147
|
+
|
105
148
|
### show languages
|
106
149
|
|
107
150
|
git trend all_languages
|
data/lib/git_trend.rb
CHANGED
data/lib/git_trend/cli.rb
CHANGED
@@ -2,6 +2,8 @@ require 'thor'
|
|
2
2
|
|
3
3
|
module GitTrend
|
4
4
|
class CLI < Thor
|
5
|
+
include GitTrend::Rendering
|
6
|
+
|
5
7
|
map '-v' => :version,
|
6
8
|
'--version' => :version
|
7
9
|
|
@@ -15,9 +17,11 @@ module GitTrend
|
|
15
17
|
desc :list, '[List] Trending repository on github'
|
16
18
|
option :list, aliases:'-l', required: false
|
17
19
|
option :since, aliases:'-s', required: false
|
20
|
+
option :description, aliases:'-d', required: false
|
18
21
|
def list
|
19
22
|
scraper = Scraper.new
|
20
|
-
scraper.get(options[:list], options[:since])
|
23
|
+
projects = scraper.get(options[:list], options[:since])
|
24
|
+
render(projects, !!options[:description])
|
21
25
|
rescue => e
|
22
26
|
say "An unexpected #{e.class} has occurred.", :red
|
23
27
|
say e.message
|
@@ -26,7 +30,8 @@ module GitTrend
|
|
26
30
|
desc :all_languages, 'Show selectable languages'
|
27
31
|
def all_languages
|
28
32
|
scraper = Scraper.new
|
29
|
-
scraper.list_all_languages
|
33
|
+
languages = scraper.list_all_languages
|
34
|
+
render_all_languages(languages)
|
30
35
|
end
|
31
36
|
end
|
32
37
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'git_trend/ext/string'
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class String
|
2
|
+
def mb_width
|
3
|
+
each_char.inject(0) { |sum, c| sum += c.ascii_only? ? 1 : 2 }
|
4
|
+
end
|
5
|
+
|
6
|
+
def mb_slice(width)
|
7
|
+
return '' if empty?
|
8
|
+
|
9
|
+
max_size = width - 3 # 3 is '...' size.
|
10
|
+
extraction_size = 0
|
11
|
+
extraction = ''
|
12
|
+
each_char do |c|
|
13
|
+
char_size = c.ascii_only? ? 1 : 2
|
14
|
+
if extraction_size + char_size > max_size
|
15
|
+
extraction << '...'
|
16
|
+
break
|
17
|
+
end
|
18
|
+
extraction_size += char_size
|
19
|
+
extraction << c
|
20
|
+
end
|
21
|
+
extraction
|
22
|
+
end
|
23
|
+
|
24
|
+
def mb_ljust(width, padding=' ')
|
25
|
+
padding_size = [0, width - mb_width].max
|
26
|
+
self + padding * padding_size
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
data/lib/git_trend/rendering.rb
CHANGED
@@ -1,13 +1,16 @@
|
|
1
1
|
module GitTrend
|
2
2
|
module Rendering
|
3
|
-
# 'No.', 'Name', 'Lang', 'Star', 'Fork'
|
4
|
-
DEFAULT_RULED_LINE_SIZE = [3, 40, 10, 6, 5]
|
5
3
|
|
6
4
|
def self.included(base)
|
7
5
|
base.extend(self)
|
8
6
|
end
|
9
7
|
|
10
|
-
|
8
|
+
# header columns:
|
9
|
+
# 'No.', 'Name', 'Lang', 'Star', 'Fork', ['Description']
|
10
|
+
DEFAULT_RULED_LINE_SIZE = [3, 40, 10, 6, 5]
|
11
|
+
|
12
|
+
def render(projects, describable=false)
|
13
|
+
@describable = describable
|
11
14
|
set_ruled_line_size(projects)
|
12
15
|
render_to_header
|
13
16
|
render_to_body(projects)
|
@@ -28,34 +31,64 @@ module GitTrend
|
|
28
31
|
end
|
29
32
|
|
30
33
|
def set_ruled_line_size(projects)
|
34
|
+
@ruled_line_size = DEFAULT_RULED_LINE_SIZE.dup
|
31
35
|
max_name_size = max_size_of(projects, :name)
|
32
|
-
if max_name_size >
|
33
|
-
|
36
|
+
if max_name_size > @ruled_line_size[1]
|
37
|
+
@ruled_line_size[1] = max_name_size
|
34
38
|
end
|
35
39
|
|
36
40
|
max_lang_size = max_size_of(projects, :lang)
|
37
|
-
if max_lang_size >
|
38
|
-
|
41
|
+
if max_lang_size > @ruled_line_size[2]
|
42
|
+
@ruled_line_size[2] = max_lang_size
|
39
43
|
end
|
40
|
-
end
|
41
44
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
45
|
+
if @describable
|
46
|
+
terminal_width, _terminal_height = detect_terminal_size
|
47
|
+
description_width = terminal_width - @ruled_line_size.inject(&:+) - @ruled_line_size.size
|
48
|
+
@ruled_line_size << description_width
|
49
|
+
end
|
46
50
|
end
|
47
51
|
|
48
52
|
def render_to_header
|
49
|
-
|
50
|
-
|
51
|
-
|
53
|
+
f = @ruled_line_size
|
54
|
+
if @describable
|
55
|
+
fmt = "%#{f[0]}s %-#{f[1]}s %-#{f[2]}s %#{f[3]}s %#{f[4]}s %-#{f[5]}s"
|
56
|
+
else
|
57
|
+
fmt = "%#{f[0]}s %-#{f[1]}s %-#{f[2]}s %#{f[3]}s %#{f[4]}s"
|
52
58
|
end
|
59
|
+
header = ['No.', 'Name', 'Lang', 'Star', 'Fork']
|
60
|
+
header << 'Description' if @describable
|
61
|
+
puts fmt % header
|
62
|
+
puts fmt % @ruled_line_size.map{ |f| '-'*f }
|
53
63
|
end
|
54
64
|
|
55
65
|
def render_to_body(projects)
|
56
|
-
|
57
|
-
|
66
|
+
f = @ruled_line_size
|
67
|
+
fmt = "%#{f[0]}s %-#{f[1]}s %-#{f[2]}s %#{f[3]}s %#{f[4]}s"
|
68
|
+
projects.each_with_index do |project, i|
|
69
|
+
result = fmt % [i+1, project.to_a].flatten
|
70
|
+
result << " " + project.description.mb_slice(f.last).mb_ljust(f.last) if @describable
|
71
|
+
puts result
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def command_exists?(command)
|
76
|
+
ENV['PATH'].split(File::PATH_SEPARATOR).any? { |d| File.exists? File.join(d, command) }
|
77
|
+
end
|
78
|
+
|
79
|
+
# https://github.com/cldwalker/hirb/blob/master/lib/hirb/util.rb#L61-71
|
80
|
+
def detect_terminal_size
|
81
|
+
if (ENV['COLUMNS'] =~ /^\d+$/) && (ENV['LINES'] =~ /^\d+$/)
|
82
|
+
[ENV['COLUMNS'].to_i, ENV['LINES'].to_i]
|
83
|
+
elsif (RUBY_PLATFORM =~ /java/ || (!STDIN.tty? && ENV['TERM'])) && command_exists?('tput')
|
84
|
+
[`tput cols`.to_i, `tput lines`.to_i]
|
85
|
+
elsif STDIN.tty? && command_exists?('stty')
|
86
|
+
`stty size`.scan(/\d+/).map { |s| s.to_i }.reverse
|
87
|
+
else
|
88
|
+
nil
|
58
89
|
end
|
90
|
+
rescue Exception => e
|
91
|
+
nil
|
59
92
|
end
|
60
93
|
end
|
61
94
|
end
|
data/lib/git_trend/scraper.rb
CHANGED
@@ -3,7 +3,6 @@ require 'addressable/uri'
|
|
3
3
|
|
4
4
|
module GitTrend
|
5
5
|
class Scraper
|
6
|
-
include GitTrend::Rendering
|
7
6
|
|
8
7
|
BASE_HOST = 'https://github.com'
|
9
8
|
BASE_URL = "#{BASE_HOST}/trending"
|
@@ -31,7 +30,7 @@ module GitTrend
|
|
31
30
|
|
32
31
|
projects << project
|
33
32
|
end
|
34
|
-
|
33
|
+
projects
|
35
34
|
end
|
36
35
|
|
37
36
|
def list_all_languages
|
@@ -43,7 +42,7 @@ module GitTrend
|
|
43
42
|
language = href.match(/github.com\/trending\?l=(.+)/).to_a[1]
|
44
43
|
languages << CGI.unescape(language) if language
|
45
44
|
end
|
46
|
-
|
45
|
+
languages
|
47
46
|
end
|
48
47
|
|
49
48
|
private
|
data/lib/git_trend/version.rb
CHANGED
@@ -0,0 +1,474 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include GitTrend
|
4
|
+
RSpec.describe GitTrend::CLI do
|
5
|
+
|
6
|
+
describe '#list' do
|
7
|
+
before do
|
8
|
+
@cli = CLI.new
|
9
|
+
end
|
10
|
+
|
11
|
+
context 'with no option' do
|
12
|
+
before do
|
13
|
+
stub_request_get('trending')
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'display daily ranking' do
|
17
|
+
res = <<-'EOS'.unindent
|
18
|
+
|No. Name Lang Star Fork
|
19
|
+
|--- -------------------------------------------------- ------------ ------ -----
|
20
|
+
| 1 prat0318/json_resume Ruby 264 15
|
21
|
+
| 2 andlabs/ui Go 185 8
|
22
|
+
| 3 jessepollak/card CSS 174 9
|
23
|
+
| 4 fullstackio/FlappySwift Swift 148 44
|
24
|
+
| 5 grant/swift-cheat-sheet 153 13
|
25
|
+
| 6 Flolagale/mailin Python 155 3
|
26
|
+
| 7 numbbbbb/the-swift-programming-language-in-chinese JavaScript 120 31
|
27
|
+
| 8 hippyvm/hippyvm PHP 113 1
|
28
|
+
| 9 neovim/neovim C 83 8
|
29
|
+
| 10 hiphopapp/hiphop CoffeeScript 77 8
|
30
|
+
| 11 interagent/http-api-design 78 4
|
31
|
+
| 12 austinzheng/swift-2048 Swift 69 16
|
32
|
+
| 13 mdznr/What-s-New Objective-C 72 2
|
33
|
+
| 14 daneden/animate.css CSS 65 6
|
34
|
+
| 15 davidmerfield/randomColor JavaScript 66 3
|
35
|
+
| 16 dawn/dawn Ruby 62 2
|
36
|
+
| 17 greatfire/wiki 54 9
|
37
|
+
| 18 swift-jp/swift-guide CSS 45 9
|
38
|
+
| 19 addyosmani/psi JavaScript 49 0
|
39
|
+
| 20 mtford90/silk Python 47 0
|
40
|
+
| 21 agaue/agaue Go 47 0
|
41
|
+
| 22 mentionapp/mntpulltoreact Objective-C 46 1
|
42
|
+
| 23 mikepenz/AboutLibraries Java 45 0
|
43
|
+
| 24 PistonDevelopers/piston-workspace Shell 45 0
|
44
|
+
| 25 maxpow4h/swiftz Swift 43 1
|
45
|
+
EOS
|
46
|
+
expect { @cli.list }.to output(res).to_stdout
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe 'with -l option' do
|
51
|
+
context 'with ruby' do
|
52
|
+
before do
|
53
|
+
stub_request_get("trending?l=#{language}")
|
54
|
+
end
|
55
|
+
let(:language) {'ruby'}
|
56
|
+
|
57
|
+
it 'display daily ranking by language' do
|
58
|
+
res = <<-'EOS'.unindent
|
59
|
+
|No. Name Lang Star Fork
|
60
|
+
|--- ---------------------------------------- ---------- ------ -----
|
61
|
+
| 1 prat0318/json_resume Ruby 412 27
|
62
|
+
| 2 dawn/dawn Ruby 57 2
|
63
|
+
| 3 Homebrew/homebrew Ruby 15 7
|
64
|
+
| 4 etsy/nagios-herald Ruby 18 0
|
65
|
+
| 5 jekyll/jekyll Ruby 14 4
|
66
|
+
| 6 opf/openproject Ruby 11 0
|
67
|
+
| 7 caskroom/homebrew-cask Ruby 9 3
|
68
|
+
| 8 rails/rails Ruby 6 7
|
69
|
+
| 9 interagent/prmd Ruby 9 0
|
70
|
+
| 10 mitchellh/vagrant Ruby 8 2
|
71
|
+
| 11 discourse/discourse Ruby 7 3
|
72
|
+
| 12 CanCanCommunity/cancancan Ruby 7 1
|
73
|
+
| 13 venmo/synx Ruby 7 0
|
74
|
+
| 14 laravel/homestead Shell 6 2
|
75
|
+
| 15 alexreisner/geocoder Ruby 6 0
|
76
|
+
| 16 visionmedia/commander Ruby 5 0
|
77
|
+
| 17 CocoaPods/Specs Ruby 0 3
|
78
|
+
| 18 gitlabhq/gitlabhq Ruby 0 2
|
79
|
+
| 19 puppetlabs/puppetlabs-apache Ruby 0 2
|
80
|
+
| 20 gitlabhq/gitlab-recipes Ruby 0 2
|
81
|
+
| 21 Mixd/wp-deploy Ruby 0 1
|
82
|
+
| 22 svenfuchs/rails-i18n Ruby 0 1
|
83
|
+
| 23 Homebrew/homebrew-php Ruby 0 1
|
84
|
+
| 24 sferik/twitter Ruby 0 1
|
85
|
+
| 25 rightscale/rightscale_cookbooks Ruby 0 1
|
86
|
+
EOS
|
87
|
+
expect { @cli.invoke(:list, [], {list: language}) }.to output(res).to_stdout
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
context 'with objective-c++ (including + sign)' do
|
92
|
+
before do
|
93
|
+
stub_request_get("trending?l=objective-c%2B%2B")
|
94
|
+
end
|
95
|
+
let(:language) {'objective-c++'}
|
96
|
+
|
97
|
+
it 'display daily ranking by language' do
|
98
|
+
res = <<-'EOS'.unindent
|
99
|
+
|No. Name Lang Star Fork
|
100
|
+
|--- ---------------------------------------- ------------- ------ -----
|
101
|
+
| 1 facebook/pop Objective-C++ 0 0
|
102
|
+
| 2 johnno1962/Xtrace Objective-C++ 0 0
|
103
|
+
| 3 pivotal/cedar Objective-C++ 0 0
|
104
|
+
| 4 wetube/bitcloud Objective-C++ 0 0
|
105
|
+
| 5 jerols/PopTut Objective-C++ 0 0
|
106
|
+
| 6 otaviocc/OCBorghettiView Objective-C++ 0 0
|
107
|
+
| 7 droolsjbpm/optaplanner Objective-C++ 0 0
|
108
|
+
| 8 otaviocc/NHCalendarActivity Objective-C++ 0 0
|
109
|
+
| 9 callmeed/pop-playground Objective-C++ 0 0
|
110
|
+
| 10 jxd001/POPdemo Objective-C++ 0 0
|
111
|
+
| 11 couchdeveloper/RXPromise Objective-C++ 0 0
|
112
|
+
| 12 johnno1962/XprobePlugin Objective-C++ 0 0
|
113
|
+
| 13 openpeer/opios Objective-C++ 0 0
|
114
|
+
| 14 pivotal/PivotalCoreKit Objective-C++ 0 0
|
115
|
+
| 15 rbaumbach/Swizzlean Objective-C++ 0 0
|
116
|
+
| 16 andreacremaschi/ShapeKit Objective-C++ 0 0
|
117
|
+
| 17 Smartype/iOS_VPNPlugIn Objective-C++ 0 0
|
118
|
+
| 18 humblehacker/AutoLayoutDSL Objective-C++ 0 0
|
119
|
+
| 19 hoddez/FFTAccelerate Objective-C++ 0 0
|
120
|
+
| 20 armadillu/ofxPanZoom Objective-C++ 0 0
|
121
|
+
| 21 dodikk/CsvToSqlite Objective-C++ 0 0
|
122
|
+
| 22 hbang/TypeStatus Objective-C++ 0 0
|
123
|
+
| 23 trentbrooks/ofxCoreMotion Objective-C++ 0 0
|
124
|
+
| 24 Yonsm/CeleWare Objective-C++ 0 0
|
125
|
+
| 25 ccrma/miniAudicle Objective-C++ 0 0
|
126
|
+
EOS
|
127
|
+
expect { @cli.invoke(:list, [], {list: language}) }.to output(res).to_stdout
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
describe 'with -s option' do
|
133
|
+
context 'with weekly' do
|
134
|
+
before do
|
135
|
+
stub_request_get("trending?since=#{since}")
|
136
|
+
end
|
137
|
+
let(:since) {'weekly'}
|
138
|
+
|
139
|
+
it 'display daily ranking since weekly' do
|
140
|
+
res = <<-'EOS'.unindent
|
141
|
+
|No. Name Lang Star Fork
|
142
|
+
|--- -------------------------------------------------- ------------ ------ -----
|
143
|
+
| 1 numbbbbb/the-swift-programming-language-in-chinese JavaScript 2495 679
|
144
|
+
| 2 jessepollak/card CSS 2177 153
|
145
|
+
| 3 grant/swift-cheat-sheet JavaScript 1906 122
|
146
|
+
| 4 tictail/bounce.js CSS 1540 74
|
147
|
+
| 5 fullstackio/FlappySwift Swift 1125 401
|
148
|
+
| 6 GoogleCloudPlatform/kubernetes Go 1001 97
|
149
|
+
| 7 andlabs/ui Go 1004 36
|
150
|
+
| 8 facebook/Haxl Haskell 911 53
|
151
|
+
| 9 greatfire/wiki 683 196
|
152
|
+
| 10 interagent/http-api-design 757 42
|
153
|
+
| 11 prat0318/json_resume Ruby 717 50
|
154
|
+
| 12 lafikl/steady.js JavaScript 717 20
|
155
|
+
| 13 dotcloud/docker Go 617 119
|
156
|
+
| 14 dmytrodanylyk/circular-progress-button Java 608 69
|
157
|
+
| 15 docker/libswarm Go 606 20
|
158
|
+
| 16 watilde/beeplay JavaScript 594 23
|
159
|
+
| 17 austinzheng/swift-2048 Swift 518 116
|
160
|
+
| 18 Flolagale/mailin Python 543 14
|
161
|
+
| 19 hiphopapp/hiphop CoffeeScript 507 71
|
162
|
+
| 20 rpicard/explore-flask Python 454 27
|
163
|
+
| 21 addyosmani/psi JavaScript 443 8
|
164
|
+
| 22 twbs/bootstrap CSS 290 189
|
165
|
+
| 23 angular/angular.js JavaScript 268 194
|
166
|
+
| 24 mbostock/d3 JavaScript 307 113
|
167
|
+
| 25 maxpow4h/swiftz Swift 350 20
|
168
|
+
EOS
|
169
|
+
expect { @cli.invoke(:list, [], {since: since}) }.to output(res).to_stdout
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
context 'with monthly' do
|
174
|
+
before do
|
175
|
+
stub_request_get("trending?since=#{since}")
|
176
|
+
end
|
177
|
+
let(:since) {'monthly'}
|
178
|
+
|
179
|
+
it 'display daily ranking since monthly' do
|
180
|
+
res = <<-'EOS'.unindent
|
181
|
+
|No. Name Lang Star Fork
|
182
|
+
|--- -------------------------------------------------- ------------ ------ -----
|
183
|
+
| 1 fullstackio/FlappySwift Swift 5753 1530
|
184
|
+
| 2 interagent/http-api-design 4735 214
|
185
|
+
| 3 jessepollak/card CSS 3944 257
|
186
|
+
| 4 numbbbbb/the-swift-programming-language-in-chinese JavaScript 3159 831
|
187
|
+
| 5 calmh/syncthing Go 2738 123
|
188
|
+
| 6 grant/swift-cheat-sheet JavaScript 2254 136
|
189
|
+
| 7 atom/atom CoffeeScript 1761 285
|
190
|
+
| 8 angular/angular.js JavaScript 1389 842
|
191
|
+
| 9 schneiderandre/popping Objective-C 1681 129
|
192
|
+
| 10 quilljs/quill CoffeeScript 1655 75
|
193
|
+
| 11 twbs/bootstrap CSS 1235 887
|
194
|
+
| 12 tictail/bounce.js CSS 1553 74
|
195
|
+
| 13 venmo/synx Ruby 1545 40
|
196
|
+
| 14 lovell/sharp JavaScript 1528 39
|
197
|
+
| 15 mbostock/d3 JavaScript 1101 424
|
198
|
+
| 16 facebook/jest JavaScript 1287 50
|
199
|
+
| 17 octobercms/october PHP 1190 192
|
200
|
+
| 18 buunguyen/octotree JavaScript 1228 90
|
201
|
+
| 19 felipernb/algorithms.js JavaScript 1206 90
|
202
|
+
| 20 strongloop/loopback JavaScript 1198 61
|
203
|
+
| 21 greatfire/wiki 1067 254
|
204
|
+
| 22 austinzheng/swift-2048 Swift 1083 218
|
205
|
+
| 23 dotcloud/docker Go 1057 269
|
206
|
+
| 24 julianshapiro/velocity JavaScript 1081 71
|
207
|
+
| 25 babun/babun Shell 1068 46
|
208
|
+
EOS
|
209
|
+
expect { @cli.invoke(:list, [], {since: since}) }.to output(res).to_stdout
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
describe 'with -l and -s option' do
|
215
|
+
context 'with ruby and weekly' do
|
216
|
+
before do
|
217
|
+
stub_request_get("trending?l=#{language}&since=#{since}")
|
218
|
+
end
|
219
|
+
let(:language) {'ruby'}
|
220
|
+
let(:since) {'weekly'}
|
221
|
+
|
222
|
+
it 'display daily ranking since weekly' do
|
223
|
+
res = <<-'EOS'.unindent
|
224
|
+
|No. Name Lang Star Fork
|
225
|
+
|--- ---------------------------------------- ---------- ------ -----
|
226
|
+
| 1 prat0318/json_resume Ruby 717 50
|
227
|
+
| 2 dawn/dawn Ruby 349 11
|
228
|
+
| 3 newrelic/centurion Ruby 213 6
|
229
|
+
| 4 Homebrew/homebrew Ruby 107 74
|
230
|
+
| 5 rails/rails Ruby 100 74
|
231
|
+
| 6 code-mancers/invoker Ruby 97 2
|
232
|
+
| 7 CanCanCommunity/cancancan Ruby 92 5
|
233
|
+
| 8 etsy/nagios-herald Ruby 89 0
|
234
|
+
| 9 jekyll/jekyll Ruby 74 25
|
235
|
+
| 10 venmo/synx Ruby 82 2
|
236
|
+
| 11 interagent/prmd Ruby 74 5
|
237
|
+
| 12 discourse/discourse Ruby 64 22
|
238
|
+
| 13 gitlabhq/gitlabhq Ruby 56 21
|
239
|
+
| 14 vigetlabs/sass-json-vars Ruby 65 0
|
240
|
+
| 15 caskroom/homebrew-cask Ruby 49 30
|
241
|
+
| 16 mitchellh/vagrant Ruby 53 19
|
242
|
+
| 17 harrystech/seed_migration Ruby 57 0
|
243
|
+
| 18 twbs/bootstrap-sass Ruby 47 17
|
244
|
+
| 19 opal/opal Ruby 50 2
|
245
|
+
| 20 plataformatec/devise Ruby 39 22
|
246
|
+
| 21 sass/sass Ruby 43 12
|
247
|
+
| 22 nickjj/orats Ruby 46 2
|
248
|
+
| 23 chrishunt/desktop Ruby 39 3
|
249
|
+
| 24 chloerei/campo Ruby 35 9
|
250
|
+
| 25 jordansissel/fpm Ruby 35 4
|
251
|
+
EOS
|
252
|
+
expect { @cli.invoke(:list, [], {list: language, since: since}) }.to output(res).to_stdout
|
253
|
+
end
|
254
|
+
end
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
describe '#all_languages' do
|
259
|
+
before do
|
260
|
+
@cli = CLI.new
|
261
|
+
stub_request_get('trending')
|
262
|
+
end
|
263
|
+
|
264
|
+
context 'with no option' do
|
265
|
+
it 'display daily ranking' do
|
266
|
+
res = <<-'EOS'.unindent
|
267
|
+
|abap
|
268
|
+
|as3
|
269
|
+
|ada
|
270
|
+
|agda
|
271
|
+
|alloy
|
272
|
+
|antlr
|
273
|
+
|apex
|
274
|
+
|applescript
|
275
|
+
|arc
|
276
|
+
|arduino
|
277
|
+
|aspx-vb
|
278
|
+
|aspectj
|
279
|
+
|nasm
|
280
|
+
|ats
|
281
|
+
|augeas
|
282
|
+
|autohotkey
|
283
|
+
|autoit
|
284
|
+
|awk
|
285
|
+
|blitzbasic
|
286
|
+
|bluespec
|
287
|
+
|boo
|
288
|
+
|brightscript
|
289
|
+
|bro
|
290
|
+
|c
|
291
|
+
|csharp
|
292
|
+
|cpp
|
293
|
+
|ceylon
|
294
|
+
|cirru
|
295
|
+
|clean
|
296
|
+
|clips
|
297
|
+
|clojure
|
298
|
+
|cobol
|
299
|
+
|coffeescript
|
300
|
+
|cfm
|
301
|
+
|common-lisp
|
302
|
+
|coq
|
303
|
+
|crystal
|
304
|
+
|css
|
305
|
+
|cuda
|
306
|
+
|d
|
307
|
+
|dart
|
308
|
+
|dcpu-16-asm
|
309
|
+
|dm
|
310
|
+
|dogescript
|
311
|
+
|dot
|
312
|
+
|dylan
|
313
|
+
|e
|
314
|
+
|ec
|
315
|
+
|eiffel
|
316
|
+
|elixir
|
317
|
+
|elm
|
318
|
+
|emacs-lisp
|
319
|
+
|erlang
|
320
|
+
|fsharp
|
321
|
+
|factor
|
322
|
+
|fancy
|
323
|
+
|fantom
|
324
|
+
|flux
|
325
|
+
|forth
|
326
|
+
|fortran
|
327
|
+
|frege
|
328
|
+
|game-maker-language
|
329
|
+
|gams
|
330
|
+
|gap
|
331
|
+
|glyph
|
332
|
+
|gnuplot
|
333
|
+
|go
|
334
|
+
|gosu
|
335
|
+
|grammatical-framework
|
336
|
+
|groovy
|
337
|
+
|harbour
|
338
|
+
|haskell
|
339
|
+
|haxe
|
340
|
+
|hy
|
341
|
+
|idl
|
342
|
+
|idris
|
343
|
+
|inform-7
|
344
|
+
|io
|
345
|
+
|ioke
|
346
|
+
|j
|
347
|
+
|java
|
348
|
+
|javascript
|
349
|
+
|jsoniq
|
350
|
+
|julia
|
351
|
+
|kotlin
|
352
|
+
|krl
|
353
|
+
|lasso
|
354
|
+
|livescript
|
355
|
+
|logos
|
356
|
+
|logtalk
|
357
|
+
|lua
|
358
|
+
|m
|
359
|
+
|markdown
|
360
|
+
|mathematica
|
361
|
+
|matlab
|
362
|
+
|max/msp
|
363
|
+
|mercury
|
364
|
+
|ruby
|
365
|
+
|monkey
|
366
|
+
|moocode
|
367
|
+
|moonscript
|
368
|
+
|nemerle
|
369
|
+
|nesc
|
370
|
+
|netlogo
|
371
|
+
|nimrod
|
372
|
+
|nu
|
373
|
+
|objective-c
|
374
|
+
|objective-c++
|
375
|
+
|objective-j
|
376
|
+
|ocaml
|
377
|
+
|omgrofl
|
378
|
+
|ooc
|
379
|
+
|opa
|
380
|
+
|openedge-abl
|
381
|
+
|oxygene
|
382
|
+
|pan
|
383
|
+
|parrot
|
384
|
+
|pascal
|
385
|
+
|pawn
|
386
|
+
|perl
|
387
|
+
|perl6
|
388
|
+
|php
|
389
|
+
|pike
|
390
|
+
|pogoscript
|
391
|
+
|powershell
|
392
|
+
|processing
|
393
|
+
|prolog
|
394
|
+
|propeller-spin
|
395
|
+
|puppet
|
396
|
+
|pure-data
|
397
|
+
|purescript
|
398
|
+
|python
|
399
|
+
|r
|
400
|
+
|racket
|
401
|
+
|ragel-in-ruby-host
|
402
|
+
|rdoc
|
403
|
+
|realbasic
|
404
|
+
|rebol
|
405
|
+
|red
|
406
|
+
|robotframework
|
407
|
+
|rouge
|
408
|
+
|ruby
|
409
|
+
|rust
|
410
|
+
|sas
|
411
|
+
|scala
|
412
|
+
|scheme
|
413
|
+
|scilab
|
414
|
+
|self
|
415
|
+
|bash
|
416
|
+
|shellsession
|
417
|
+
|shen
|
418
|
+
|slash
|
419
|
+
|smalltalk
|
420
|
+
|sourcepawn
|
421
|
+
|sql
|
422
|
+
|squirrel
|
423
|
+
|standard-ml
|
424
|
+
|stata
|
425
|
+
|supercollider
|
426
|
+
|swift
|
427
|
+
|systemverilog
|
428
|
+
|tcl
|
429
|
+
|tex
|
430
|
+
|turing
|
431
|
+
|txl
|
432
|
+
|typescript
|
433
|
+
|unrealscript
|
434
|
+
|vala
|
435
|
+
|verilog
|
436
|
+
|vhdl
|
437
|
+
|vim
|
438
|
+
|visual-basic
|
439
|
+
|volt
|
440
|
+
|wisp
|
441
|
+
|xbase
|
442
|
+
|xc
|
443
|
+
|xml
|
444
|
+
|xproc
|
445
|
+
|xquery
|
446
|
+
|xslt
|
447
|
+
|xtend
|
448
|
+
|zephir
|
449
|
+
|zimpl
|
450
|
+
|
|
451
|
+
|183 languages
|
452
|
+
|you can get only selected language list with '-l' option.
|
453
|
+
|if languages is unknown, you can specify 'unkown'.
|
454
|
+
|
|
455
|
+
EOS
|
456
|
+
expect { @cli.all_languages }.to output(res).to_stdout
|
457
|
+
end
|
458
|
+
end
|
459
|
+
end
|
460
|
+
|
461
|
+
private
|
462
|
+
def stub_request_get(stub_url)
|
463
|
+
url = Scraper::BASE_HOST.dup
|
464
|
+
url << "/#{stub_url}" if stub_url
|
465
|
+
uri = URI.parse(url)
|
466
|
+
|
467
|
+
stub_request(:get, uri).
|
468
|
+
to_return(
|
469
|
+
:status => 200,
|
470
|
+
:headers => {content_type: 'text/html'},
|
471
|
+
:body => load_http_stub(stub_url))
|
472
|
+
end
|
473
|
+
|
474
|
+
end
|
@@ -16,489 +16,13 @@ RSpec.describe GitTrend::Scraper do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
describe '#get' do
|
19
|
-
after do
|
20
|
-
# reset initialize
|
21
|
-
# warning measure: already initialized constant
|
22
|
-
[3, 40, 10, 6, 5].each_with_index { |n, i| Rendering::DEFAULT_RULED_LINE_SIZE[i] = n }
|
23
|
-
end
|
24
|
-
|
25
19
|
context 'when a network error occurred' do
|
26
20
|
before do
|
21
|
+
@scraper = Scraper.new
|
27
22
|
stub_request(:get, Scraper::BASE_URL).
|
28
23
|
to_return(:status => 500, :body => '[]')
|
29
24
|
end
|
30
|
-
|
31
|
-
it { expect{ @scraper.get(language) }.to raise_error(Exception) }
|
32
|
-
end
|
33
|
-
|
34
|
-
context 'with no option' do
|
35
|
-
before do
|
36
|
-
@scraper = Scraper.new
|
37
|
-
stub_request_get('trending')
|
38
|
-
end
|
39
|
-
let(:language) {nil}
|
40
|
-
|
41
|
-
it 'display daily ranking' do
|
42
|
-
res = <<-'EOS'.unindent
|
43
|
-
|No. Name Lang Star Fork
|
44
|
-
|--- -------------------------------------------------- ------------ ------ -----
|
45
|
-
| 1 prat0318/json_resume Ruby 264 15
|
46
|
-
| 2 andlabs/ui Go 185 8
|
47
|
-
| 3 jessepollak/card CSS 174 9
|
48
|
-
| 4 fullstackio/FlappySwift Swift 148 44
|
49
|
-
| 5 grant/swift-cheat-sheet 153 13
|
50
|
-
| 6 Flolagale/mailin Python 155 3
|
51
|
-
| 7 numbbbbb/the-swift-programming-language-in-chinese JavaScript 120 31
|
52
|
-
| 8 hippyvm/hippyvm PHP 113 1
|
53
|
-
| 9 neovim/neovim C 83 8
|
54
|
-
| 10 hiphopapp/hiphop CoffeeScript 77 8
|
55
|
-
| 11 interagent/http-api-design 78 4
|
56
|
-
| 12 austinzheng/swift-2048 Swift 69 16
|
57
|
-
| 13 mdznr/What-s-New Objective-C 72 2
|
58
|
-
| 14 daneden/animate.css CSS 65 6
|
59
|
-
| 15 davidmerfield/randomColor JavaScript 66 3
|
60
|
-
| 16 dawn/dawn Ruby 62 2
|
61
|
-
| 17 greatfire/wiki 54 9
|
62
|
-
| 18 swift-jp/swift-guide CSS 45 9
|
63
|
-
| 19 addyosmani/psi JavaScript 49 0
|
64
|
-
| 20 mtford90/silk Python 47 0
|
65
|
-
| 21 agaue/agaue Go 47 0
|
66
|
-
| 22 mentionapp/mntpulltoreact Objective-C 46 1
|
67
|
-
| 23 mikepenz/AboutLibraries Java 45 0
|
68
|
-
| 24 PistonDevelopers/piston-workspace Shell 45 0
|
69
|
-
| 25 maxpow4h/swiftz Swift 43 1
|
70
|
-
EOS
|
71
|
-
expect { @scraper.get(language) }.to output(res).to_stdout
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
describe 'with -l option' do
|
76
|
-
context 'with ruby' do
|
77
|
-
before do
|
78
|
-
@scraper = Scraper.new
|
79
|
-
stub_request_get("trending?l=#{language}")
|
80
|
-
end
|
81
|
-
let(:language) {'ruby'}
|
82
|
-
|
83
|
-
it 'display daily ranking by language' do
|
84
|
-
res = <<-'EOS'.unindent
|
85
|
-
|No. Name Lang Star Fork
|
86
|
-
|--- ---------------------------------------- ---------- ------ -----
|
87
|
-
| 1 prat0318/json_resume Ruby 412 27
|
88
|
-
| 2 dawn/dawn Ruby 57 2
|
89
|
-
| 3 Homebrew/homebrew Ruby 15 7
|
90
|
-
| 4 etsy/nagios-herald Ruby 18 0
|
91
|
-
| 5 jekyll/jekyll Ruby 14 4
|
92
|
-
| 6 opf/openproject Ruby 11 0
|
93
|
-
| 7 caskroom/homebrew-cask Ruby 9 3
|
94
|
-
| 8 rails/rails Ruby 6 7
|
95
|
-
| 9 interagent/prmd Ruby 9 0
|
96
|
-
| 10 mitchellh/vagrant Ruby 8 2
|
97
|
-
| 11 discourse/discourse Ruby 7 3
|
98
|
-
| 12 CanCanCommunity/cancancan Ruby 7 1
|
99
|
-
| 13 venmo/synx Ruby 7 0
|
100
|
-
| 14 laravel/homestead Shell 6 2
|
101
|
-
| 15 alexreisner/geocoder Ruby 6 0
|
102
|
-
| 16 visionmedia/commander Ruby 5 0
|
103
|
-
| 17 CocoaPods/Specs Ruby 0 3
|
104
|
-
| 18 gitlabhq/gitlabhq Ruby 0 2
|
105
|
-
| 19 puppetlabs/puppetlabs-apache Ruby 0 2
|
106
|
-
| 20 gitlabhq/gitlab-recipes Ruby 0 2
|
107
|
-
| 21 Mixd/wp-deploy Ruby 0 1
|
108
|
-
| 22 svenfuchs/rails-i18n Ruby 0 1
|
109
|
-
| 23 Homebrew/homebrew-php Ruby 0 1
|
110
|
-
| 24 sferik/twitter Ruby 0 1
|
111
|
-
| 25 rightscale/rightscale_cookbooks Ruby 0 1
|
112
|
-
EOS
|
113
|
-
expect { @scraper.get(language) }.to output(res).to_stdout
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
context 'with objective-c++ (including + sign)' do
|
118
|
-
before do
|
119
|
-
@scraper = Scraper.new
|
120
|
-
stub_request_get("trending?l=objective-c%2B%2B")
|
121
|
-
end
|
122
|
-
let(:language) {'objective-c++'}
|
123
|
-
|
124
|
-
it 'display daily ranking by language' do
|
125
|
-
res = <<-'EOS'.unindent
|
126
|
-
|No. Name Lang Star Fork
|
127
|
-
|--- ---------------------------------------- ------------- ------ -----
|
128
|
-
| 1 facebook/pop Objective-C++ 0 0
|
129
|
-
| 2 johnno1962/Xtrace Objective-C++ 0 0
|
130
|
-
| 3 pivotal/cedar Objective-C++ 0 0
|
131
|
-
| 4 wetube/bitcloud Objective-C++ 0 0
|
132
|
-
| 5 jerols/PopTut Objective-C++ 0 0
|
133
|
-
| 6 otaviocc/OCBorghettiView Objective-C++ 0 0
|
134
|
-
| 7 droolsjbpm/optaplanner Objective-C++ 0 0
|
135
|
-
| 8 otaviocc/NHCalendarActivity Objective-C++ 0 0
|
136
|
-
| 9 callmeed/pop-playground Objective-C++ 0 0
|
137
|
-
| 10 jxd001/POPdemo Objective-C++ 0 0
|
138
|
-
| 11 couchdeveloper/RXPromise Objective-C++ 0 0
|
139
|
-
| 12 johnno1962/XprobePlugin Objective-C++ 0 0
|
140
|
-
| 13 openpeer/opios Objective-C++ 0 0
|
141
|
-
| 14 pivotal/PivotalCoreKit Objective-C++ 0 0
|
142
|
-
| 15 rbaumbach/Swizzlean Objective-C++ 0 0
|
143
|
-
| 16 andreacremaschi/ShapeKit Objective-C++ 0 0
|
144
|
-
| 17 Smartype/iOS_VPNPlugIn Objective-C++ 0 0
|
145
|
-
| 18 humblehacker/AutoLayoutDSL Objective-C++ 0 0
|
146
|
-
| 19 hoddez/FFTAccelerate Objective-C++ 0 0
|
147
|
-
| 20 armadillu/ofxPanZoom Objective-C++ 0 0
|
148
|
-
| 21 dodikk/CsvToSqlite Objective-C++ 0 0
|
149
|
-
| 22 hbang/TypeStatus Objective-C++ 0 0
|
150
|
-
| 23 trentbrooks/ofxCoreMotion Objective-C++ 0 0
|
151
|
-
| 24 Yonsm/CeleWare Objective-C++ 0 0
|
152
|
-
| 25 ccrma/miniAudicle Objective-C++ 0 0
|
153
|
-
EOS
|
154
|
-
expect { @scraper.get(language) }.to output(res).to_stdout
|
155
|
-
end
|
156
|
-
end
|
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
|
286
|
-
end
|
287
|
-
|
288
|
-
describe '#list_all_languages' do
|
289
|
-
before do
|
290
|
-
@scraper = Scraper.new
|
291
|
-
stub_request_get('trending')
|
292
|
-
end
|
293
|
-
|
294
|
-
context 'with no option' do
|
295
|
-
it 'display daily ranking' do
|
296
|
-
res = <<-'EOS'.unindent
|
297
|
-
|abap
|
298
|
-
|as3
|
299
|
-
|ada
|
300
|
-
|agda
|
301
|
-
|alloy
|
302
|
-
|antlr
|
303
|
-
|apex
|
304
|
-
|applescript
|
305
|
-
|arc
|
306
|
-
|arduino
|
307
|
-
|aspx-vb
|
308
|
-
|aspectj
|
309
|
-
|nasm
|
310
|
-
|ats
|
311
|
-
|augeas
|
312
|
-
|autohotkey
|
313
|
-
|autoit
|
314
|
-
|awk
|
315
|
-
|blitzbasic
|
316
|
-
|bluespec
|
317
|
-
|boo
|
318
|
-
|brightscript
|
319
|
-
|bro
|
320
|
-
|c
|
321
|
-
|csharp
|
322
|
-
|cpp
|
323
|
-
|ceylon
|
324
|
-
|cirru
|
325
|
-
|clean
|
326
|
-
|clips
|
327
|
-
|clojure
|
328
|
-
|cobol
|
329
|
-
|coffeescript
|
330
|
-
|cfm
|
331
|
-
|common-lisp
|
332
|
-
|coq
|
333
|
-
|crystal
|
334
|
-
|css
|
335
|
-
|cuda
|
336
|
-
|d
|
337
|
-
|dart
|
338
|
-
|dcpu-16-asm
|
339
|
-
|dm
|
340
|
-
|dogescript
|
341
|
-
|dot
|
342
|
-
|dylan
|
343
|
-
|e
|
344
|
-
|ec
|
345
|
-
|eiffel
|
346
|
-
|elixir
|
347
|
-
|elm
|
348
|
-
|emacs-lisp
|
349
|
-
|erlang
|
350
|
-
|fsharp
|
351
|
-
|factor
|
352
|
-
|fancy
|
353
|
-
|fantom
|
354
|
-
|flux
|
355
|
-
|forth
|
356
|
-
|fortran
|
357
|
-
|frege
|
358
|
-
|game-maker-language
|
359
|
-
|gams
|
360
|
-
|gap
|
361
|
-
|glyph
|
362
|
-
|gnuplot
|
363
|
-
|go
|
364
|
-
|gosu
|
365
|
-
|grammatical-framework
|
366
|
-
|groovy
|
367
|
-
|harbour
|
368
|
-
|haskell
|
369
|
-
|haxe
|
370
|
-
|hy
|
371
|
-
|idl
|
372
|
-
|idris
|
373
|
-
|inform-7
|
374
|
-
|io
|
375
|
-
|ioke
|
376
|
-
|j
|
377
|
-
|java
|
378
|
-
|javascript
|
379
|
-
|jsoniq
|
380
|
-
|julia
|
381
|
-
|kotlin
|
382
|
-
|krl
|
383
|
-
|lasso
|
384
|
-
|livescript
|
385
|
-
|logos
|
386
|
-
|logtalk
|
387
|
-
|lua
|
388
|
-
|m
|
389
|
-
|markdown
|
390
|
-
|mathematica
|
391
|
-
|matlab
|
392
|
-
|max/msp
|
393
|
-
|mercury
|
394
|
-
|ruby
|
395
|
-
|monkey
|
396
|
-
|moocode
|
397
|
-
|moonscript
|
398
|
-
|nemerle
|
399
|
-
|nesc
|
400
|
-
|netlogo
|
401
|
-
|nimrod
|
402
|
-
|nu
|
403
|
-
|objective-c
|
404
|
-
|objective-c++
|
405
|
-
|objective-j
|
406
|
-
|ocaml
|
407
|
-
|omgrofl
|
408
|
-
|ooc
|
409
|
-
|opa
|
410
|
-
|openedge-abl
|
411
|
-
|oxygene
|
412
|
-
|pan
|
413
|
-
|parrot
|
414
|
-
|pascal
|
415
|
-
|pawn
|
416
|
-
|perl
|
417
|
-
|perl6
|
418
|
-
|php
|
419
|
-
|pike
|
420
|
-
|pogoscript
|
421
|
-
|powershell
|
422
|
-
|processing
|
423
|
-
|prolog
|
424
|
-
|propeller-spin
|
425
|
-
|puppet
|
426
|
-
|pure-data
|
427
|
-
|purescript
|
428
|
-
|python
|
429
|
-
|r
|
430
|
-
|racket
|
431
|
-
|ragel-in-ruby-host
|
432
|
-
|rdoc
|
433
|
-
|realbasic
|
434
|
-
|rebol
|
435
|
-
|red
|
436
|
-
|robotframework
|
437
|
-
|rouge
|
438
|
-
|ruby
|
439
|
-
|rust
|
440
|
-
|sas
|
441
|
-
|scala
|
442
|
-
|scheme
|
443
|
-
|scilab
|
444
|
-
|self
|
445
|
-
|bash
|
446
|
-
|shellsession
|
447
|
-
|shen
|
448
|
-
|slash
|
449
|
-
|smalltalk
|
450
|
-
|sourcepawn
|
451
|
-
|sql
|
452
|
-
|squirrel
|
453
|
-
|standard-ml
|
454
|
-
|stata
|
455
|
-
|supercollider
|
456
|
-
|swift
|
457
|
-
|systemverilog
|
458
|
-
|tcl
|
459
|
-
|tex
|
460
|
-
|turing
|
461
|
-
|txl
|
462
|
-
|typescript
|
463
|
-
|unrealscript
|
464
|
-
|vala
|
465
|
-
|verilog
|
466
|
-
|vhdl
|
467
|
-
|vim
|
468
|
-
|visual-basic
|
469
|
-
|volt
|
470
|
-
|wisp
|
471
|
-
|xbase
|
472
|
-
|xc
|
473
|
-
|xml
|
474
|
-
|xproc
|
475
|
-
|xquery
|
476
|
-
|xslt
|
477
|
-
|xtend
|
478
|
-
|zephir
|
479
|
-
|zimpl
|
480
|
-
|
|
481
|
-
|183 languages
|
482
|
-
|you can get only selected language list with '-l' option.
|
483
|
-
|if languages is unknown, you can specify 'unkown'.
|
484
|
-
|
|
485
|
-
EOS
|
486
|
-
expect { @scraper.list_all_languages }.to output(res).to_stdout
|
487
|
-
end
|
25
|
+
it { expect{ @scraper.get }.to raise_error(Exception) }
|
488
26
|
end
|
489
27
|
end
|
490
|
-
|
491
|
-
private
|
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).
|
498
|
-
to_return(
|
499
|
-
:status => 200,
|
500
|
-
:headers => {content_type: 'text/html'},
|
501
|
-
:body => load_http_stub(stub_url))
|
502
|
-
end
|
503
|
-
|
504
28
|
end
|
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.
|
4
|
+
version: 0.0.4
|
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-
|
11
|
+
date: 2014-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -156,6 +156,8 @@ files:
|
|
156
156
|
- git-trend.gemspec
|
157
157
|
- lib/git_trend.rb
|
158
158
|
- lib/git_trend/cli.rb
|
159
|
+
- lib/git_trend/ext.rb
|
160
|
+
- lib/git_trend/ext/string.rb
|
159
161
|
- lib/git_trend/project.rb
|
160
162
|
- lib/git_trend/rendering.rb
|
161
163
|
- lib/git_trend/scraper.rb
|
@@ -166,6 +168,7 @@ files:
|
|
166
168
|
- spec/fixtures/trending?l=ruby&since=weekly
|
167
169
|
- spec/fixtures/trending?since=monthly
|
168
170
|
- spec/fixtures/trending?since=weekly
|
171
|
+
- spec/git_trend/cli_spec.rb
|
169
172
|
- spec/git_trend/scraper_spec.rb
|
170
173
|
- spec/spec_helper.rb
|
171
174
|
homepage: https://github.com/rochefort/github-trend
|
@@ -188,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
188
191
|
version: '0'
|
189
192
|
requirements: []
|
190
193
|
rubyforge_project:
|
191
|
-
rubygems_version: 2.
|
194
|
+
rubygems_version: 2.3.0
|
192
195
|
signing_key:
|
193
196
|
specification_version: 4
|
194
197
|
summary: cli based; show Trending repository on github
|
@@ -199,5 +202,6 @@ test_files:
|
|
199
202
|
- spec/fixtures/trending?l=ruby&since=weekly
|
200
203
|
- spec/fixtures/trending?since=monthly
|
201
204
|
- spec/fixtures/trending?since=weekly
|
205
|
+
- spec/git_trend/cli_spec.rb
|
202
206
|
- spec/git_trend/scraper_spec.rb
|
203
207
|
- spec/spec_helper.rb
|