awesome_bot 1.15.0 → 1.16.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 -1
- data/CHANGELOG.md +4 -0
- data/README.md +4 -0
- data/bin/assets/test-errors +0 -1
- data/lib/awesome_bot/check.rb +3 -1
- data/lib/awesome_bot/cli.rb +6 -1
- data/lib/awesome_bot/links.rb +14 -2
- 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: 9af72ee336b052bf87a013c876f0a9bdafc25c70
|
4
|
+
data.tar.gz: 756eb8577b75cdb81e284a862ec3db91b52f246a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48ed0e912d2bb3f92f00f7cc712065c249763e4f5e8e33c5ff7e4cd72d8744d26eb028278d17dbe27f391bb91fcf5c05e2139f2b48171df1a4d8fba518c0d01b
|
7
|
+
data.tar.gz: 189249162e3449417fcf5c408bf68f2d8fcf11f86f30b1da6a812fc4f3cb265368df15144ae824383b6c812839432762a17d6c78e2acc2449dc58742e5c35d49
|
data/.travis.yml
CHANGED
@@ -21,5 +21,5 @@ script:
|
|
21
21
|
- awesome_bot bin/assets/test-ssl --allow-ssl
|
22
22
|
- awesome_bot bin/assets/test-invalid.md --allow-redirect --allow-dupe
|
23
23
|
- awesome_bot bin/assets/test-request-delay -d 1
|
24
|
-
- awesome_bot README.md --allow-dupe --white-list gph.is,giphy,travis-ci.org,codeload,badge,rubydoc,rubygems,circleci,codeship
|
24
|
+
- awesome_bot README.md --allow-dupe --white-list gph.is,giphy,travis-ci.org,codeload,badge,rubydoc,rubygems,circleci,codeship,blob/master
|
25
25
|
- gem install awesome_bot
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -27,6 +27,7 @@ Usage: awesome_bot [file or files]
|
|
27
27
|
--allow-ssl SSL errors are allowed
|
28
28
|
--allow-redirect Redirected URLs are allowed
|
29
29
|
--allow-timeout URLs that time out are allowed
|
30
|
+
--base-url [base url] Base URL to use for relative links
|
30
31
|
-d, --request-delay [seconds] Set request delay
|
31
32
|
-t, --set-timeout [seconds] Set connection timeout
|
32
33
|
--skip-save-results Skip saving results
|
@@ -82,6 +83,9 @@ $ awesome_bot README.md --allow-timeout -t 5
|
|
82
83
|
$ awesome_bot README.md --allow 403,429
|
83
84
|
# allow status code errors 403 and 429
|
84
85
|
# --allow 301 would be similar to --allow-redirect
|
86
|
+
|
87
|
+
$ awesome_bot README.md --base-url https://github.com/IDR/idr-notebooks/blob/master/
|
88
|
+
# will check relative links using the base url provided
|
85
89
|
```
|
86
90
|
|
87
91
|
```shell
|
data/bin/assets/test-errors
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
|
2
2
|
3. [L056] 405 https://www.google.com/events/io
|
3
3
|
5. [L130] 500 http://decentralizecamp.com/
|
4
|
-
6. [L138] 405 https://emberfest.eu/
|
5
4
|
02. [L0138] 401 https://developer.apple.com/library/ios/referencelibrary/GettingStarted/DevelopiOSAppsSwift/
|
6
5
|
03. [L0145] 401 https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Introduction/Introduction.html
|
7
6
|
04. [L0146] 401 https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/OOP_ObjC/Introduction/Introduction.html
|
data/lib/awesome_bot/check.rb
CHANGED
@@ -12,15 +12,17 @@ module AwesomeBot
|
|
12
12
|
skip_dupe = false
|
13
13
|
timeout = nil
|
14
14
|
delay = 0
|
15
|
+
base = nil
|
15
16
|
else
|
16
17
|
white_listed = options['whitelist']
|
17
18
|
skip_dupe = options['allowdupe']
|
18
19
|
timeout = options['timeout']
|
19
20
|
delay = options['delay']
|
20
21
|
delay = 0 if delay.nil?
|
22
|
+
base = options['baseurl']
|
21
23
|
end
|
22
24
|
|
23
|
-
links = links_filter(links_find(content))
|
25
|
+
links = links_filter(links_find(content, base))
|
24
26
|
|
25
27
|
r = Result.new(links, white_listed)
|
26
28
|
r.skip_dupe = skip_dupe
|
data/lib/awesome_bot/cli.rb
CHANGED
@@ -23,6 +23,7 @@ module AwesomeBot
|
|
23
23
|
opts.on('--allow-ssl', TrueClass, 'SSL errors are allowed') { |val| options['allow_ssl'] = val }
|
24
24
|
opts.on('--allow-redirect', TrueClass, 'Redirected URLs are allowed') { |val| options['allow_redirect'] = val }
|
25
25
|
opts.on('--allow-timeout', TrueClass, 'URLs that time out are allowed') { |val| options['allow_timeout'] = val }
|
26
|
+
opts.on('--base-url [base url]', String, 'Base URL to use for relative links') { |val| options['base_url'] = val }
|
26
27
|
opts.on('-d', '--request-delay [seconds]', Integer, 'Set request delay') { |val| options['delay'] = val }
|
27
28
|
opts.on('-t', '--set-timeout [seconds]', Integer, 'Set connection timeout') { |val| options['timeout'] = val }
|
28
29
|
opts.on('--skip-save-results', TrueClass, 'Skip saving results') { |val| options['no_results'] = val }
|
@@ -77,6 +78,9 @@ module AwesomeBot
|
|
77
78
|
|
78
79
|
puts "> Checking links in #{filename}"
|
79
80
|
|
81
|
+
base = options['base_url']
|
82
|
+
puts "> Will check relative links with base URL #{base}" unless base.nil?
|
83
|
+
|
80
84
|
errors = options['errors']
|
81
85
|
puts "> Will allow errors: #{errors.join ','}" unless errors.nil?
|
82
86
|
|
@@ -113,7 +117,8 @@ module AwesomeBot
|
|
113
117
|
'allowdupe' => skip_dupe,
|
114
118
|
'delay' => delay,
|
115
119
|
'timeout' => timeout,
|
116
|
-
'whitelist' => white_listed
|
120
|
+
'whitelist' => white_listed,
|
121
|
+
'baseurl' => base
|
117
122
|
}
|
118
123
|
|
119
124
|
threads = delay == nil ? 10 : 1
|
data/lib/awesome_bot/links.rb
CHANGED
@@ -35,9 +35,21 @@ module AwesomeBot
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
def links_find(content)
|
38
|
+
def links_find(content, url_base=nil)
|
39
39
|
require 'uri'
|
40
|
-
URI.extract(content, /http()s?/)
|
40
|
+
ext = URI.extract(content, /http()s?/)
|
41
|
+
return ext if url_base.nil?
|
42
|
+
|
43
|
+
rel = get_relative_links content, url_base
|
44
|
+
return rel + ext
|
45
|
+
end
|
46
|
+
|
47
|
+
def get_relative_links(content, base)
|
48
|
+
links = content.scan /\].*?\)/
|
49
|
+
links.reject { |x| x.include?('http') || x.include?('#') }
|
50
|
+
.map { |x| x.sub '](', ''}
|
51
|
+
.map { |x| x =~ /\S/ ? x.match(/^\S*/) : x }
|
52
|
+
.map { |x| "#{base}#{x}"}
|
41
53
|
end
|
42
54
|
end # class
|
43
55
|
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.16.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: 2017-
|
11
|
+
date: 2017-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parallel
|