sniffles 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. data/.gitignore +1 -0
  2. data/README.md +53 -2
  3. data/lib/sniffles/sniffers/advertising/admeld.rb +24 -0
  4. data/lib/sniffles/sniffers/advertising/adsense.rb +30 -0
  5. data/lib/sniffles/sniffers/advertising/buysellads.rb +24 -0
  6. data/lib/sniffles/sniffers/advertising/casale.rb +24 -0
  7. data/lib/sniffles/sniffers/analytics/chartbeat.rb +24 -0
  8. data/lib/sniffles/sniffers/analytics/clicky.rb +24 -0
  9. data/lib/sniffles/sniffers/analytics/google_analytics.rb +4 -3
  10. data/lib/sniffles/sniffers/analytics/kissmetrics.rb +24 -0
  11. data/lib/sniffles/sniffers/analytics/mixpanel.rb +2 -2
  12. data/lib/sniffles/sniffers/analytics/quantcast.rb +2 -2
  13. data/lib/sniffles/sniffers/cms/blogger.rb +28 -0
  14. data/lib/sniffles/sniffers/cms/cscart.rb +24 -0
  15. data/lib/sniffles/sniffers/cms/movabletype.rb +28 -0
  16. data/lib/sniffles/sniffers/cms/oscommerce.rb +24 -0
  17. data/lib/sniffles/sniffers/cms/phpbb.rb +27 -0
  18. data/lib/sniffles/sniffers/cms/posterous.rb +28 -0
  19. data/lib/sniffles/sniffers/cms/tumblr.rb +24 -0
  20. data/lib/sniffles/sniffers/cms/vanilla.rb +24 -0
  21. data/lib/sniffles/sniffers/cms/vbulletin.rb +39 -0
  22. data/lib/sniffles/sniffers/cms/wordpress.rb +7 -6
  23. data/lib/sniffles/sniffers/cms/xenforo.rb +28 -0
  24. data/lib/sniffles/sniffers/cms/zencart.rb +28 -0
  25. data/lib/sniffles/sniffers/javascript/jquery.rb +2 -2
  26. data/lib/sniffles/version.rb +1 -1
  27. data/lib/sniffles.rb +1 -1
  28. data/spec/cassettes/beenverified_com.yml +798 -0
  29. data/spec/cassettes/blog_posterous_com.yml +5015 -0
  30. data/spec/cassettes/demo_cs-cart_com.yml +1167 -0
  31. data/spec/cassettes/demo_oscommerce_com.yml +422 -0
  32. data/spec/cassettes/forum-software_org_vanilla.yml +223 -0
  33. data/spec/cassettes/foursquare_com.yml +363 -0
  34. data/spec/cassettes/google_blogspot_com.yml +1073 -0
  35. data/spec/cassettes/guistyles_com.yml +1306 -0
  36. data/spec/cassettes/humemes_com.yml +2 -2
  37. data/spec/cassettes/movabletype_com_blog.yml +1234 -0
  38. data/spec/cassettes/orangecrushbeads_com.yml +751 -0
  39. data/spec/cassettes/pearsonified_com.yml +11 -11
  40. data/spec/cassettes/phpbb_com.yml +466 -0
  41. data/spec/cassettes/squidoo_com.yml +466 -458
  42. data/spec/cassettes/staff_tumblr_com.yml +1673 -0
  43. data/spec/cassettes/topix_com.yml +1431 -0
  44. data/spec/cassettes/vbulletin_com.yml +2983 -0
  45. data/spec/cassettes/wordpress_com.yml +879 -0
  46. data/spec/cassettes/wundergroud_com.yml +907 -0
  47. data/spec/cassettes/xenforo_com.yml +1947 -0
  48. data/spec/sniffles/sniffers/advertising/admeld_spec.rb +17 -0
  49. data/spec/sniffles/sniffers/advertising/adsense_spec.rb +19 -0
  50. data/spec/sniffles/sniffers/advertising/buysellads_spec.rb +18 -0
  51. data/spec/sniffles/sniffers/advertising/casale_spec.rb +18 -0
  52. data/spec/sniffles/sniffers/analytics/chartbeat_spec.rb +17 -0
  53. data/spec/sniffles/sniffers/analytics/clicky_spec.rb +17 -0
  54. data/spec/sniffles/sniffers/analytics/google_analytics_spec.rb +11 -31
  55. data/spec/sniffles/sniffers/analytics/kissmetrics_spec.rb +17 -0
  56. data/spec/sniffles/sniffers/analytics/mixpanel_spec.rb +8 -13
  57. data/spec/sniffles/sniffers/analytics/quantcast_spec.rb +7 -12
  58. data/spec/sniffles/sniffers/cms/blogger_spec.rb +18 -0
  59. data/spec/sniffles/sniffers/cms/cscart_spec.rb +18 -0
  60. data/spec/sniffles/sniffers/cms/movabletype_spec.rb +18 -0
  61. data/spec/sniffles/sniffers/cms/oscommerce_spec.rb +18 -0
  62. data/spec/sniffles/sniffers/cms/phpbb_spec.rb +18 -0
  63. data/spec/sniffles/sniffers/cms/posterous_spec.rb +18 -0
  64. data/spec/sniffles/sniffers/cms/tumblr_spec.rb +18 -0
  65. data/spec/sniffles/sniffers/cms/vanilla_spec.rb +18 -0
  66. data/spec/sniffles/sniffers/cms/vbulletin_spec.rb +21 -0
  67. data/spec/sniffles/sniffers/cms/wordpress_spec.rb +17 -48
  68. data/spec/sniffles/sniffers/cms/xenforo_spec.rb +18 -0
  69. data/spec/sniffles/sniffers/cms/zencart_spec.rb +18 -0
  70. data/spec/sniffles/sniffers/javascript/jquery_spec.rb +8 -15
  71. data/spec/sniffles/sniffers_spec.rb +8 -19
  72. data/spec/sniffles_spec.rb +14 -41
  73. data/spec/spec_helper.rb +1 -10
  74. data/spec/support/helpers.rb +12 -0
  75. metadata +106 -14
  76. data/Gemfile.lock +0 -44
  77. data/spec/cassettes/google_com.yml +0 -784
