awesome_bot 1.11.0 → 1.12.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 44c4121f5cf211f02e3f55149a31681a4e5eb854
4
- data.tar.gz: ebe9cfa3f4bd160fe34c12b3737c8bcabdce2512
3
+ metadata.gz: 61e7d39fd465602a61c824ad316ac2d6f0b116c3
4
+ data.tar.gz: 8e662e958ea3c4744d0e2ac64e94ea32755e2e82
5
5
  SHA512:
6
- metadata.gz: ffcb771a6ac91866f80aba48188d059467928a1c0e8bdd3c726da95e800585bccd2d0e3319e471fc94285748e9b79db9f3796375883efdf42f8816c7222f3d3d
7
- data.tar.gz: c374442c4a9fdeb8bab0c912f590f8c71f42aa04ee870b2edcdc65beaa529e7d7d5066c5754f69b26f17503635d2534405ed067dfc0fb8c591259528f34b518f
6
+ metadata.gz: e4226ba76b6387d7b5a3ed4c251613ca39be19c366494694d954e4984e3286e2e1e13a791842cc7ba57fe9293e90dcb042ca372236de7ab834c68bf2f3d26c70
7
+ data.tar.gz: d9d51330bf8f9f70e76178b291a973e7e46998dc9448fcf7025734dbca6c9a11343427a63c367441a00eb432e6b607d23bfa3b9dd39c35a51b78dd17ff098ae7
data/.travis.yml CHANGED
@@ -12,6 +12,7 @@ script:
12
12
  - awesome_bot bin/assets/test-timeout --allow-timeout --set-timeout 1
13
13
  - awesome_bot bin/assets/test-timeout-and-redirect --allow-timeout --set-timeout 1 --allow-redirect
14
14
  - awesome_bot bin/assets/test-redirect --allow-redirect
15
+ - awesome_bot bin/assets/test-redirect --allow-redirect -a 301
15
16
  - awesome_bot bin/assets/test-statuses --white-list bot,bad,super
16
17
  - awesome_bot bin/assets/test-errors
17
18
  - awesome_bot -f bin/assets/test-no-issues,bin/assets/test-no-links
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  Changes by [Daniel Khamsing][] unless otherwise noted.
4
4
 
5
+ # 1.12.0
6
+
7
+ - add `allow` option to allow specific error status codes, i.e. `--allow 301` or `--allow 403,429`
8
+
5
9
  # 1.11.0
6
10
 
7
11
  - [net] set `awesome_bot` user agent
data/README.md CHANGED
@@ -22,6 +22,7 @@ Verify links in [awesome](status/status.md) projects
22
22
  Usage: awesome_bot [file or files]
23
23
  awesome_bot [options]
24
24
  -f, --files [files] Comma separated files to check
25
+ -a, --allow [errors] Status code errors to allow
25
26
  --allow-dupe Duplicate URLs are allowed
26
27
  --allow-ssl SSL errors are allowed
27
28
  --allow-redirect Redirected URLs are allowed
@@ -32,11 +33,12 @@ Usage: awesome_bot [file or files]
32
33
 
33
34
  - You can check multiple files (comma separated or `*` pattern, look below for details).
34
35
 
35
- - By default, `awesome_bot` flags duplicates and URL redirects.
36
+ - By default, duplicate URLs or any status code other than `200` are flagged as failures.
36
37
 
37
38
  - Use option `--allow-dupe` to allow duplicates.
38
- - Use option `--allow-redirect` to all redirects.
39
- - 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`.
39
+ - Use option `--allow-redirect` to allow redirects.
40
+ - Use option `--allow` to allow specific status code errors.
41
+ - Use option `--white-list` (`-w` for short) to prevent links from being flagged: `-w domain1.com/post/article,domain2.com` white lists `domain1.com/post/article` and all links matching `domain2.com`.
40
42
 
41
43
  ### Examples
42
44
 
@@ -63,7 +65,7 @@ Issues :-(
63
65
  ```
