linkey 1.3.0 → 1.4.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/lib/linkey.rb +58 -34
- data/lib/linkey/version.rb +1 -1
- data/linkey.gemspec +2 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aecb337d1fc6a5912ddbfdb8d5ab85571680eb19
|
4
|
+
data.tar.gz: 7f3e4c32377465f87300ef4324e3fa9612c4b836
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 749aa652254f43d038ca1199d8b8a4107612a0381847b38c0b33e451185d355cd30f0b2f66ff95fc6924687b3f836ae69c47874d1a872ac3e4834b1dc92a48b0
|
7
|
+
data.tar.gz: 36b71fc3fa9d8e7c3f83d796a511da1a21884b8f42495804e9a5cff80c1c11ad6dd4d456c782392b99e79c1e663634ce473ceff2ccc6b400960b70aa548b7508
|
data/lib/linkey.rb
CHANGED
@@ -28,7 +28,7 @@ module Linkey
|
|
28
28
|
|
29
29
|
def scan(page_links)
|
30
30
|
urls = page_links.scan(/^#{Regexp.quote(reg)}(?:|.+)?$/)
|
31
|
-
Getter.
|
31
|
+
Getter.new(urls, base).check
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
@@ -63,63 +63,87 @@ module Linkey
|
|
63
63
|
options = @smoke_urls["headers"]
|
64
64
|
headers = Hash[*options]
|
65
65
|
@smoke_urls["status_code"] ? status_code = @smoke_urls["status_code"] : status_code = 200
|
66
|
-
Getter.
|
66
|
+
Getter.new(urls, base, { :headers => headers }, status_code).check
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
70
|
class Getter
|
71
|
-
|
71
|
+
def initialize(paths, base, headers = {}, status = 200)
|
72
|
+
@paths = paths
|
73
|
+
@base = base
|
74
|
+
@headers = headers
|
75
|
+
@status = status
|
76
|
+
end
|
72
77
|
|
73
|
-
def
|
74
|
-
@output = []
|
78
|
+
def check
|
75
79
|
puts "Checking..."
|
76
80
|
|
77
|
-
|
78
|
-
|
79
|
-
requests = urls.map do |page_paths|
|
81
|
+
paths.each do |path|
|
80
82
|
begin
|
81
|
-
|
82
|
-
|
83
|
-
|
83
|
+
Typhoeus::Request.new(url(path), options).tap do |req|
|
84
|
+
req.on_complete { |r| parse_response(r, status) }
|
85
|
+
HYDRA.queue req
|
86
|
+
end
|
84
87
|
rescue
|
85
|
-
puts "Error with URL #{
|
88
|
+
puts "Error with URL #{path}, please check config"
|
86
89
|
end
|
87
90
|
end
|
88
91
|
|
89
92
|
HYDRA.run
|
90
|
-
|
91
|
-
requests.map do |request|
|
92
|
-
begin
|
93
|
-
status = request.response.code
|
94
|
-
url = request.response.options[:effective_url]
|
95
|
-
make_request(url, status, status_code)
|
96
|
-
rescue
|
97
|
-
puts "Unable to get status code"
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
93
|
check_for_broken
|
102
94
|
end
|
103
95
|
|
104
|
-
|
105
|
-
if status != status_code
|
106
|
-
puts "Status is NOT GOOD for #{url}, response is #{status}"
|
107
|
-
@output << url
|
108
|
-
else
|
109
|
-
puts "Status is #{status} for #{url}"
|
110
|
-
end
|
111
|
-
end
|
96
|
+
private
|
112
97
|
|
113
|
-
|
98
|
+
attr_reader :base, :headers, :paths, :status
|
99
|
+
|
100
|
+
HYDRA = Typhoeus::Hydra.new(:max_concurrency => 100)
|
101
|
+
|
102
|
+
def check_for_broken
|
114
103
|
puts "Checking"
|
115
|
-
if
|
104
|
+
if output.empty?
|
116
105
|
puts 'URL\'s are good, All Done!'
|
117
106
|
exit 0
|
118
107
|
else
|
119
108
|
puts "Buddy, you got a bad link"
|
120
|
-
puts
|
109
|
+
puts output
|
121
110
|
exit 1
|
122
111
|
end
|
123
112
|
end
|
113
|
+
|
114
|
+
def make_request(url, status, status_code)
|
115
|
+
if status != status_code
|
116
|
+
puts "Status is NOT GOOD for #{url}, response is #{status}"
|
117
|
+
output << url
|
118
|
+
else
|
119
|
+
puts "Status is #{status} for #{url}"
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
def options
|
124
|
+
{
|
125
|
+
:followlocation => true,
|
126
|
+
:ssl_verifypeer => false,
|
127
|
+
:headers => headers[:headers]
|
128
|
+
}
|
129
|
+
end
|
130
|
+
|
131
|
+
def output
|
132
|
+
@output ||= []
|
133
|
+
end
|
134
|
+
|
135
|
+
def parse_response(resp, status)
|
136
|
+
make_request(
|
137
|
+
resp.options[:effective_url],
|
138
|
+
resp.code,
|
139
|
+
status
|
140
|
+
)
|
141
|
+
rescue
|
142
|
+
puts "Unable to get status code"
|
143
|
+
end
|
144
|
+
|
145
|
+
def url(path)
|
146
|
+
"#{base}#{path}"
|
147
|
+
end
|
124
148
|
end
|
125
149
|
end
|
data/lib/linkey/version.rb
CHANGED
data/linkey.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: linkey
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dave Blooman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
description: Linkey
|
42
56
|
email:
|
43
57
|
- david.blooman@gmail.com
|