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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3317c91687d43df81b226480c1f94828c32e300d
4
- data.tar.gz: 3bc742e615d7d45b28dbf0eee5d8d144d7497957
3
+ metadata.gz: f6e294d02da2617f8971fecb1502fe9fedaaa5af
4
+ data.tar.gz: 202c8139bd43e992f05c25fa04ed56cf93536057
5
5
  SHA512:
6
- metadata.gz: 38d0eb2d3521991f9992233d72ed22c955099b859af5b3b4c43f9c96d7f95c534ed9e9a0fbb2b308081b865c294094862ed56827b308ca98623d80a165495875
7
- data.tar.gz: 519d6d05130f0123665f0b96f9372f99cbf2c0bb66dd4addd50511944b291ccc8e126c8d72af7ba8258ce7f117cc04eeb663b3039b8e6a01447e4e0da2060001
6
+ metadata.gz: 41b355392e5d5f6b92d5e60629605c5309972c052c6a42b67857d26e3ce83908994f7af991548f916e4f83595f09e10f351f0d58658ba79009374012d49ad29f
7
+ data.tar.gz: 426019334d31e407f4c8df359889517d0a6b70e611bccfab44f0f8c6349de9a47998b710c445ca3f1e1f04ce3fe9f445903fd2e258688f9023ef8e2a7099e433
data/README.md CHANGED
@@ -29,7 +29,7 @@ linkey check URL BASEURL /regex Filename
29
29
  Example
30
30
 
31
31
  ```
32
- linkey check http://www.live.bbc.co.uk/arabic http://www.live.bbc.co.uk /arabic arabic.md
32
+ linkey check http://www.bbc.co.uk/arabic http://www.bbc.co.uk /arabic arabic.md
33
33
  ```
34
34
  Another
35
35
 
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
- array = []
21
- links = File.read(file_name)
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 < CheckResponse
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
@@ -1,3 +1,3 @@
1
1
  module Linkey
2
- VERSION = '1.0.1'
2
+ VERSION = '1.1.0'
3
3
  end
data/linkey.gemspec CHANGED
@@ -20,4 +20,5 @@ Gem::Specification.new do |spec|
20
20
  spec.add_runtime_dependency 'thor'
21
21
  spec.add_runtime_dependency 'parallel'
22
22
  spec.add_runtime_dependency 'typhoeus'
23
+ spec.add_runtime_dependency 'faraday'
23
24
  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.0.1
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-10-10 00:00:00.000000000 Z
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