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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7b94c57d6ea72b04ee98820691f8bc15c203232a
4
- data.tar.gz: 3db6a0e7ef0533d89688b044f73b3b457e926ce3
3
+ metadata.gz: 7cf7d38db7c5c755398ed59a5523d7d33051e1d8
4
+ data.tar.gz: 8b4751d3e83b5021b1a794b99e7389d51003f960
5
5
  SHA512:
6
- metadata.gz: 61ad15a2d2cc0b56ec2eb59b4762bec6c6b77d9c7815582dade5bfee497587f486db30560fe20824e5940a3648fedfbb69ef04c37a6b80b4df8a77d3460a7f8b
7
- data.tar.gz: a3d66df5a6378ccd868567726c2c62a3876e262a3d978a3fef80c1991ac6904f9b47df628b757a8373f0986649142653c88b863b49bfe3dfb04510ff15580842
6
+ metadata.gz: 6c9780f42a16f54e4f9c5a272e72ecd5b3d0fe798e834ec1d9722709f533e965e4a9e5a8d338df667334d07bd7e630d14b1434e14bdac343a0a03f125cbbc181
7
+ data.tar.gz: 4dea5a21089542399ae016d129ca922fb9ed36071a404d2b1d78f12187aa8927e3fc0070b0c8690d97de64ab11c5529605a3143c246a897f2c7bd336194895d5
@@ -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
@@ -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
- Parallel.each(urls, :in_threads => 4) do |page_path|
80
- request = Faraday.new(:url => base, :ssl => { :verify => false }, :headers => headers[:headers]) do |faraday|
81
- faraday.use FaradayMiddleware::FollowRedirects
82
- faraday.adapter :typhoeus
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(page_path, base, status, status_code)
104
+ def self.make_request(url, status, status_code)
91
105
  if status != status_code
92
- puts "Status is NOT GOOD for #{base}#{page_path}, response is #{status}"
93
- @output << page_path
106
+ puts "Status is NOT GOOD for #{url}, response is #{status}"
107
+ @output << url
94
108
  else
95
- puts "Status is #{status} for #{base}#{page_path}"
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 broken link"
119
+ puts "Buddy, you got a bad link"
106
120
  puts @output
107
121
  exit 1
108
122
  end
@@ -1,3 +1,3 @@
1
1
  module Linkey
2
- VERSION = "1.2.0"
2
+ VERSION = "1.3.0"
3
3
  end
@@ -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.2.0
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-17 00:00:00.000000000 Z
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