blinkr 0.3.1 → 0.3.2
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/bin/blinkr +7 -1
- data/lib/blinkr/extensions/links.rb +4 -0
- data/lib/blinkr/hacks.rb +5 -5
- data/lib/blinkr/typhoeus_wrapper.rb +21 -0
- data/lib/blinkr/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f3dba6e6e0d389b3760f1f8e5fed683f52f93bd
|
4
|
+
data.tar.gz: bf28ba4b5e000d6492429e92409a97434e628106
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ade22d86f835fe6addb8262bd416d3f8cd797ba342aa447b7bd6ff76080229a81189b56538c789de67e1bd1461a57657c6c11075571ef0820bec19bc746b670
|
7
|
+
data.tar.gz: 819b85bfc6f8fd85ccd13040a0cb3832444a7019f97f5b16f4fa402f26694f996dbe3bfdd414127e002d996837b809b40a9f9434c4d44ef4062c994070605f02
|
data/bin/blinkr
CHANGED
@@ -26,5 +26,11 @@ OptionParser.new do |opts|
|
|
26
26
|
end
|
27
27
|
end.parse!
|
28
28
|
|
29
|
-
|
29
|
+
require 'blinkr/hacks'
|
30
|
+
require 'date'
|
31
|
+
start = DateTime.now
|
32
|
+
puts "Started at #{start.to_s}"
|
33
|
+
Blinkr.run options[:base_url].freeze, options[:config].freeze, options[:single_url].freeze,
|
34
|
+
options[:verbose].freeze, options[:vverbose].freeze
|
35
|
+
puts "Total time: #{(DateTime.now.to_time - start.to_time).duration}"
|
30
36
|
|
@@ -31,6 +31,8 @@ module Blinkr
|
|
31
31
|
puts '----------------------'
|
32
32
|
puts " #{@links.length} links to check "
|
33
33
|
puts '----------------------'
|
34
|
+
start = DateTime.now
|
35
|
+
|
34
36
|
external_links = @links.reject { |k| k.start_with? @config.base_url }
|
35
37
|
processed = 0
|
36
38
|
# Find the internal links
|
@@ -59,6 +61,7 @@ module Blinkr
|
|
59
61
|
# if link start_with? @config.base_url check to see if it's in the sitemap.xml
|
60
62
|
browser.process(url, @config.max_retrys, :method => :get, :followlocation => true) do |resp|
|
61
63
|
puts "Loaded #{url} via #{browser.name} #{'(cached)' if resp.cached?}" if @config.verbose
|
64
|
+
|
62
65
|
if resp.code.to_i < 200 || resp.code.to_i > 300
|
63
66
|
response = resp
|
64
67
|
|
@@ -89,6 +92,7 @@ module Blinkr
|
|
89
92
|
end
|
90
93
|
end
|
91
94
|
browser.hydra.run if browser.is_a? Blinkr::TyphoeusWrapper
|
95
|
+
puts "Total time in links: #{(DateTime.now.to_time - start.to_time).duration}" if @config.verbose
|
92
96
|
end
|
93
97
|
|
94
98
|
end
|
data/lib/blinkr/hacks.rb
CHANGED
@@ -11,10 +11,10 @@ class Numeric
|
|
11
11
|
# self.duration_as_arr.zip ['Days','Hours','Minutes','Seconds']).flatten.join ' '
|
12
12
|
|
13
13
|
result = []
|
14
|
-
result << "#{days}
|
15
|
-
result << "#{hours}
|
16
|
-
result << "#{mins}
|
17
|
-
result << "#{secs}
|
18
|
-
|
14
|
+
result << "#{days} days" if days > 0
|
15
|
+
result << "#{hours} hours" if hours > 0
|
16
|
+
result << "#{mins} minutes" if mins > 0
|
17
|
+
result << "#{secs} seconds" if secs > 0
|
18
|
+
result.join(' ')
|
19
19
|
end
|
20
20
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'typhoeus'
|
2
2
|
require 'blinkr/cache'
|
3
3
|
require 'blinkr/http_utils'
|
4
|
+
require 'net/http'
|
4
5
|
|
5
6
|
module Blinkr
|
6
7
|
class TyphoeusWrapper
|
@@ -76,6 +77,26 @@ module Blinkr
|
|
76
77
|
)
|
77
78
|
req.on_complete do |resp|
|
78
79
|
if retry? resp
|
80
|
+
if resp.code.to_i == 0
|
81
|
+
puts "Response code of '0', using net/http for #{url}" if @config.verbose
|
82
|
+
response = nil
|
83
|
+
|
84
|
+
begin
|
85
|
+
uri = URI::parse url
|
86
|
+
http_response = Net::HTTP.get_response(uri)
|
87
|
+
response = Typhoeus::Response.new(:code => http_response.code, :status_message => http_response.message,
|
88
|
+
:mock => true)
|
89
|
+
rescue
|
90
|
+
response = Typhoeus::Response.new(:code => 410, :status_message => 'Could not reach the resource',
|
91
|
+
:mock => true)
|
92
|
+
end
|
93
|
+
|
94
|
+
response.request = Typhoeus::Request.new(url)
|
95
|
+
Typhoeus.stub(url).and_return(response)
|
96
|
+
block.call response, nil, nil
|
97
|
+
next
|
98
|
+
end
|
99
|
+
|
79
100
|
if limit > 1
|
80
101
|
puts "Loading #{url} via typhoeus (attempt #{max - limit + 2} of #{max})" if @config.verbose
|
81
102
|
_process(url, limit - 1, max, &Proc.new)
|
data/lib/blinkr/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blinkr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pete Muir
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-08-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -157,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
157
|
version: '0'
|
158
158
|
requirements: []
|
159
159
|
rubyforge_project:
|
160
|
-
rubygems_version: 2.
|
160
|
+
rubygems_version: 2.4.8
|
161
161
|
signing_key:
|
162
162
|
specification_version: 4
|
163
163
|
summary: A simple broken link checker
|