sniffles 0.1.0 → 0.1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sniffles (0.0.3)
4
+ sniffles (0.1.0.1)
5
5
  nokogiri (~> 1.5.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,6 +1,4 @@
1
1
  # Sniffles
2
- !["Travis Build Status"](https://secure.travis-ci.org/ezkl/sniffles.png?branch=master)
3
-
4
2
  ## Description
5
3
  Sniffles parses HTML pages and searches for common patterns suggesting a page is using popular CMS, CSS, and JS libraries.
6
4
 
data/documentup.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "Sniffles",
3
+ "twitter": [
4
+ "ezkl"
5
+ ],
6
+ "issues": true,
7
+ "travis": true,
8
+ "google_analytics": "UA-29679939-1"
9
+ }
@@ -1,10 +1,10 @@
1
1
  module Sniffles
2
2
  module Sniffers
3
3
  def self.use(response_body, name)
4
- file = Dir.glob("lib/sniffles/sniffers/**/#{name.to_s}.rb").first
4
+ file = Dir.glob("lib/sniffles/sniffers/**/#{name.to_s}.rb").first
5
5
  class_name = get_sniffer_class(name.to_s)
6
6
  require File.expand_path(File.dirname(__FILE__) + "/../../#{file}")
7
- eval("Sniffers::#{class_name}.new(response_body).output")
7
+ eval("Sniffles::Sniffers::#{class_name}.new(response_body).output")
8
8
  end
9
9
 
10
10
  def self.list_all(group = "**")
@@ -1,3 +1,3 @@
1
1
  module Sniffles
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.0.1"
3
3
  end
data/lib/sniffles.rb CHANGED
@@ -1,29 +1,28 @@
1
1
  require 'nokogiri'
2
2
 
3
3
  require 'sniffles/version'
4
- require 'sniffles/sniffers'
5
- require 'sniffles/utils'
6
4
  require 'sniffles/html'
7
5
  require 'sniffles/text'
6
+ require 'sniffles/sniffers'
8
7
 
9
8
  module Sniffles
10
- def self.sniff(response_body, *sniffers_or_groups)
9
+ def self.sniff(response_body, *args)
11
10
  output = {}
12
11
 
13
- if sniffers_or_groups.empty?
12
+ if args.empty?
14
13
  list_all.each do |sniffer|
15
14
  output[sniffer] = Sniffers.use(response_body, sniffer)
16
15
  end
17
16
  else
18
- sniffers_or_groups.each do |sniffer_or_group|
19
- if list_all.include?(sniffer_or_group)
20
- output[sniffer_or_group] = Sniffers.use(response_body, sniffer_or_group)
21
- elsif list_groups.include?(sniffer_or_group)
22
- list_all_by_group[sniffer_or_group].each do |sniffer|
17
+ args.each do |arg|
18
+ if sniffer?(arg)
19
+ output[arg] = Sniffers.use(response_body, arg)
20
+ elsif group?(arg)
21
+ list_all_by_group[arg].each do |sniffer|
23
22
  output[sniffer] = Sniffers.use(response_body, sniffer)
24
23
  end
25
24
  else
26
- raise UnknownSniffer, "#{sniffer_or_group} not found!"
25
+ raise UnknownSniffer, "#{arg} not found!"
27
26
  end
28
27
  end
29
28
  end
@@ -42,5 +41,13 @@ module Sniffles
42
41
  Sniffers.list_all_by_group
43
42
  end
44
43
 
44
+ def self.group?(name)
45
+ list_groups.include?(name)
46
+ end
47
+
48
+ def self.sniffer?(name)
49
+ list_all.include?(name)
50
+ end
51
+
45
52
  class UnknownSniffer < Exception;end
46
53
  end