linkey 1.0.1 → 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/README.md +1 -1
- data/lib/linkey.rb +43 -39
- data/lib/linkey/version.rb +1 -1
- data/linkey.gemspec +1 -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: f6e294d02da2617f8971fecb1502fe9fedaaa5af
|
4
|
+
data.tar.gz: 202c8139bd43e992f05c25fa04ed56cf93536057
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41b355392e5d5f6b92d5e60629605c5309972c052c6a42b67857d26e3ce83908994f7af991548f916e4f83595f09e10f351f0d58658ba79009374012d49ad29f
|
7
|
+
data.tar.gz: 426019334d31e407f4c8df359889517d0a6b70e611bccfab44f0f8c6349de9a47998b710c445ca3f1e1f04ce3fe9f445903fd2e258688f9023ef8e2a7099e433
|
data/README.md
CHANGED
data/lib/linkey.rb
CHANGED
@@ -2,6 +2,8 @@ require 'linkey/version'
|
|
2
2
|
require 'yaml'
|
3
3
|
require 'parallel'
|
4
4
|
require 'typhoeus'
|
5
|
+
require 'faraday'
|
6
|
+
require 'typhoeus/adapters/faraday'
|
5
7
|
|
6
8
|
module Linkey
|
7
9
|
autoload :CLI, 'linkey/cli'
|
@@ -17,10 +19,8 @@ module Linkey
|
|
17
19
|
end
|
18
20
|
|
19
21
|
def check_links
|
20
|
-
|
21
|
-
links
|
22
|
-
array << links
|
23
|
-
links(array)
|
22
|
+
links_list = File.read(file_name).split(',')
|
23
|
+
links(links_list)
|
24
24
|
end
|
25
25
|
|
26
26
|
def links(links)
|
@@ -35,40 +35,6 @@ module Linkey
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
class Getter
|
39
|
-
def self.status(urls, base, headers = {}, status_code = 200)
|
40
|
-
@output = []
|
41
|
-
puts 'Checking...'
|
42
|
-
Parallel.each(urls, in_threads: 4) do |page_path|
|
43
|
-
request = Typhoeus.get(base + page_path.chomp('/'), headers)
|
44
|
-
status = request.code
|
45
|
-
make_request(page_path, base, status, status_code)
|
46
|
-
end
|
47
|
-
check_for_broken
|
48
|
-
end
|
49
|
-
|
50
|
-
def self.make_request(page_path, base, status, status_code)
|
51
|
-
if status != status_code
|
52
|
-
puts "Status is NOT GOOD for #{base}#{page_path}, response is #{status}"
|
53
|
-
@output << page_path
|
54
|
-
else
|
55
|
-
puts "Status is #{status} for #{base}#{page_path}"
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def self.check_for_broken
|
60
|
-
puts 'Checking'
|
61
|
-
if @output.empty?
|
62
|
-
puts 'URL\'s are good, All Done!'
|
63
|
-
exit 0
|
64
|
-
else
|
65
|
-
puts 'Buddy, you got a broken link'
|
66
|
-
puts @output
|
67
|
-
exit 1
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
38
|
class SaveLinks
|
73
39
|
attr_accessor :url, :file_name
|
74
40
|
|
@@ -86,7 +52,7 @@ module Linkey
|
|
86
52
|
end
|
87
53
|
end
|
88
54
|
|
89
|
-
class Checker
|
55
|
+
class Checker
|
90
56
|
def initialize(config)
|
91
57
|
@smoke_urls = YAML.load(File.open("#{config}"))
|
92
58
|
end
|
@@ -103,4 +69,42 @@ module Linkey
|
|
103
69
|
Getter.status(urls, base, { headers: headers }, status_code)
|
104
70
|
end
|
105
71
|
end
|
72
|
+
|
73
|
+
class Getter
|
74
|
+
def self.status(urls, base, _headers = {}, status_code = 200)
|
75
|
+
@output = []
|
76
|
+
puts 'Checking...'
|
77
|
+
|
78
|
+
Parallel.each(urls, in_threads: 4) do |page_path|
|
79
|
+
|
80
|
+
request = Faraday.new(url: base, ssl: { verify: false }) do |faraday|
|
81
|
+
faraday.adapter :typhoeus
|
82
|
+
end
|
83
|
+
status = request.get(page_path).status
|
84
|
+
make_request(page_path, base, status, status_code)
|
85
|
+
end
|
86
|
+
check_for_broken
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.make_request(page_path, base, status, status_code)
|
90
|
+
if status != status_code
|
91
|
+
puts "Status is NOT GOOD for #{base}#{page_path}, response is #{status}"
|
92
|
+
@output << page_path
|
93
|
+
else
|
94
|
+
puts "Status is #{status} for #{base}#{page_path}"
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def self.check_for_broken
|
99
|
+
puts 'Checking'
|
100
|
+
if @output.empty?
|
101
|
+
puts 'URL\'s are good, All Done!'
|
102
|
+
exit 0
|
103
|
+
else
|
104
|
+
puts 'Buddy, you got a broken link'
|
105
|
+
puts @output
|
106
|
+
exit 1
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
106
110
|
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.0
|
4
|
+
version: 1.1.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: 2014-
|
11
|
+
date: 2014-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
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'
|
55
69
|
description: Linkey
|
56
70
|
email:
|
57
71
|
- david.blooman@gmail.com
|