64
66
 
65
67
  ```shell
66
- $ awesome_bot README.md --allow-dupe --allow-redirect --w rubydoc,giphy
68
+ $ awesome_bot README.md --allow-dupe --allow-redirect -w rubydoc,giphy
67
69
  # allow redirects, dupes and white list all links matching rubydoc and giphy
68
70
 
69
71
  $ awesome_bot README.md,README-zh.md
@@ -72,8 +74,12 @@ $ awesome_bot README.md,README-zh.md
72
74
  $ awesome_bot docs/*.md
73
75
  # check all markdown files in docs/ directory
74
76
 
75
- $ awesome_bot README.md --allow-timeout --t 5
77
+ $ awesome_bot README.md --allow-timeout -t 5
76
78
  # speed up validation by setting a timeout of 5s per link request and allowing timeouts
79
+
80
+ $ awesome_bot README.md --allow 403,429
81
+ # allow status code errors 403 and 429
82
+ # --allow 301 would be similar to --allow-redirect
77
83
  ```
78
84
 
79
85
  ```shell
@@ -90,7 +96,7 @@ Switched to a new branch 'new-branch'
90
96
  (new-branch) $ git diff master.. --name-only | grep '.md' | xargs awesome_bot
91
97
  > Checking links in new-readme.md
92
98
  Links to check: 1
93
- 1. https://github.com/dkhamsing
99
+ 1. https://github.com/dkhamsing
94
100
  Checking URLs: ✓
95
101
  No issues :-)
96
102
 
@@ -19,6 +19,7 @@ module AwesomeBot
19
19
  " #{PROJECT} [options]"
20
20
 
21
21
  opts.on('-f', '--files [files]', Array, 'Comma separated files to check') { |val| options['files'] = val }
22
+ opts.on('-a', '--allow [errors]', Array, 'Status code errors to allow') { |val| options['errors'] = val }
22
23
  opts.on('--allow-dupe', TrueClass, 'Duplicate URLs are allowed') { |val| options['allow_dupe'] = val }
23
24
  opts.on('--allow-ssl', TrueClass, 'SSL errors are allowed') { |val| options['allow_ssl'] = val }
24
25
  opts.on('--allow-redirect', TrueClass, 'Redirected URLs are allowed') { |val| options['allow_redirect'] = val }
@@ -74,6 +75,9 @@ module AwesomeBot
74
75
 
75
76
  puts "> Checking links in #{filename}"
76
77
 
78
+ errors = options['errors']
79
+ puts "> Will allow errors: #{errors.join ','}" unless errors.nil?
80
+
77
81
  skip_dupe = options['allow_dupe']
78
82
  puts '> Will allow duplicate links' if skip_dupe == true
79
83
 
@@ -116,6 +120,7 @@ module AwesomeBot
116
120
  allow_timeouts = false if allow_timeouts.nil?
117
121
 
118
122
  options = {
123
+ 'errors' => errors,
119
124
  'redirect' => allow_redirects,
120
125
  'ssl' => allow_ssl,
121
126
  'timeout' => allow_timeouts
@@ -46,6 +46,12 @@ module AwesomeBot
46
46
  end
47
47
  end
48
48
 
49
+ unless options['errors'].nil?
50
+ options['errors'].each do |c|
51
+ s = s.reject { |x| x['status']==c.to_i }
52
+ end
53
+ end
54
+
49
55
  s
50
56
  end
51
57
 
@@ -5,5 +5,5 @@ module AwesomeBot
5
5
  'Great for "awesome" projects.'
6
6
  PROJECT_URL = 'https://github.com/dkhamsing/awesome_bot'
7
7
 
8
- VERSION = '1.11.0'
8
+ VERSION = '1.12.0'
9
9
  end
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.11.0
4
+ version: 1.12.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-31 00:00:00.000000000 Z
11
+ date: 2016-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parallel