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 +1 -1
- data/README.md +0 -2
- data/documentup.json +9 -0
- data/lib/sniffles/sniffers.rb +2 -2
- data/lib/sniffles/version.rb +1 -1
- data/lib/sniffles.rb +17 -10
- data/spec/cassettes/google_com.yml +715 -716
- data/spec/cassettes/humemes_com.yml +2 -2
- data/spec/cassettes/pearsonified_com.yml +10 -10
- data/spec/cassettes/squidoo_com.yml +148 -146
- data/spec/sniffles/sniffers/analytics/google_analytics_spec.rb +3 -5
- data/spec/sniffles/sniffers/analytics/mixpanel_spec.rb +3 -5
- data/spec/sniffles/sniffers/analytics/quantcast_spec.rb +3 -5
- data/spec/sniffles/sniffers/cms/wordpress_spec.rb +9 -15
- data/spec/sniffles/sniffers_spec.rb +17 -4
- data/spec/sniffles_spec.rb +30 -4
- data/spec/spec_helper.rb +7 -3
- metadata +16 -17
- data/lib/sniffles/utils.rb +0 -7
- data/spec/cassettes/squidoo.yml +0 -515
- data/spec/cassettes/wordpress.yml +0 -902
- data/spec/sniffles/utils_spec.rb +0 -20
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
data/documentup.json
ADDED
data/lib/sniffles/sniffers.rb
CHANGED
@@ -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 = "**")
|
data/lib/sniffles/version.rb
CHANGED
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, *
|
9
|
+
def self.sniff(response_body, *args)
|
11
10
|
output = {}
|
12
11
|
|
13
|
-
if
|
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
|
-
|
19
|
-
if
|
20
|
-
output[
|
21
|
-
elsif
|
22
|
-
list_all_by_group[
|
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, "#{
|
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
|