linkey 0.3.2 → 0.3.3

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: 0ddaf7abf726952442158a9cdee11371cec1a7f2
4
- data.tar.gz: b12f32b17cda71b19d2a46a3d854528fe33ae376
3
+ metadata.gz: 306512d00f55ed9b6c74b858c087621c420ad225
4
+ data.tar.gz: c3e26fd44a31553ae0be10d6cdaacc6de53943d4
5
5
  SHA512:
6
- metadata.gz: c11a6981001909f888f2790aa467082a1a06f19ed8913ad267ed93a1ae84fcffff09b9ada3d5d5ba5ebe2c9ee71fe24588031713244f4c0dd374d4591184d96d
7
- data.tar.gz: 4fd8cd1b04ccd043920e2c3e6b74f3e1ca72b61af0d333826ba1323d0b6aa1ca5bdffaab2f93a077535c5e4656d71a46f97d176aea8f813cd3d03698d96045b9
6
+ metadata.gz: 5483ae20a70fb78194753c4ccb6fcbb28c4e2d1cfe753761ea2813b3828343b24200a8f5a7ac218bd3c0a5eb4efc9411cd88a3d0bc9f4cf05a28b3d9490bc797
7
+ data.tar.gz: 10935afa6b84e205a1fcf9158f7fda8cc845560827c605b9d45ebeb50456dc3c2e4539f7152e1045f458f1d6a031ca0f188b0d3c0382f9f889c1395e4795d3b1
data/.travis.yml CHANGED
@@ -2,7 +2,7 @@ language: ruby
2
2
  rvm:
3
3
  - "2.0.0"
4
4
 
5
- script: "bundle exec bin/linkey check http://www.bbc.com/news http://www.bbc.com /news news.md"
5
+ script: "bundle exec bin/linkey check http://www.theguardian.com/technology/2014/feb/15/year-of-code-needs-reboot-teachers http://www.theguardian.com /technology news.md"
6
6
 
7
7
  notifications:
8
8
  email:
data/lib/linkey.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'linkey/version'
2
- require 'open-uri'
3
2
  require 'yaml'
4
3
  require 'parallel'
4
+ require 'typhoeus'
5
5
 
6
6
  module Linkey
7
7
  autoload :CLI, 'linkey/cli'
@@ -31,28 +31,32 @@ module Linkey
31
31
 
32
32
  def scan(page_links)
33
33
  urls = page_links.scan(/^#{Regexp.quote(reg)}(?:|.+)?$/)
34
- status(urls)
34
+ Getter.status(urls, base)
35
35
  end
36
+ end
36
37
 
37
- def status(urls)
38
+ class Getter
39
+ def self.status(urls, base, headers = {})
38
40
  @output = []
39
41
  puts 'Checking...'
40
42
  Parallel.each(urls, in_threads: 7) do |page_path|
41
- begin
42
- gets = open(base + page_path)
43
- status = gets.status.first
44
- puts "Status is #{status} for #{base}#{page_path}"
45
- rescue OpenURI::HTTPError
46
- if status != 200
47
- puts "Status is NOT GOOD for #{base}#{page_path}"
48
- @output << page_path
49
- end
50
- end
43
+ request = Typhoeus.get(base + page_path.chomp('/'), headers)
44
+ status = request.code
45
+ make_request(page_path, base, status)
51
46
  end
52
47
  check_for_broken
53
48
  end
54
49
 
55
- def check_for_broken
50
+ def self.make_request(page_path, base, status)
51
+ if status != 200
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
56
60
  puts 'Checking'
57
61
  if @output.empty?
58
62
  puts 'URL\'s are good, All Done!'
@@ -93,7 +97,9 @@ module Linkey
93
97
 
94
98
  def smoke
95
99
  urls = @smoke_urls['paths']
96
- status(urls)
100
+ options = @smoke_urls['headers']
101
+ headers = Hash[*options]
102
+ Getter.status(urls, base, headers: headers)
97
103
  end
98
104
  end
99
105
  end
@@ -1,3 +1,3 @@
1
1
  module Linkey
2
- VERSION = '0.3.2'
2
+ VERSION = '0.3.3'
3
3
  end
data/linkey.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ['david.blooman@gmail.com']
11
11
  spec.summary = 'Linkey'
12
12
  spec.description = 'Linkey'
13
- spec.homepage = 'http://responsivenews.co.uk'
13
+ spec.homepage = 'https://github.com/DaveBlooman/linkey'
14
14
  spec.license = 'Apache 2'
15
15
 
16
16
  spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
@@ -19,4 +19,5 @@ Gem::Specification.new do |spec|
19
19
 
20
20
  spec.add_runtime_dependency 'thor'
21
21
  spec.add_runtime_dependency 'parallel'
22
+ spec.add_runtime_dependency 'typhoeus'
22
23
  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: 0.3.2
4
+ version: 0.3.3
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-07-29 00:00:00.000000000 Z
11
+ date: 2014-07-30 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: typhoeus
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
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
@@ -58,7 +72,7 @@ files:
58
72
  - lib/linkey/javascript/snap.js
59
73
  - lib/linkey/version.rb
60
74
  - linkey.gemspec
61
- homepage: http://responsivenews.co.uk
75
+ homepage: https://github.com/DaveBlooman/linkey
62
76
  licenses:
63
77
  - Apache 2
64
78
  metadata: {}