site-inspector 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4942c0885c9e08824ecde08d6b29864ef028f94f
4
- data.tar.gz: 95b45f2c948946eca91f1d37c46b9c868afb6aa3
3
+ metadata.gz: 081857089e6dd0832b6fd0553615c02c74ba271b
4
+ data.tar.gz: aaa19892e68cf24c05898e44e2314413976819a1
5
5
  SHA512:
6
- metadata.gz: 5a953be1f1a17923acfd4b1565ca3ceca28a0b06dc64bf4e9caa9308865496134de31fcde53b1562263dd77ebf7c3aabba3c421ee965040f08d145e2a344093e
7
- data.tar.gz: 7e9af2ba7bc62fb0bc4895acb5d99c500673cbb664ba457cd7f00d9a5c90102fbb16bba960fff7d3df6ffa62b0c61312f418058e008e96df8bbc77ae6b25418a
6
+ metadata.gz: 613c90276d90b35a8d74502893f6d4bf2579c84f4f399c34c7ee33c3722f92af29e12796d7c733a8503903e63eb85e49f940379ca40d41c55ce1aa5660437181
7
+ data.tar.gz: 6ddf58171d7c76d8a0f5b029b94878a76e1b68b3becb6dc6c48b972389c9c94e48f5e7ff56ad52b3b00dab8b02aa6620c083920dbe97e2228de6d513ad52c8d1
@@ -24,7 +24,7 @@ class SiteInspector
24
24
 
25
25
  def detect_by_hostname(type)
26
26
 
27
- haystack = load_data(type)
27
+ haystack = SiteInspector.load_data(type)
28
28
  needle = haystack.find { |name, domain|
29
29
  cnames.any? { |cname|
30
30
  domain == cname.tld || domain == "#{cname.sld}.#{cname.tld}"
@@ -46,14 +46,14 @@ class SiteInspector
46
46
  end
47
47
 
48
48
  def secure_cookies?
49
- return nil if !has_cookies?
49
+ return false if !has_cookies?
50
50
  cookie = headers["set-cookie"]
51
51
  cookie = cookie.first if cookie.is_a?(Array)
52
52
  !!(cookie =~ /(; secure.*; httponly|; httponly.*; secure)/i)
53
53
  end
54
54
 
55
- # Returns an array of hashes of downcased key/value header pairs (or nil)
55
+ # Returns an array of hashes of downcased key/value header pairs (or an empty hash)
56
56
  def headers
57
- @headers ||= Hash[response.headers.map{ |k,v| [k.downcase,v] }] if response
57
+ @headers ||= response ? Hash[response.headers.map{ |k,v| [k.downcase,v] }] : {}
58
58
  end
59
59
  end
@@ -3,6 +3,8 @@ class SiteInspector
3
3
  results = Sniffles.sniff(body, type).select { |name, meta| meta[:found] == true }
4
4
  results.each { |name, result| result.delete :found} if results
5
5
  results
6
+ rescue
7
+ nil
6
8
  end
7
9
 
8
10
  def cms
@@ -20,5 +22,4 @@ class SiteInspector
20
22
  def advertising
21
23
  sniff :advertising
22
24
  end
23
-
24
25
  end
@@ -21,6 +21,10 @@ Typhoeus::Config.cache = SiteInspectorCache.new
21
21
 
22
22
  class SiteInspector
23
23
 
24
+ def self.load_data(name)
25
+ YAML.load_file File.expand_path "./data/#{name}.yml", File.dirname(__FILE__)
26
+ end
27
+
24
28
  def initialize(domain)
25
29
  domain = domain.downcase
26
30
  domain = domain.sub /^https?\:/, ""
@@ -46,7 +50,7 @@ class SiteInspector
46
50
  end
47
51
 
48
52
  def request(ssl=false, www=false, followlocation=true)
49
- Typhoeus::Request.get(uri(ssl, www), followlocation: followlocation, timeout: 10)
53
+ Typhoeus.get(uri(ssl, www), followlocation: followlocation, timeout: 10)
50
54
  end
51
55
 
52
56
  def response
@@ -75,10 +79,6 @@ class SiteInspector
75
79
  doc.to_s.force_encoding("UTF-8").encode("UTF-8", :invalid => :replace, :replace => "")
76
80
  end
77
81
 
78
- def load_data(name)
79
- YAML.load_file File.expand_path "./data/#{name}.yml", File.dirname(__FILE__)
80
- end
81
-
82
82
  def government?
83
83
  Gman.valid? domain.to_s
84
84
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: site-inspector
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Balter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-06 00:00:00.000000000 Z
11
+ date: 2015-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri