awesome_bot 1.8.5 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/CHANGELOG.md +5 -0
- data/README.md +29 -29
- data/lib/awesome_bot/cli.rb +71 -78
- data/lib/awesome_bot/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: 9f0cbdb5d7a7e2db7fb90d76ce2c444cee6456b1
|
4
|
+
data.tar.gz: 6dee220ffd70eb6b7f8fe37302faf51f1b9e7d9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 894ee0128f3b177805182a6c6e74fac43c150182383647e27e8a3b021302937752377c836c88654aaba51b0e983159af3a49e4ebd724ab3eccb15a9c773e08af
|
7
|
+
data.tar.gz: 7694fe013d9a93af945cceaffee1cf045eabf22258a59d52b69fbffeac20ea5cae8679ea1486b7f6ad29c342b3721eee19f62b5dd52dc1964b5b61378eb8fa3b
|
data/.travis.yml
CHANGED
@@ -14,5 +14,8 @@ script:
|
|
14
14
|
- awesome_bot bin/assets/test-redirect --allow-redirect
|
15
15
|
- awesome_bot bin/assets/test-statuses --white-list bot,bad,super
|
16
16
|
- awesome_bot bin/assets/test-errors
|
17
|
+
- awesome_bot -f bin/assets/test-no-issues,bin/assets/test-no-links
|
18
|
+
- awesome_bot -f bin/assets/test-no-issues,bin/assets/test-redirect --allow-redirect
|
19
|
+
- awesome_bot bin/assets/test-no-* --allow-redirect
|
17
20
|
- awesome_bot README.md --allow-dupe --white-list gph.is,giphy,travis-ci.org,codeload,badge,rubydoc,rubygems,circleci
|
18
21
|
- gem install awesome_bot
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,11 @@
|
|
2
2
|
|
3
3
|
Changes by [Daniel Khamsing][] unless otherwise noted.
|
4
4
|
|
5
|
+
# 1.9.0
|
6
|
+
|
7
|
+
- [cli] support checking multiple files (comma separated or `*` pattern i.e. `docs/*.md`), suggested by [Sota Yamashita](https://github.com/sotayamashita)
|
8
|
+
- [cli] use `optparse`
|
9
|
+
|
5
10
|
# 1.8.5
|
6
11
|
|
7
12
|
- [fix] request errors (make `get` requests), reported by [Richard Littauer](https://github.com/RichardLitt)
|
data/README.md
CHANGED
@@ -18,19 +18,24 @@ Verify links in [awesome](https://github.com/sindresorhus/awesome) projects
|
|
18
18
|
|
19
19
|
### Command Line
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
21
|
+
```
|
22
|
+
Usage: awesome_bot [file or files]
|
23
|
+
awesome_bot [options]
|
24
|
+
-f, --files [files] Comma separated files to check
|
25
|
+
--allow-dupe Duplicate URLs are allowed
|
26
|
+
--allow-redirect Redirected URLs are allowed
|
27
|
+
--allow-timeout URLs that time out are allowed
|
28
|
+
-t, --set-timeout [seconds] Set connection timeout
|
29
|
+
-w, --white-list [urls] Comma separated URLs to white list
|
30
|
+
```
|
28
31
|
|
29
|
-
|
32
|
+
- You can check multiple files (comma separated or `*` pattern, look below for details).
|
30
33
|
|
31
|
-
-
|
32
|
-
|
33
|
-
-
|
34
|
+
- By default, `awesome_bot` flags duplicates and URL redirects.
|
35
|
+
|
36
|
+
- Use option `--allow-dupe` to allow duplicates.
|
37
|
+
- Use option `--allow-redirect` to all redirects.
|
38
|
+
- You can white list links so that they won't be flagged. `-w domain1.com/post/article,domain2.com` white lists `domain1.com/post/article` and all links matching `domain2.com`.
|
34
39
|
|
35
40
|
### Examples
|
36
41
|
|
@@ -57,22 +62,17 @@ Issues :-(
|
|
57
62
|
```
|
58
63
|
|
59
64
|
```shell
|
60
|
-
$ awesome_bot README.md --allow-dupe --allow-redirect --
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
# ...
|
69
|
-
Checking URLs: ✓✓→✓✓→→→✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓→✓✓✓→✓
|
70
|
-
Checking white listed URLs: ?✓
|
65
|
+
$ awesome_bot README.md --allow-dupe --allow-redirect --w rubydoc,giphy
|
66
|
+
# allow redirects, dupes and white list all links matching rubydoc and giphy
|
67
|
+
|
68
|
+
$ awesome_bot README.md,README-zh.md
|
69
|
+
# check links in 2 files
|
70
|
+
|
71
|
+
$ awesome_bot docs/*.md
|
72
|
+
# check all markdown files in docs/ directory
|
71
73
|
|
72
|
-
|
73
|
-
|
74
|
-
2. [L093] 202 http://www.rubydoc.info/gems/awesome_bot
|
75
|
-
No issues :-)
|
74
|
+
$ awesome_bot README.md --allow-timeout --t 5
|
75
|
+
# speed up validation by setting a timeout of 5s per link request and allowing timeouts
|
76
76
|
```
|
77
77
|
|
78
78
|
### Library
|
@@ -96,15 +96,15 @@ More information at [rubydoc](http://www.rubydoc.info/gems/awesome_bot).
|
|
96
96
|
Does your GitHub README contain a lot of links? `awesome_bot` can help you validate them when a [pull request](https://github.com/dkhamsing/open-source-ios-apps/pull/159) is created (or a commit is pushed). It is used by:
|
97
97
|
|
98
98
|
- https://github.com/tiimgreen/github-cheat-sheet
|
99
|
-
- https://github.com/vinta/awesome-python
|
100
99
|
- https://github.com/enaqx/awesome-react
|
100
|
+
- https://github.com/ziadoz/awesome-php
|
101
101
|
- https://github.com/vsouza/awesome-ios
|
102
102
|
- https://github.com/alebcay/awesome-shell
|
103
103
|
- https://github.com/matteocrippa/awesome-swift
|
104
104
|
|
105
105
|
and [more](status/status.md).
|
106
106
|
|
107
|
-
Tip: Use the keyword `[ci skip]` in your commit title/message to
|
107
|
+
Tip: Use the keyword `[ci skip]` in your commit title/message to skip verification.
|
108
108
|
|
109
109
|
### Travis CI
|
110
110
|
|
@@ -182,7 +182,7 @@ As it happens, the default code snippet provided contain a redirect so adding a
|
|
182
182
|
- awesome_bot README.md --white-list travis-ci
|
183
183
|
```
|
184
184
|
|
185
|
-
You can also add a badge for other CI tools,
|
185
|
+
You can also add a badge for other CI tools, check out [shields.io](http://shields.io/).
|
186
186
|
|
187
187
|
## Contact
|
188
188
|
|
data/lib/awesome_bot/cli.rb
CHANGED
@@ -5,101 +5,86 @@ require 'awesome_bot/version'
|
|
5
5
|
|
6
6
|
# Command line interface
|
7
7
|
module AwesomeBot
|
8
|
-
|
9
|
-
OPTION_REDIRECT = 'allow-redirect'
|
10
|
-
OPTION_TIMEOUT_ALLOW = 'allow-timeout'
|
11
|
-
OPTION_TIMEOUT_SET = 'set-timeout'
|
12
|
-
OPTION_WHITE_LIST = 'white-list'
|
8
|
+
RESULTS_PREFIX = 'ab-results'
|
13
9
|
|
14
|
-
|
10
|
+
class << self
|
11
|
+
def cli
|
12
|
+
require 'optparse'
|
15
13
|
|
16
|
-
|
14
|
+
ARGV << '-h' if ARGV.empty?
|
17
15
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
options = {}
|
17
|
+
ARGV.options do |opts|
|
18
|
+
opts.banner = "Usage: #{PROJECT} [file or files] \n"\
|
19
|
+
" #{PROJECT} [options]"
|
22
20
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
option_w
|
36
|
-
]
|
37
|
-
|
38
|
-
if ARGV.count == 0
|
39
|
-
puts "Usage: #{PROJECT} <file> [#{option_d}] [#{option_r}] "\
|
40
|
-
"[#{option_t_a}] [#{option_t} d] "\
|
41
|
-
"[#{option_w} item1,item2,..]\n"\
|
42
|
-
"#{USAGE} file Path to file, required as first argument\n"\
|
43
|
-
"#{USAGE} #{option_d} Duplicate URLs are allowed \n"\
|
44
|
-
"#{USAGE} #{option_r} Redirected URLs are allowed \n"\
|
45
|
-
"#{USAGE} #{option_t_a} URLs that time out are allowed \n"\
|
46
|
-
"#{USAGE} #{option_t} Set connection timeout (seconds) \n"\
|
47
|
-
"#{USAGE} #{option_w} Comma separated URLs to white list \n"\
|
48
|
-
"\nVersion #{VERSION}, see #{PROJECT_URL} for more information"
|
49
|
-
exit
|
21
|
+
opts.on("-f", "--files [files]", Array, 'Comma separated files to check') { |val| options['files'] = val }
|
22
|
+
opts.on("--allow-dupe", TrueClass, 'Duplicate URLs are allowed') { |val| options['allow_dupe'] = val }
|
23
|
+
opts.on("--allow-redirect", TrueClass, 'Redirected URLs are allowed') { |val| options['allow_redirect'] = val }
|
24
|
+
opts.on("--allow-timeout", TrueClass, 'URLs that time out are allowed') { |val| options['allow_timeout'] = val }
|
25
|
+
opts.on("-t", "--set-timeout [seconds]", Integer, 'Set connection timeout') { |val| options['timeout'] = val }
|
26
|
+
opts.on("-w", "--white-list [urls]", Array, 'Comma separated URLs to white list') { |val| options['white_list'] = val }
|
27
|
+
|
28
|
+
opts.on_tail("--help") do
|
29
|
+
puts opts
|
30
|
+
exit
|
31
|
+
end
|
32
|
+
opts.parse!
|
50
33
|
end
|
51
34
|
|
52
|
-
|
35
|
+
files = options['files']
|
36
|
+
if files.nil?
|
37
|
+
files = []
|
38
|
+
ARGV.each do |a|
|
39
|
+
files.push a if a !~ /^--.*/
|
40
|
+
end
|
41
|
+
end
|
53
42
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
exit 1
|
43
|
+
summary = {}
|
44
|
+
files.each do |f|
|
45
|
+
summary[f] = cli_process(f, options)
|
58
46
|
end
|
59
47
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
48
|
+
if summary.count>1
|
49
|
+
puts "\nSummary"
|
50
|
+
|
51
|
+
largest = 0
|
52
|
+
summary.each do |k, v|
|
53
|
+
s = k.size
|
54
|
+
largest = s if s>largest
|
55
|
+
end
|
56
|
+
|
57
|
+
summary.each do |k, v|
|
58
|
+
k_display = "%#{largest}.#{largest}s" % k
|
59
|
+
puts "#{k_display}: #{v}"
|
60
|
+
end
|
67
61
|
end
|
68
62
|
|
63
|
+
summary.each { |k, v| exit 1 unless v==STATUS_OK }
|
64
|
+
end
|
65
|
+
|
66
|
+
def cli_process(filename, options)
|
69
67
|
begin
|
70
68
|
content = File.read filename
|
71
69
|
rescue => error
|
72
70
|
puts "File open error: #{error}"
|
73
|
-
|
71
|
+
return error
|
74
72
|
end
|
75
73
|
|
76
74
|
puts "> Checking links in #{filename}"
|
77
75
|
|
78
|
-
|
79
|
-
options = ARGV.drop 1
|
76
|
+
skip_dupe = options['allow_dupe']
|
80
77
|
|
81
|
-
|
78
|
+
allow_redirects = options['allow_redirect']
|
79
|
+
puts '> Will allow redirects' if allow_redirects == true
|
82
80
|
|
83
|
-
|
84
|
-
|
81
|
+
allow_timeouts = options['allow_timeout']
|
82
|
+
puts '> Will allow network timeouts' if allow_timeouts == true
|
85
83
|
|
86
|
-
|
87
|
-
puts '> Will allow network timeouts' if allow_timeouts == true
|
84
|
+
white_listed = options['white_list']
|
88
85
|
|
89
|
-
|
90
|
-
|
91
|
-
white_listed = options[i].split ','
|
92
|
-
end
|
93
|
-
|
94
|
-
if options.include? option_t
|
95
|
-
i = options.find_index(option_t) + 1
|
96
|
-
timeout = options[i].to_i
|
97
|
-
puts "> Connection timeout = #{timeout}s"
|
98
|
-
end
|
99
|
-
else
|
100
|
-
allow_redirects = false
|
101
|
-
allow_timeouts = false
|
102
|
-
end
|
86
|
+
timeout = options['timeout']
|
87
|
+
puts "> Connection timeout = #{timeout}s" unless timeout.nil?
|
103
88
|
|
104
89
|
options = {
|
105
90
|
'whitelist' => white_listed,
|
@@ -119,9 +104,13 @@ module AwesomeBot
|
|
119
104
|
end
|
120
105
|
end
|
121
106
|
|
107
|
+
allow_redirects = false if allow_redirects.nil?
|
108
|
+
allow_timeouts = false if allow_timeouts.nil?
|
109
|
+
|
122
110
|
if r.success(allow_redirects, allow_timeouts) == true
|
123
111
|
puts 'No issues :-)'
|
124
|
-
r
|
112
|
+
cli_write_results(filename, r)
|
113
|
+
return STATUS_OK
|
125
114
|
else
|
126
115
|
puts "\nIssues :-("
|
127
116
|
|
@@ -156,12 +145,16 @@ module AwesomeBot
|
|
156
145
|
end
|
157
146
|
end
|
158
147
|
|
159
|
-
|
160
|
-
|
161
|
-
puts "\nWrote results to #{RESULTS_FILE}"
|
162
|
-
|
163
|
-
exit 1
|
148
|
+
cli_write_results(filename, r)
|
149
|
+
return 'Issues'
|
164
150
|
end
|
165
151
|
end
|
152
|
+
|
153
|
+
def cli_write_results(f, r)
|
154
|
+
results_file_filter = f.gsub('/','-')
|
155
|
+
results_file = "#{RESULTS_PREFIX}-#{results_file_filter}.json"
|
156
|
+
r.write results_file
|
157
|
+
puts "\nWrote results to #{results_file}"
|
158
|
+
end
|
166
159
|
end # class
|
167
160
|
end
|
data/lib/awesome_bot/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awesome_bot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Khamsing
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parallel
|