awesome_bot 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +8 -12
- data/bin/assets/test-bad-link +3 -0
- data/lib/awesome_bot/check.rb +5 -3
- data/lib/awesome_bot/statuses.rb +16 -5
- data/lib/awesome_bot/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8feb264201072a97f70c9146f636d95bcd5fca77
|
4
|
+
data.tar.gz: 5762b4ef3b0584cd155b87dd3ba81cb5347f6a1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00f748d97bc39f0ad148288611ed8252dc0d1f242da3b948146a0cae7e3c373063fc9df67f14990dff622e9ae01b81934018a00b28931d2a425ac643d3df8dd1
|
7
|
+
data.tar.gz: 023bad1bc68ee5b59915ac10cd2ccad6fe3d77626318b886fe8a1ad5c3da1bd51d1707020d2396165589e3efe54d725816b7d35706c66d734c94c3a790555840
|
data/CHANGELOG.md
CHANGED
@@ -13,6 +13,13 @@
|
|
13
13
|
- [gemspec] update
|
14
14
|
- [travis] simplify
|
15
15
|
|
16
|
+
## 1.1.0
|
17
|
+
|
18
|
+
- handle bad links
|
19
|
+
- statuses yields `status`, `url`
|
20
|
+
- add head option when getting statuses
|
21
|
+
- [cli] improve output for `--allow-dupe`
|
22
|
+
|
16
23
|
## Contact
|
17
24
|
|
18
25
|
- [github.com/dkhamsing](https://github.com/dkhamsing)
|
data/README.md
CHANGED
@@ -11,15 +11,15 @@
|
|
11
11
|
|
12
12
|
## Installation
|
13
13
|
|
14
|
-
Add this line to your application's Gemfile
|
14
|
+
Add this line to your application's Gemfile
|
15
15
|
|
16
|
-
gem 'awesome_bot'
|
16
|
+
gem 'awesome_bot'
|
17
17
|
|
18
|
-
And then execute
|
18
|
+
And then execute
|
19
19
|
|
20
20
|
$ bundle
|
21
21
|
|
22
|
-
Or install it yourself as
|
22
|
+
Or install it yourself as
|
23
23
|
|
24
24
|
$ gem install awesome_bot
|
25
25
|
|
@@ -38,7 +38,7 @@ irb(main):003:0> AwesomeBot.check c
|
|
38
38
|
# otherwise returning true
|
39
39
|
```
|
40
40
|
|
41
|
-
More information at [rubydoc](http://www.rubydoc.info/gems/awesome_bot/
|
41
|
+
More information at [rubydoc](http://www.rubydoc.info/gems/awesome_bot/1.1.0).
|
42
42
|
|
43
43
|
### Command Line
|
44
44
|
|
@@ -110,13 +110,9 @@ language: ruby
|
|
110
110
|
rvm:
|
111
111
|
- 2.2
|
112
112
|
before_script:
|
113
|
-
-
|
114
|
-
|
115
|
-
-
|
116
|
-
- cd awesome_bot-master
|
117
|
-
- bundle install
|
118
|
-
script:
|
119
|
-
- awesome_bot ../README.md
|
113
|
+
- gem install awesome_bot
|
114
|
+
script:
|
115
|
+
- awesome_bot README.md
|
120
116
|
```
|
121
117
|
|
122
118
|
## Credits
|
data/lib/awesome_bot/check.rb
CHANGED
@@ -13,7 +13,7 @@ module AwesomeBot
|
|
13
13
|
def check(content, white_listed = nil, skip_dupe = false, verbose = false)
|
14
14
|
dupe_success = skip_dupe
|
15
15
|
|
16
|
-
puts '> Will
|
16
|
+
puts '> Will allow duplicate links' if skip_dupe && verbose
|
17
17
|
|
18
18
|
white_listing = !white_listed.nil?
|
19
19
|
puts "> White list: #{white_listed.join ', '}" if white_listing && verbose
|
@@ -34,7 +34,9 @@ module AwesomeBot
|
|
34
34
|
|
35
35
|
print 'Checking URLs: ' if verbose && (links.count > 0)
|
36
36
|
statuses =
|
37
|
-
statuses
|
37
|
+
statuses(links.uniq, NUMBER_OF_THREADS) do |s|
|
38
|
+
print(s == 200 ? STATUS_OK : STATUS_OTHER) if verbose
|
39
|
+
end
|
38
40
|
puts '' if verbose
|
39
41
|
|
40
42
|
statuses_issues = statuses.select { |x| x['status'] != 200 }
|
@@ -58,7 +60,7 @@ module AwesomeBot
|
|
58
60
|
puts " All OK #{STATUS_OK}"
|
59
61
|
else
|
60
62
|
statuses_issues.each_with_index do |x, k|
|
61
|
-
puts " #{k + 1}. #{x['status']} #{x['url']} "
|
63
|
+
puts " #{k + 1}. #{x['status']}: #{x['url']} "
|
62
64
|
end
|
63
65
|
end
|
64
66
|
|
data/lib/awesome_bot/statuses.rb
CHANGED
@@ -4,17 +4,28 @@ module AwesomeBot
|
|
4
4
|
require 'parallel'
|
5
5
|
|
6
6
|
class << self
|
7
|
-
def
|
7
|
+
def net_head_status(url)
|
8
|
+
Faraday.head(url).status
|
9
|
+
end
|
10
|
+
|
11
|
+
def net_get_status(url)
|
8
12
|
Faraday.get(url).status
|
9
13
|
end
|
10
14
|
|
11
|
-
def
|
15
|
+
def net_status(url, head)
|
16
|
+
head ? net_head_status(url) : net_get_status(url)
|
17
|
+
end
|
18
|
+
|
19
|
+
def statuses(links, threads, head = false)
|
12
20
|
statuses = []
|
13
21
|
Parallel.each(links, in_threads: threads) do |u|
|
14
|
-
|
15
|
-
|
16
|
-
|
22
|
+
begin
|
23
|
+
status = net_status u, head
|
24
|
+
rescue => e
|
25
|
+
status = e
|
26
|
+
end
|
17
27
|
|
28
|
+
yield status, u
|
18
29
|
statuses.push('url' => u, 'status' => status)
|
19
30
|
end # Parallel
|
20
31
|
|
data/lib/awesome_bot/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awesome_bot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Khamsing
|
@@ -82,6 +82,7 @@ files:
|
|
82
82
|
- README.md
|
83
83
|
- Rakefile
|
84
84
|
- awesome_bot.gemspec
|
85
|
+
- bin/assets/test-bad-link
|
85
86
|
- bin/assets/test-dupe
|
86
87
|
- bin/assets/test-link-issue
|
87
88
|
- bin/assets/test-no-dupes
|