data/.gitignore CHANGED
@@ -1,4 +1,5 @@
1
1
  *.gem
2
+ Gemfile.lock
2
3
  *.rbc
3
4
  .bundle
4
5
  .config
data/README.md CHANGED
@@ -17,5 +17,56 @@ Bundler:
17
17
  require 'sniffles'
18
18
  require 'typhoeus' # Optional: Use your favorite HTTP client.
19
19
 
20
- response = Typhoeus::Request.get("http://www.wordpress.com/")
21
- Sniffles.sniff(response.body) # => {wordpress: true, jquery: true, quantcast: true}
20
+ response = Typhoeus::Request.get("http://www.squidoo.com/")
21
+
22
+ You can pass in a single sniffer:
23
+
24
+ Sniffles.sniff(response.body, :google_analytics)
25
+ # => { :google_analytics=> { :found=>true, :ua=>"UA-185209-2" } }
26
+
27
+ Or multiple sniffers:
28
+
29
+ Sniffles.sniff(response.body, :google_analytics, :kissmetrics)
30
+ # => {:google_analytics=>{:found=>true, :ua=>"UA-185209-2"}, :kissmetrics=>{:found=>false}}
31
+
32
+ Or an entire group of sniffers:
33
+
34
+ Sniffles.sniff(response.body, :analytics)
35
+ # => {:chartbeat=>{:found=>false},
36
+ # :clicky=>{:found=>false},
37
+ # :google_analytics=>{:found=>true, :ua=>"UA-185209-2"},
38
+ # :kissmetrics=>{:found=>false},
39
+ # :mixpanel=>{:found=>true},
40
+ # :quantcast=>{:found=>true}}
41
+
42
+ ## Sniffers (v0.1.2)
43
+ ### Advertising
44
+ * AdMeld
45
+ * AdSense
46
+ * BuySellAds
47
+ * Casale
48
+
49
+ ### Analytics
50
+ * ChartBeat
51
+ * Clicky
52
+ * Google Analytics
53
+ * KISSMetrics
54
+ * MixPanel
55
+ * Quantcast
56
+
57
+ ### CMS
58
+ * Blogger
59
+ * CS-Cart
60
+ * MovableType
61
+ * osCommerce
62
+ * phpBB
63
+ * Posterous
64
+ * Tumblr
65
+ * Vanilla
66
+ * vBulletin
67
+ * WordPress
68
+ * XenForo
69
+ * ZenCart
70
+
71
+ ### Javascript
72
+ * jQuery
@@ -0,0 +1,24 @@
1
+ module Sniffles
2
+ module Sniffers
3
+ class Admeld
4
+ include Text
5
+
6
+ attr_accessor :doc
7
+ attr_reader :output
8
+
9
+ def initialize(response_body)
10
+ @output = {}
11
+ parse(response_body) && process_document
12
+ end
13
+
14
+ def process_document
15
+ @output[:found] = found?
16
+ end
17
+
18
+ private
19
+ def found?
20
+ match? /js\.admeld\.com/
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,30 @@
1
+ module Sniffles
2
+ module Sniffers
3
+ class Adsense
4
+ include Text
5
+
6
+ attr_accessor :doc
7
+ attr_reader :output
8
+
9
+ def initialize(response_body)
10
+ @output = {}
11
+ parse(response_body) && process_document
12
+ end
13
+
14
+ def process_document
15
+ if @output[:found] = found?
16
+ parse_publisher_id
17
+ end
18
+ end
19
+
20
+ private
21
+ def found?
22
+ match? /googleAddAdSenseService/
23
+ end
24
+
25
+ def parse_publisher_id
26
+ @output[:publisher_id] = capture(/googleAddAdSenseService\(["|']+([a-z]+\-pub\-[\d]+)["|']+\)/)
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,24 @@
1
+ module Sniffles
2
+ module Sniffers
3
+ class Buysellads
4
+ include Text
5
+
6
+ attr_accessor :doc
7
+ attr_reader :output
8
+
9
+ def initialize(response_body)
10
+ @output = {}
11
+ parse(response_body) && process_document
12
+ end
13
+
14
+ def process_document
15
+ @output[:found] = found?
16
+ end
17
+
18
+ private
19
+ def found?
20
+ match? /s3\.buysellads\.com/
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,24 @@
1
+ module Sniffles
2
+ module Sniffers
3
+ class Casale
4
+ include Text
5
+
6
+ attr_accessor :doc
7
+ attr_reader :output
8
+
9
+ def initialize(response_body)
10
+ @output = {}
11
+ parse(response_body) && process_document
12
+ end
13
+
14
+ def process_document
15
+ @output[:found] = found?
16
+ end
17
+
18
+ private
19
+ def found?
20
+ match? /as\.casalemedia\.com/
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,24 @@
1
+ module Sniffles
2
+ module Sniffers
3
+ class Chartbeat
4
+ include Text
5
+
6
+ attr_accessor :doc
7
+ attr_reader :output
8
+
9
+ def initialize(response_body)
10
+ @output = {}
11
+ parse(response_body) && process_document
12
+ end
13
+
14
+ def process_document
15
+ @output[:found] = found?
16
+ end
17
+
18
+ private
19
+ def found?
20
+ match? /static\.chartbeat\.com\/js\/chartbeat\.js/
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,24 @@
1
+ module Sniffles
2
+ module Sniffers
3
+ class Clicky
4
+ include Text
5
+
6
+ attr_accessor :doc
7
+ attr_reader :output
8
+
9
+ def initialize(response_body)
10
+ @output = {}
11
+ parse(response_body) && process_document
12
+ end
13
+
14
+ def process_document
15
+ @output[:found] = found?
16
+ end
17
+
18
+ private
19
+ def found?
20
+ match? /static\.getclicky\.com/
21
+ end
22
+ end
23
+ end
24
+ end
@@ -12,12 +12,13 @@ module Sniffles
12
12
  end
13
13
 
14
14
  def process_document
15
- @output[:found] = google_analytics?
16
- parse_google_analytics_ua
15
+ if @output[:found] = found?
16
+ parse_google_analytics_ua
17
+ end
17
18
  end
18
19
 
19
20
  private
20
- def google_analytics?
21
+ def found?
21
22
  match?(/\.google\-analytics\.com|urchinTracker/i)
22
23
  end
23
24
 
@@ -0,0 +1,24 @@
1
+ module Sniffles
2
+ module Sniffers
3
+ class Kissmetrics
4
+ include Text
5
+
6
+ attr_accessor :doc
7
+ attr_reader :output
8
+
9
+ def initialize(response_body)
10
+ @output = {}
11
+ parse(response_body) && process_document
12
+ end
13
+
14
+ def process_document
15
+ @output[:found] = found?
16
+ end
17
+
18
+ private
19
+ def found?
20
+ match? /i\.kissmetrics\.com/
21
+ end
22
+ end
23
+ end
24
+ end
@@ -12,11 +12,11 @@ module Sniffles
12
12
  end
13
13
 
14
14
  def process_document
15
- @output[:found] = mixpanel?
15
+ @output[:found] = found?
16
16
  end
17
17
 
18
18
  private
19
- def mixpanel?
19
+ def found?
20
20
  match?(/api\.mixpanel\.com\S+mixpanel\.js/)
21
21
  end
22
22
  end
@@ -12,11 +12,11 @@ module Sniffles
12
12
  end
13
13
 
14
14
  def process_document
15
- @output[:found] = quantcast?
15
+ @output[:found] = found?
16
16
  end
17
17
 
18
18
  private
19
- def quantcast?
19
+ def found?
20
20
  match?(/\.quantserve\.com\/quant\.js/)
21
21
  end
22
22
  end
@@ -0,0 +1,28 @@
1
+ module Sniffles
2
+ module Sniffers
3
+ class Blogger
4
+ include HTML
5
+
6
+ attr_accessor :doc
7
+ attr_reader :output
8
+
9
+ def initialize(response_body)
10
+ @output = {}
11
+ parse(response_body) && process_document
12
+ end
13
+
14
+ def process_document
15
+ @output[:found] = found?
16
+ end
17
+
18
+ private
19
+ def found?
20
+ meta_generator_content == "blogger"
21
+ end
22
+
23
+ def meta_generator_content
24
+ text_at("//meta[@name='generator']/@content")
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,24 @@
1
+ module Sniffles
2
+ module Sniffers
3
+ class Cscart
4
+ include HTML
5
+
6
+ attr_accessor :doc
7
+ attr_reader :output
8
+
9
+ def initialize(response_body)
10
+ @output = {}
11
+ parse(response_body) && process_document
12
+ end
13
+
14
+ def process_document
15
+ @output[:found] = found?
16
+ end
17
+
18
+ private
19
+ def found?
20
+ !!(@doc.text =~ /Powered by CS\-Cart/)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,28 @@
1
+ module Sniffles
2
+ module Sniffers
3
+ class Movabletype
4
+ include HTML
5
+
6
+ attr_accessor :doc
7
+ attr_reader :output
8
+
9
+ def initialize(response_body)
10
+ @output = {}
11
+ parse(response_body) && process_document
12
+ end
13
+
14
+ def process_document
15
+ @output[:found] = found?
16
+ end
17
+
18
+ private
19
+ def found?
20
+ !!(meta_generator_content =~ /Movable Type/)
21
+ end
22
+
23
+ def meta_generator_content
24
+ text_at("//meta[@name='generator']/@content")
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,24 @@
1
+ module Sniffles
2
+ module Sniffers
3
+ class Oscommerce
4
+ include HTML
5
+
6
+ attr_accessor :doc
7
+ attr_reader :output
8
+
9
+ def initialize(response_body)
10
+ @output = {}
11
+ parse(response_body) && process_document
12
+ end
13
+
14
+ def process_document
15
+ @output[:found] = found?
16
+ end
17
+
18
+ private
19
+ def found?
20
+ !!(@doc.text =~ /Powered by osCommerce/)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,27 @@
1
+ module Sniffles
2
+ module Sniffers
3
+ class Phpbb
4
+ include HTML
5
+ attr_accessor :doc
6
+ attr_reader :output
7
+
8
+ def initialize(response_body)
9
+ @output = {}
10
+ parse(response_body) && process_document
11
+ end
12
+
13
+ def process_document
14
+ @output[:found] = found?
15
+ end
16
+
17
+ private
18
+ def found?
19
+ @doc.text.include?("Powered by phpBB") && phpbb_meta?
20
+ end
21
+
22
+ def phpbb_meta?
23
+ !@doc.xpath("//meta[@name='resource-type']").empty? && !@doc.xpath("//meta[@name='distribution']").empty?
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,28 @@
1
+ module Sniffles
2
+ module Sniffers
3
+ class Posterous
4
+ include HTML
5
+
6
+ attr_accessor :doc
7
+ attr_reader :output
8
+
9
+ def initialize(response_body)
10
+ @output = {}
11
+ parse(response_body) && process_document
12
+ end
13
+
14
+ def process_document
15
+ @output[:found] = found?
16
+ end
17
+
18
+ private
19
+ def found?
20
+ meta_generator_content == "Posterous"
21
+ end
22
+
23
+ def meta_generator_content
24
+ text_at("//meta[@name='generator']/@content")
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,24 @@
1
+ module Sniffles
2
+ module Sniffers
3
+ class Tumblr
4
+ include Text
5
+
6
+ attr_accessor :doc
7
+ attr_reader :output
8
+
9
+ def initialize(response_body)
10
+ @output = {}
11
+ parse(response_body) && process_document
12
+ end
13
+
14
+ def process_document
15
+ @output[:found] = found?
16
+ end
17
+
18
+ private
19
+ def found?
20
+ match?(/assets\.tumblr\.com\/iframe/) && match?(/<!-- BEGIN TUMBLR CODE -->/)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,24 @@
1
+ module Sniffles
2
+ module Sniffers
3
+ class Vanilla
4
+ include Text
5
+
6
+ attr_accessor :doc
7
+ attr_reader :output
8
+
9
+ def initialize(response_body)
10
+ @output = {}
11
+ parse(response_body) && process_document
12
+ end
13
+
14
+ def process_document
15
+ @output[:found] = found?
16
+ end
17
+
18
+ private
19
+ def found?
20
+ match? /Powered by Vanilla/
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,39 @@
1
+ module Sniffles
2
+ module Sniffers
3
+ class Vbulletin
4
+ include HTML
5
+
6
+ attr_accessor :doc
7
+ attr_reader :output
8
+
9
+ def initialize(response_body)
10
+ @output = {}
11
+ parse(response_body) && process_document
12
+ end
13
+
14
+ def process_document
15
+ if @output[:found] = found?
16
+ parse_version
17
+ parse_feed
18
+ end
19
+ end
20
+
21
+ private
22
+ def found?
23
+ !!(meta_generator_content =~ /vBulletin/)
24
+ end
25
+
26
+ def parse_feed
27
+ @output[:feed] = text_at("//link[@type='application/rss+xml']/@href")
28
+ end
29
+
30
+ def parse_version
31
+ @output[:version] = (meta_generator_content.match(/([\d]+\.[\d]+\.[\d]+)/) ? $1 : false)
32
+ end
33
+
34
+ def meta_generator_content
35
+ text_at("//meta[@name='generator']/@content")
36
+ end
37
+ end
38
+ end
39
+ end
@@ -11,15 +11,16 @@ module Sniffles
11
11
  end
12
12
 
13
13
  def process_document
14
- @output[:found] = wordpress?
15
- parse_version
16
- parse_feed
17
- parse_theme
18
- parse_pingback
14
+ if @output[:found] = found?
15
+ parse_version
16
+ parse_feed
17
+ parse_theme
18
+ parse_pingback
19
+ end
19
20
  end
20
21
 
21
22
  private
22
- def wordpress?
23
+ def found?
23
24
  @doc.xpath('//link[contains(@href,"wp-content")]').any?
24
25
  end
25
26
 
@@ -0,0 +1,28 @@
1
+ module Sniffles
2
+ module Sniffers
3
+ class Xenforo
4
+ include HTML
5
+
6
+ attr_accessor :doc
7
+ attr_reader :output
8
+
9
+ def initialize(response_body)
10
+ @output = {}
11
+ parse(response_body) && process_document
12
+ end
13
+
14
+ def process_document
15
+ @output[:found] = found?
16
+ end
17
+
18
+ private
19
+ def found?
20
+ meta_description_content == "Forum software by XenForo"
21
+ end
22
+
23
+ def meta_description_content
24
+ text_at("//meta[@name='description']/@content")
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,28 @@
1
+ module Sniffles
2
+ module Sniffers
3
+ class Zencart
4
+ include HTML
5
+
6
+ attr_accessor :doc
7
+ attr_reader :output
8
+
9
+ def initialize(response_body)
10
+ @output = {}
11
+ parse(response_body) && process_document
12
+ end
13
+
14
+ def process_document
15
+ @output[:found] = found?
16
+ end
17
+
18
+ private
19
+ def found?
20
+ !!(meta_generator_content =~ /by Zen Cart/)
21
+ end
22
+
23
+ def meta_generator_content
24
+ text_at("//meta[@name='generator']/@content")
25
+ end
26
+ end
27
+ end
28
+ end
@@ -12,11 +12,11 @@ module Sniffles
12
12
  end
13
13
 
14
14
  def process_document
15
- @output[:found] = jquery?
15
+ @output[:found] = found?
16
16
  end
17
17
 
18
18
  private
19
- def jquery?
19
+ def found?
20
20
  match?(/jQuery/)
21
21
  end
22
22
  end
@@ -1,3 +1,3 @@
1
1
  module Sniffles
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/lib/sniffles.rb CHANGED
@@ -49,5 +49,5 @@ module Sniffles
49
49
  list_all.include?(name)
50
50
  end
51
51
 
52
- class UnknownSniffer < Exception;end
52
+ class UnknownSniffer < StandardError; end
53
53
  end