awesome_bot 1.9.1 → 1.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9e4a96c0cd7a8268af60e722d10c9b239110970b
4
- data.tar.gz: 424ed53ce3270b4790a7558d41c18427bae9cd76
3
+ metadata.gz: 579b7cb269ffa2b68154fb856d45ce053ec0d521
4
+ data.tar.gz: be39e06b6476aa7dc46a46c8b191ba72f1480645
5
5
  SHA512:
6
- metadata.gz: 77ef0e9e6069c316dba78f0c8e868920cb4e5a7a970558ae4d77369f3daeb78d360bdc289174762a802d4e823559816ddd2d25a082fe16bbe87b70ec82251ad4
7
- data.tar.gz: 35060b12c0219745a3ff7363d402cd6e4f6dc91b54c7666791098cdbb675fb7e52e2e617aef5eb9b6c6d1f45d4bb24429029e40cee479f6edc5ab8c88912a67d
6
+ metadata.gz: 3d18b3b61f7e4bc5dc0d72408ea9201b1b795f18274e1933f83d80626310f99438d239aaba01e78abeef7395b16511076bb8c3ce10397bf120a1454b1ea024b6
7
+ data.tar.gz: f4c6b23f500f4de422332e2f3cb8261ba612314e60440152bd0648394a31f7a05c29315f4a21988d153f396bf3193f9eb1146a899bad8ff5a55bef527d6de1af
@@ -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
@@ -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
@@ -0,0 +1,5 @@
1
+ https://www.gitbook.io/book/gitbookio/markdown
2
+ https://this-week-in-rust.org/
3
+ https://kismatic.com/
4
+ https://kismatic.com/community/introducing-kubernetes-weekly-news/
5
+ https://data.nasdaq.com/
@@ -1,2 +1,3 @@
1
1
  http://www.cmr.osu.edu/browse/datasets
2
2
  https://github.com
3
+ http://github.com
@@ -19,15 +19,11 @@ module AwesomeBot
19
19
  timeout = options['timeout']
20
20
  end
21
21
 
22
- yield "> Will allow duplicate links \n" if skip_dupe && block_given?
22
+ links = links_filter(links_find(content))
23
23
 
24
- temp = links_filter(links_find(content))
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?
@@ -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("-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 }
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' => 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
- if r.success(allow_redirects, allow_timeouts) == true
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(allow_redirects, allow_timeouts)
132
+ if r.success_links(options)
119
133
  puts " All OK #{STATUS_OK}"
120
134
  else
121
- o = order_by_loc r.statuses_issues(allow_redirects, allow_timeouts), content
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
@@ -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(allow_redirects = false, allow_timeouts = false)
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
- r = s.reject { |x| AwesomeBot.status_is_redirected? x['status'] }
27
- t = s.reject do |x|
28
- (x['status'] == STATUS_ERROR) && ((x['error'].message == 'Net::ReadTimeout') || (x['error'].message == 'execution expired'))
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 (allow_redirects == false) && (allow_timeouts == false)
32
- return s
33
- elsif (allow_redirects == true) && (allow_timeouts == false)
34
- return r
35
- elsif (allow_redirects == false) && (allow_timeouts == true)
36
- return t
37
- else
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(allow_redirects = false, allow_timeouts = false)
45
- success_dupe && success_links(allow_redirects, allow_timeouts)
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(allow_redirects = false, allow_timeouts = false)
54
- statuses_issues(allow_redirects, allow_timeouts).count == 0
61
+ def success_links(options)
62
+ statuses_issues(options).count==0
55
63
  end
56
64
 
57
65
  def white_listing
@@ -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.9.1'
8
+ VERSION = '1.10.0'
9
9
  end
@@ -61,7 +61,7 @@ sergeyklay/awesome-phalcon
61
61
  ipfs/awesome-ipfs
62
62
  iJackUA/awesome-vagrant
63
63
  ramitsurana/awesome-kubernetes
64
- bucaran/awesome-fish
64
+ brj/awesome-fish
65
65
  yenchenlin1994/awesome-watchos
66
66
  MakinGiants/awesome-mobile-dev
67
67
  MakinGiants/awesome-mobile-dev
@@ -67,7 +67,7 @@ Status | Config | Repo
67
67
  [![Build Status](https://travis-ci.org/ipfs/awesome-ipfs.svg)](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
  [![Build Status](https://travis-ci.org/iJackUA/awesome-vagrant.svg)](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
  [![Build Status](https://travis-ci.org/ramitsurana/awesome-kubernetes.svg)](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
- [![Build Status](https://travis-ci.org/bucaran/awesome-fish.svg)](https://travis-ci.org/bucaran/awesome-fish) | [`config`](https://github.com/bucaran/awesome-fish/blob/master/.travis.yml) | [bucaran/awesome-fish](https://github.com/bucaran/awesome-fish)
70
+ [![Build Status](https://travis-ci.org/brj/awesome-fish.svg)](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
  [![Build Status](https://travis-ci.org/yenchenlin1994/awesome-watchos.svg)](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
  [![Build Status](https://travis-ci.org/MakinGiants/awesome-mobile-dev.svg)](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
  [![Build Status](https://travis-ci.org/MakinGiants/awesome-mobile-dev.svg)](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.9.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-18 00:00:00.000000000 Z
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