awesome_bot 1.9.1 → 1.10.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.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CHANGELOG.md +4 -0
- data/README.md +22 -0
- data/bin/assets/test-ssl +5 -0
- data/bin/assets/test-timeout +1 -0
- data/lib/awesome_bot/check.rb +2 -6
- data/lib/awesome_bot/cli.rb +26 -12
- data/lib/awesome_bot/result.rb +25 -17
- data/lib/awesome_bot/version.rb +1 -1
- data/status/list-travis-ci +1 -1
- data/status/status.md +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 579b7cb269ffa2b68154fb856d45ce053ec0d521
|
4
|
+
data.tar.gz: be39e06b6476aa7dc46a46c8b191ba72f1480645
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d18b3b61f7e4bc5dc0d72408ea9201b1b795f18274e1933f83d80626310f99438d239aaba01e78abeef7395b16511076bb8c3ce10397bf120a1454b1ea024b6
|
7
|
+
data.tar.gz: f4c6b23f500f4de422332e2f3cb8261ba612314e60440152bd0648394a31f7a05c29315f4a21988d153f396bf3193f9eb1146a899bad8ff5a55bef527d6de1af
|
data/.travis.yml
CHANGED
@@ -17,5 +17,6 @@ script:
|
|
17
17
|
- awesome_bot -f bin/assets/test-no-issues,bin/assets/test-no-links
|
18
18
|
- awesome_bot -f bin/assets/test-no-issues,bin/assets/test-redirect --allow-redirect
|
19
19
|
- awesome_bot bin/assets/test-no-* --allow-redirect
|
20
|
+
- awesome_bot bin/assets/test-ssl --allow-ssl
|
20
21
|
- awesome_bot README.md --allow-dupe --white-list gph.is,giphy,travis-ci.org,codeload,badge,rubydoc,rubygems,circleci
|
21
22
|
- gem install awesome_bot
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
Changes by [Daniel Khamsing][] unless otherwise noted.
|
4
4
|
|
5
|
+
# 1.10.0
|
6
|
+
|
7
|
+
- add `allow-ssl` option, suggested by [Joe Block](https://github.com/unixorn)
|
8
|
+
|
5
9
|
# 1.9.1
|
6
10
|
|
7
11
|
- [fix] url redirect location encoding, reported by [@hoppfrosch](https://github.com/hoppfrosch)
|
data/README.md
CHANGED
@@ -23,6 +23,7 @@ Usage: awesome_bot [file or files]
|
|
23
23
|
awesome_bot [options]
|
24
24
|
-f, --files [files] Comma separated files to check
|
25
25
|
--allow-dupe Duplicate URLs are allowed
|
26
|
+
--allow-ssl SSL errors are allowed
|
26
27
|
--allow-redirect Redirected URLs are allowed
|
27
28
|
--allow-timeout URLs that time out are allowed
|
28
29
|
-t, --set-timeout [seconds] Set connection timeout
|
@@ -75,6 +76,27 @@ $ awesome_bot README.md --allow-timeout --t 5
|
|
75
76
|
# speed up validation by setting a timeout of 5s per link request and allowing timeouts
|
76
77
|
```
|
77
78
|
|
79
|
+
```shell
|
80
|
+
(master) $ git branch
|
81
|
+
* master
|
82
|
+
(master) $ git checkout -b new-branch
|
83
|
+
Switched to a new branch 'new-branch'
|
84
|
+
(new-branch) $ touch new-readme.md && echo 'https://github.com/dkhamsing' >> new-readme.md
|
85
|
+
(new-branch) $ git add new-readme.md
|
86
|
+
(new-branch) $ git commit -m 'Testing'
|
87
|
+
[new-branch ef47336] Testing
|
88
|
+
1 file changed, 1 insertion(+)
|
89
|
+
create mode 100644 new-readme.md
|
90
|
+
(new-branch) $ git diff master.. --name-only | grep '.md' | xargs awesome_bot
|
91
|
+
> Checking links in new-readme.md
|
92
|
+
Links to check: 1
|
93
|
+
1. https://github.com/dkhamsing
|
94
|
+
Checking URLs: ✓
|
95
|
+
No issues :-)
|
96
|
+
|
97
|
+
Wrote results to ab-results-new-readme.md.json
|
98
|
+
```
|
99
|
+
|
78
100
|
### Library
|
79
101
|
|
80
102
|
```ruby
|
data/bin/assets/test-ssl
ADDED
data/bin/assets/test-timeout
CHANGED
data/lib/awesome_bot/check.rb
CHANGED
@@ -19,15 +19,11 @@ module AwesomeBot
|
|
19
19
|
timeout = options['timeout']
|
20
20
|
end
|
21
21
|
|
22
|
-
|
22
|
+
links = links_filter(links_find(content))
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
r = Result.new(temp, white_listed)
|
24
|
+
r = Result.new(links, white_listed)
|
27
25
|
r.skip_dupe = skip_dupe
|
28
26
|
|
29
|
-
yield "> White list links matching: #{white_listed.join ', '} \n" if r.white_listing && block_given?
|
30
|
-
|
31
27
|
r.dupes = r.links.select { |e| r.links.count(e) > 1 }
|
32
28
|
|
33
29
|
yield "Links to check: #{r.links.count}" if block_given?
|
data/lib/awesome_bot/cli.rb
CHANGED
@@ -8,7 +8,7 @@ module AwesomeBot
|
|
8
8
|
RESULTS_PREFIX = 'ab-results'
|
9
9
|
|
10
10
|
class << self
|
11
|
-
def cli
|
11
|
+
def cli()
|
12
12
|
require 'optparse'
|
13
13
|
|
14
14
|
ARGV << '-h' if ARGV.empty?
|
@@ -18,12 +18,13 @@ module AwesomeBot
|
|
18
18
|
opts.banner = "Usage: #{PROJECT} [file or files] \n"\
|
19
19
|
" #{PROJECT} [options]"
|
20
20
|
|
21
|
-
opts.on(
|
22
|
-
opts.on(
|
23
|
-
opts.on(
|
24
|
-
opts.on(
|
25
|
-
opts.on(
|
26
|
-
opts.on(
|
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-ssl', TrueClass, 'SSL errors are allowed') { |val| options['allow_ssl'] = val }
|
24
|
+
opts.on('--allow-redirect', TrueClass, 'Redirected URLs are allowed') { |val| options['allow_redirect'] = val }
|
25
|
+
opts.on('--allow-timeout', TrueClass, 'URLs that time out are allowed') { |val| options['allow_timeout'] = val }
|
26
|
+
opts.on('-t', '--set-timeout [seconds]', Integer, 'Set connection timeout') { |val| options['timeout'] = val }
|
27
|
+
opts.on('-w', '--white-list [urls]', Array, 'Comma separated URLs to white list') { |val| options['white_list'] = val }
|
27
28
|
|
28
29
|
opts.on_tail("--help") do
|
29
30
|
puts opts
|
@@ -74,10 +75,14 @@ module AwesomeBot
|
|
74
75
|
puts "> Checking links in #{filename}"
|
75
76
|
|
76
77
|
skip_dupe = options['allow_dupe']
|
78
|
+
puts '> Will allow duplicate links' if skip_dupe == true
|
77
79
|
|
78
80
|
allow_redirects = options['allow_redirect']
|
79
81
|
puts '> Will allow redirects' if allow_redirects == true
|
80
82
|
|
83
|
+
allow_ssl = options['allow_ssl']
|
84
|
+
puts '> Will allow SSL errors' if allow_ssl == true
|
85
|
+
|
81
86
|
allow_timeouts = options['allow_timeout']
|
82
87
|
puts '> Will allow network timeouts' if allow_timeouts == true
|
83
88
|
|
@@ -86,10 +91,12 @@ module AwesomeBot
|
|
86
91
|
timeout = options['timeout']
|
87
92
|
puts "> Connection timeout = #{timeout}s" unless timeout.nil?
|
88
93
|
|
94
|
+
puts "> White list links matching: #{white_listed.join ', '} " unless white_listed.nil?
|
95
|
+
|
89
96
|
options = {
|
90
|
-
'whitelist' => white_listed,
|
91
97
|
'allowdupe' => skip_dupe,
|
92
|
-
'timeout'
|
98
|
+
'timeout' => timeout,
|
99
|
+
'whitelist' => white_listed
|
93
100
|
}
|
94
101
|
r = check content, options do |o|
|
95
102
|
print o
|
@@ -105,9 +112,16 @@ module AwesomeBot
|
|
105
112
|
end
|
106
113
|
|
107
114
|
allow_redirects = false if allow_redirects.nil?
|
115
|
+
allow_ssl = false if allow_ssl.nil?
|
108
116
|
allow_timeouts = false if allow_timeouts.nil?
|
109
117
|
|
110
|
-
|
118
|
+
options = {
|
119
|
+
'redirect' => allow_redirects,
|
120
|
+
'ssl' => allow_ssl,
|
121
|
+
'timeout' => allow_timeouts
|
122
|
+
}
|
123
|
+
|
124
|
+
if r.success(options) == true
|
111
125
|
puts 'No issues :-)'
|
112
126
|
cli_write_results(filename, r)
|
113
127
|
return STATUS_OK
|
@@ -115,10 +129,10 @@ module AwesomeBot
|
|
115
129
|
puts "\nIssues :-("
|
116
130
|
|
117
131
|
print "> Links \n"
|
118
|
-
if r.success_links(
|
132
|
+
if r.success_links(options)
|
119
133
|
puts " All OK #{STATUS_OK}"
|
120
134
|
else
|
121
|
-
o = order_by_loc r.statuses_issues(
|
135
|
+
o = order_by_loc r.statuses_issues(options), content
|
122
136
|
o.each_with_index do |x, k|
|
123
137
|
puts output x, k, pad_list(o), digits
|
124
138
|
end
|
data/lib/awesome_bot/result.rb
CHANGED
@@ -21,28 +21,36 @@ module AwesomeBot
|
|
21
21
|
@links = links.partition { |u| AwesomeBot.white_list @w, u }
|
22
22
|
end
|
23
23
|
|
24
|
-
def statuses_issues(
|
24
|
+
def statuses_issues(options=nil)
|
25
|
+
options = {
|
26
|
+
'timeout'=>false,
|
27
|
+
'ssl'=>false,
|
28
|
+
'redirect'=>false
|
29
|
+
} if options.nil?
|
30
|
+
|
25
31
|
s = status.select { |x| x['status'] != 200 }
|
26
|
-
|
27
|
-
|
28
|
-
|
32
|
+
|
33
|
+
if options['timeout']
|
34
|
+
s = s.reject do |x|
|
35
|
+
( (x['error'].message == 'Net::ReadTimeout') || (x['error'].message == 'execution expired') || (x['error'].message.include? 'timed out') ) unless x['error'].nil?
|
36
|
+
end
|
29
37
|
end
|
30
38
|
|
31
|
-
if
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
return r.reject do |x|
|
39
|
-
(x['status'] == STATUS_ERROR) && ((x['error'].message == 'Net::ReadTimeout') || (x['error'].message == 'execution expired'))
|
39
|
+
if options['redirect']
|
40
|
+
s = s.reject { |x| AwesomeBot.status_is_redirected? x['status'] }
|
41
|
+
end
|
42
|
+
|
43
|
+
if options['ssl']
|
44
|
+
s = s.reject do |x|
|
45
|
+
( (x['error'].message.include? 'server certificate') || (x['error'].message.include? 'SSL_connect') ) unless x['error'].nil?
|
40
46
|
end
|
41
47
|
end
|
48
|
+
|
49
|
+
s
|
42
50
|
end
|
43
51
|
|
44
|
-
def success(
|
45
|
-
success_dupe && success_links(
|
52
|
+
def success(options)
|
53
|
+
success_dupe && success_links(options)
|
46
54
|
end
|
47
55
|
|
48
56
|
def success_dupe
|
@@ -50,8 +58,8 @@ module AwesomeBot
|
|
50
58
|
links.uniq.count == links.count
|
51
59
|
end
|
52
60
|
|
53
|
-
def success_links(
|
54
|
-
statuses_issues(
|
61
|
+
def success_links(options)
|
62
|
+
statuses_issues(options).count==0
|
55
63
|
end
|
56
64
|
|
57
65
|
def white_listing
|
data/lib/awesome_bot/version.rb
CHANGED
data/status/list-travis-ci
CHANGED
data/status/status.md
CHANGED
@@ -67,7 +67,7 @@ Status | Config | Repo
|
|
67
67
|
[](https://travis-ci.org/ipfs/awesome-ipfs) | [`config`](https://github.com/ipfs/awesome-ipfs/blob/master/.travis.yml) | [ipfs/awesome-ipfs](https://github.com/ipfs/awesome-ipfs)
|
68
68
|
[](https://travis-ci.org/iJackUA/awesome-vagrant) | [`config`](https://github.com/iJackUA/awesome-vagrant/blob/master/.travis.yml) | [iJackUA/awesome-vagrant](https://github.com/iJackUA/awesome-vagrant)
|
69
69
|
[](https://travis-ci.org/ramitsurana/awesome-kubernetes) | [`config`](https://github.com/ramitsurana/awesome-kubernetes/blob/master/.travis.yml) | [ramitsurana/awesome-kubernetes](https://github.com/ramitsurana/awesome-kubernetes)
|
70
|
-
[](https://travis-ci.org/brj/awesome-fish) | [`config`](https://github.com/brj/awesome-fish/blob/master/.travis.yml) | [brj/awesome-fish](https://github.com/brj/awesome-fish)
|
71
71
|
[](https://travis-ci.org/yenchenlin1994/awesome-watchos) | [`config`](https://github.com/yenchenlin1994/awesome-watchos/blob/master/.travis.yml) | [yenchenlin1994/awesome-watchos](https://github.com/yenchenlin1994/awesome-watchos)
|
72
72
|
[](https://travis-ci.org/MakinGiants/awesome-mobile-dev) | [`config`](https://github.com/MakinGiants/awesome-mobile-dev/blob/master/.travis.yml) | [MakinGiants/awesome-mobile-dev](https://github.com/MakinGiants/awesome-mobile-dev)
|
73
73
|
[](https://travis-ci.org/MakinGiants/awesome-mobile-dev) | [`config`](https://github.com/MakinGiants/awesome-mobile-dev/blob/master/.travis.yml) | [MakinGiants/awesome-mobile-dev](https://github.com/MakinGiants/awesome-mobile-dev)
|
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.10.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-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parallel
|
@@ -49,6 +49,7 @@ files:
|
|
49
49
|
- bin/assets/test-no-links
|
50
50
|
- bin/assets/test-parse
|
51
51
|
- bin/assets/test-redirect
|
52
|
+
- bin/assets/test-ssl
|
52
53
|
- bin/assets/test-statuses
|
53
54
|
- bin/assets/test-timeout
|
54
55
|
- bin/assets/test-timeout-and-redirect
|