linkey 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +8 -0
- data/lib/linkey.rb +29 -15
- data/lib/linkey/version.rb +1 -1
- data/linkey.gemspec +0 -3
- metadata +2 -44
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7cf7d38db7c5c755398ed59a5523d7d33051e1d8
|
4
|
+
data.tar.gz: 8b4751d3e83b5021b1a794b99e7389d51003f960
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c9780f42a16f54e4f9c5a272e72ecd5b3d0fe798e834ec1d9722709f533e965e4a9e5a8d338df667334d07bd7e630d14b1434e14bdac343a0a03f125cbbc181
|
7
|
+
data.tar.gz: 4dea5a21089542399ae016d129ca922fb9ed36071a404d2b1d78f12187aa8927e3fc0070b0c8690d97de64ab11c5529605a3143c246a897f2c7bd336194895d5
|
data/.rubocop.yml
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
AllCops:
|
2
|
+
Exclude:
|
3
|
+
- "**/*.gemspec"
|
4
|
+
|
1
5
|
Lint/SpaceBeforeFirstArg:
|
2
6
|
Severity: fatal
|
3
7
|
Enabled: true
|
@@ -33,6 +37,10 @@ Style/BracesAroundHashParameters:
|
|
33
37
|
Severity: fatal
|
34
38
|
Enabled: true
|
35
39
|
|
40
|
+
ClassAndModuleChildren:
|
41
|
+
Severity: fatal
|
42
|
+
Enabled: true
|
43
|
+
|
36
44
|
Style/ConstantName:
|
37
45
|
Severity: fatal
|
38
46
|
Enabled: true
|
data/lib/linkey.rb
CHANGED
@@ -1,10 +1,6 @@
|
|
1
1
|
require "linkey/version"
|
2
2
|
require "yaml"
|
3
|
-
require "parallel"
|
4
3
|
require "typhoeus"
|
5
|
-
require "faraday"
|
6
|
-
require "typhoeus/adapters/faraday"
|
7
|
-
require 'faraday_middleware'
|
8
4
|
|
9
5
|
module Linkey
|
10
6
|
autoload :CLI, "linkey/cli"
|
@@ -72,27 +68,45 @@ module Linkey
|
|
72
68
|
end
|
73
69
|
|
74
70
|
class Getter
|
71
|
+
HYDRA = Typhoeus::Hydra.new(:max_concurrency => 100)
|
72
|
+
|
75
73
|
def self.status(urls, base, headers = {}, status_code = 200)
|
76
74
|
@output = []
|
77
75
|
puts "Checking..."
|
78
76
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
77
|
+
options = { :followlocation => true, :ssl_verifypeer => false, :headers => headers[:headers] }
|
78
|
+
|
79
|
+
requests = urls.map do |page_paths|
|
80
|
+
begin
|
81
|
+
request = Typhoeus::Request.new(base + page_paths, options)
|
82
|
+
HYDRA.queue(request)
|
83
|
+
request
|
84
|
+
rescue
|
85
|
+
puts "Error with URL #{page_paths}, please check config"
|
83
86
|
end
|
84
|
-
status = request.get(page_path).status
|
85
|
-
make_request(page_path, base, status, status_code)
|
86
87
|
end
|
88
|
+
|
89
|
+
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
|
+
|
87
101
|
check_for_broken
|
88
102
|
end
|
89
103
|
|
90
|
-
def self.make_request(
|
104
|
+
def self.make_request(url, status, status_code)
|
91
105
|
if status != status_code
|
92
|
-
puts "Status is NOT GOOD for #{
|
93
|
-
@output <<
|
106
|
+
puts "Status is NOT GOOD for #{url}, response is #{status}"
|
107
|
+
@output << url
|
94
108
|
else
|
95
|
-
puts "Status is #{status} for #{
|
109
|
+
puts "Status is #{status} for #{url}"
|
96
110
|
end
|
97
111
|
end
|
98
112
|
|
@@ -102,7 +116,7 @@ module Linkey
|
|
102
116
|
puts 'URL\'s are good, All Done!'
|
103
117
|
exit 0
|
104
118
|
else
|
105
|
-
puts "Buddy, you got a
|
119
|
+
puts "Buddy, you got a bad link"
|
106
120
|
puts @output
|
107
121
|
exit 1
|
108
122
|
end
|
data/lib/linkey/version.rb
CHANGED
data/linkey.gemspec
CHANGED
@@ -18,8 +18,5 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
20
|
spec.add_runtime_dependency "thor"
|
21
|
-
spec.add_runtime_dependency "parallel"
|
22
21
|
spec.add_runtime_dependency "typhoeus"
|
23
|
-
spec.add_runtime_dependency "faraday"
|
24
|
-
spec.add_runtime_dependency "faraday_middleware"
|
25
22
|
end
|
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.3.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-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: parallel
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - '>='
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - '>='
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: typhoeus
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,34 +38,6 @@ dependencies:
|
|
52
38
|
- - '>='
|
53
39
|
- !ruby/object:Gem::Version
|
54
40
|
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: faraday
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - '>='
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: faraday_middleware
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - '>='
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :runtime
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - '>='
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
41
|
description: Linkey
|
84
42
|
email:
|
85
43
|
- david.blooman@gmail.com
|