framework_guesser 0.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.
Files changed (47) hide show
  1. data/.gitignore +17 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE.txt +22 -0
  4. data/README.md +45 -0
  5. data/Rakefile +1 -0
  6. data/framework_guesser.gemspec +24 -0
  7. data/lib/framework_guesser.rb +9 -0
  8. data/lib/framework_guesser/matcher.rb +327 -0
  9. data/lib/framework_guesser/version.rb +3 -0
  10. data/spec/fixtures/adsense-1.html +567 -0
  11. data/spec/fixtures/adsense-2.html +200 -0
  12. data/spec/fixtures/drupal-1.html +294 -0
  13. data/spec/fixtures/drupal-1.yaml +9 -0
  14. data/spec/fixtures/drupal-2.html +296 -0
  15. data/spec/fixtures/drupal-2.yaml +9 -0
  16. data/spec/fixtures/drupal-3.html +161 -0
  17. data/spec/fixtures/drupal-3.yaml +11 -0
  18. data/spec/fixtures/drupal-4.html +173 -0
  19. data/spec/fixtures/drupal-4.yaml +9 -0
  20. data/spec/fixtures/drupal-5.html +159 -0
  21. data/spec/fixtures/drupal-5.yaml +9 -0
  22. data/spec/fixtures/drupal-6.html +199 -0
  23. data/spec/fixtures/drupal-7.html +83 -0
  24. data/spec/fixtures/etarget-1.html +206 -0
  25. data/spec/fixtures/etarget-2.html +369 -0
  26. data/spec/fixtures/etarget-3.html +430 -0
  27. data/spec/fixtures/facebook-1.html +1256 -0
  28. data/spec/fixtures/facebook-1.yaml +11 -0
  29. data/spec/fixtures/facebook-2.html +119 -0
  30. data/spec/fixtures/facebook-2.yaml +11 -0
  31. data/spec/fixtures/facebook-3.html +315 -0
  32. data/spec/fixtures/facebook-3.yaml +8 -0
  33. data/spec/fixtures/opencart-1.html +625 -0
  34. data/spec/fixtures/opencart-2.html +271 -0
  35. data/spec/fixtures/prestashop-1.html +341 -0
  36. data/spec/fixtures/prestashop-2.html +435 -0
  37. data/spec/fixtures/rails-30-1.html +215 -0
  38. data/spec/fixtures/rails-30-2.html +209 -0
  39. data/spec/fixtures/rails-30-3.html +206 -0
  40. data/spec/fixtures/rails-31.html +120 -0
  41. data/spec/fixtures/ubercart-1.html +358 -0
  42. data/spec/fixtures/ubercart-2.html +447 -0
  43. data/spec/framework_guesser_spec.rb +19 -0
  44. data/spec/matcher_spec.rb +227 -0
  45. data/spec/spec_helper.rb +21 -0
  46. data/spec/support/helpers.rb +18 -0
  47. metadata +178 -0
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe FrameworkGuesser do
4
+
5
+ it "should guess framework" do
6
+ headers, body = load_headers_and_body('facebook-1')
7
+ result = FrameworkGuesser::guess(headers, body)
8
+ result[:description].should == "0101.sk domena plna zabavy, vtipy, humor, zabava, online hry a omnoho viac"
9
+ result[:keywords].should == "nesmrtelnost,extra vtipy,vtip baza,humorne situacie,morbidne obrazky,domena plna zabavy"
10
+ result[:server].should == :nginx
11
+ result[:engine].should == :php
12
+ result[:doctype].should == "html public \"-//w3c//dtd xhtml 1.0 strict//en\""
13
+ result[:features].should include :jquery
14
+ result[:features].should include :facebook
15
+ result[:features].should include :google_adsense
16
+ result[:features].should include :google_analytics
17
+ result[:features].size.should == 4
18
+ end
19
+ end
@@ -0,0 +1,227 @@
1
+ require 'spec_helper'
2
+
3
+ describe FrameworkGuesser::Matcher do
4
+
5
+ it "should detect facebook 1" do
6
+ result = run_matcher_on_fixture('facebook-1')
7
+ result[:description].should == "0101.sk domena plna zabavy, vtipy, humor, zabava, online hry a omnoho viac"
8
+ result[:keywords].should == "nesmrtelnost,extra vtipy,vtip baza,humorne situacie,morbidne obrazky,domena plna zabavy"
9
+ result[:server].should == :nginx
10
+ result[:engine].should == :php
11
+ result[:doctype].should == "html public \"-//w3c//dtd xhtml 1.0 strict//en\""
12
+ result[:features].should include :jquery
13
+ result[:features].should include :facebook
14
+ result[:features].should include :google_adsense
15
+ result[:features].should include :google_analytics
16
+ result[:features].size.should == 4
17
+ end
18
+
19
+ it "should detect facebook 2" do
20
+ result = run_matcher_on_fixture('facebook-2')
21
+ result[:server].should == :nginx
22
+ result[:engine].should == :php
23
+ result[:doctype].should == "html public \"-//w3c//dtd xhtml 1.0 strict//en\""
24
+ result[:features].should include :mootools
25
+ result[:features].should include :facebook
26
+ result[:features].should include :google_analytics
27
+ result[:features].size.should == 3
28
+ end
29
+
30
+ it "should detect facebook 3" do
31
+ result = run_matcher_on_fixture('facebook-3')
32
+ result[:server].should == :nginx
33
+ result[:engine].should == :php
34
+ result[:doctype].should == "html public \"-//w3c//dtd xhtml 1.0 transitional//en\""
35
+ result[:framework].should == :wordpress
36
+ result[:features].should include :jquery
37
+ result[:features].should include :facebook
38
+ result[:features].size.should == 2
39
+ end
40
+
41
+ it "should detect drupal 1" do
42
+ result = run_matcher_on_fixture('drupal-1')
43
+ result[:server].should == :apache
44
+ result[:framework].should == :drupal
45
+ result[:engine].should == :php
46
+ result[:doctype].should == "html public \"-//w3c//dtd xhtml 1.0 strict//en\""
47
+ result[:features].should include :jquery
48
+ result[:features].size.should == 1
49
+ end
50
+
51
+ it "should detect drupal 2" do
52
+ result = run_matcher_on_fixture('drupal-2')
53
+ result[:server].should == :apache
54
+ result[:framework].should == :drupal
55
+ result[:engine].should == :php
56
+ result[:doctype].should == "html public \"-//w3c//dtd xhtml 1.0 strict//en\""
57
+ result[:features].should include :jquery
58
+ result[:features].size.should == 1
59
+ end
60
+
61
+ it "should detect drupal 3" do
62
+ result = run_matcher_on_fixture('drupal-3')
63
+ result[:server].should == :apache
64
+ result[:framework].should == :drupal
65
+ result[:engine].should == :php
66
+ result[:doctype].should == "html public \"-//w3c//dtd xhtml 1.0 strict//en\""
67
+ end
68
+
69
+ it "should detect drupal 4" do
70
+ result = run_matcher_on_fixture('drupal-4')
71
+ result[:framework].should == :drupal
72
+ result[:engine].should == :php
73
+ result[:doctype].should == "html public \"-//w3c//dtd xhtml 1.0 strict//en\""
74
+ result[:features].should include :jquery
75
+ result[:features].should include :google_analytics
76
+ result[:features].size.should == 2
77
+ end
78
+
79
+ it "should detect drupal 5" do
80
+ result = run_matcher_on_fixture('drupal-5')
81
+ result[:framework].should == :drupal
82
+ result[:engine].should == :php
83
+ result[:doctype].should == "html public \"-//w3c//dtd xhtml 1.0 strict//en\""
84
+ result[:features].should include :jquery
85
+ result[:features].should include :google_analytics
86
+ result[:features].size.should == 2
87
+ end
88
+
89
+ it "should detect drupal 6" do
90
+ result = run_matcher_on_fixture('drupal-6')
91
+ result[:framework].should == :drupal
92
+ result[:doctype].should == "html public \"-//w3c//dtd xhtml+rdfa 1.0//en\""
93
+ result[:features].should include :jquery
94
+ result[:features].size.should == 1
95
+ end
96
+
97
+ it "should detect drupal 7" do
98
+ result = run_matcher_on_fixture('drupal-7')
99
+ result[:framework].should == :drupal
100
+ result[:doctype].should == "html public \"-//w3c//dtd xhtml 1.0 strict//en\""
101
+ end
102
+
103
+ it "should detect prestashop 1" do
104
+ result = run_matcher_on_fixture('prestashop-1')
105
+ result[:framework].should == :prestashop
106
+ result[:doctype].should == "html public \"-//w3c//dtd xhtml 1.1//en\""
107
+ end
108
+
109
+ it "should detect prestashop 2" do
110
+ result = run_matcher_on_fixture('prestashop-2')
111
+ result[:framework].should == :prestashop
112
+ result[:doctype].should == "html public \"-//w3c//dtd xhtml 1.1//en\""
113
+ end
114
+
115
+ it "should detect opencart 1" do
116
+ result = run_matcher_on_fixture('opencart-1')
117
+ result[:framework].should == :opencart
118
+ result[:doctype].should == "html public \"-//w3c//dtd xhtml 1.0 strict//en\""
119
+ end
120
+
121
+ it "should detect opencart 2" do
122
+ result = run_matcher_on_fixture('opencart-2')
123
+ result[:framework].should == :opencart
124
+ result[:doctype].should == "html public \"-//w3c//dtd xhtml 1.0 strict//en\""
125
+ end
126
+
127
+ it "should detect rails 3.1" do
128
+ result = run_matcher_on_fixture('rails-31')
129
+ result[:framework].should == :rails
130
+ result[:engine].should == :ruby
131
+ result[:features].size.should == 0
132
+ end
133
+
134
+ it "should detect rails 3.0 example 1" do
135
+ result = run_matcher_on_fixture('rails-30-1')
136
+ result[:framework].should == :rails
137
+ result[:engine].should == :ruby
138
+ result[:features].should include :google_analytics
139
+ result[:features].should include :facebook
140
+ result[:features].size.should == 2
141
+ end
142
+
143
+ it "should detect rails 3.0 example 2" do
144
+ result = run_matcher_on_fixture('rails-30-2')
145
+ result[:framework].should == :rails
146
+ result[:engine].should == :ruby
147
+ result[:features].should include :google_analytics
148
+ result[:features].should include :facebook
149
+ result[:features].size.should == 2
150
+ end
151
+
152
+ it "should detect rails 3.0 example 3" do
153
+ result = run_matcher_on_fixture('rails-30-3')
154
+ result[:framework].should == :rails
155
+ result[:engine].should == :ruby
156
+ result[:features].should include :google_analytics
157
+ result[:features].should include :facebook
158
+ result[:features].size.should == 2
159
+ end
160
+
161
+ it "should detect e-target 1" do
162
+ result = run_matcher_on_fixture('etarget-1')
163
+ result[:doctype].should == "html public \"-//w3c//dtd html 4.01 transitional//en\""
164
+ result[:features].should include :jquery
165
+ result[:features].should include :google_analytics
166
+ result[:features].should include :facebook
167
+ result[:features].should include :etarget
168
+ result[:features].size.should == 4
169
+ end
170
+
171
+ it "should detect e-target 2" do
172
+ result = run_matcher_on_fixture('etarget-2')
173
+ result[:doctype].should == "html public \"-//w3c//dtd xhtml 1.0 transitional//en\""
174
+ result[:engine].should == :php
175
+ result[:framework].should == :wordpress
176
+ result[:features].should include :jquery
177
+ result[:features].should include :google_analytics
178
+ result[:features].should include :google_adsense
179
+ result[:features].should include :facebook
180
+ result[:features].should include :etarget
181
+ result[:features].size.should == 5
182
+ end
183
+
184
+ it "should detect e-target 3" do
185
+ result = run_matcher_on_fixture('etarget-3')
186
+ result[:doctype].should == "html public \"-//w3c//dtd xhtml 1.0 strict//en\""
187
+ result[:features].should include :etarget
188
+ result[:features].size.should == 1
189
+ end
190
+
191
+ it "should detect google adsense 1" do
192
+ result = run_matcher_on_fixture('adsense-1')
193
+ result[:doctype].should == "html"
194
+ result[:features].should include :jquery
195
+ result[:features].should include :google_analytics
196
+ result[:features].should include :google_adsense
197
+ result[:features].size.should == 3
198
+ end
199
+
200
+ it "should detect google adsense 2" do
201
+ result = run_matcher_on_fixture('adsense-2')
202
+ result[:doctype].should == "html public \"-//w3c//dtd xhtml 1.0 strict//en\""
203
+ result[:features].should include :mootools
204
+ result[:features].should include :google_analytics
205
+ result[:features].should include :google_adsense
206
+ result[:features].size.should == 3
207
+ end
208
+
209
+ it "should detect ubercart 1" do
210
+ result = run_matcher_on_fixture('ubercart-1')
211
+ result[:doctype].should == "html public \"-//w3c//dtd xhtml 1.0 strict//en\""
212
+ result[:engine].should == :php
213
+ result[:framework].should == :ubercart
214
+ result[:features].should include :jquery
215
+ result[:features].should include :google_analytics
216
+ result[:features].size.should == 2
217
+ end
218
+
219
+ it "should detect ubercart 2" do
220
+ result = run_matcher_on_fixture('ubercart-2')
221
+ result[:doctype].should == "html public \"-//w3c//dtd xhtml 1.0 strict//en\""
222
+ result[:engine].should == :php
223
+ result[:framework].should == :ubercart
224
+ result[:features].should include :google_analytics
225
+ result[:features].size.should == 1
226
+ end
227
+ end
@@ -0,0 +1,21 @@
1
+ require 'fakeweb'
2
+ require 'nokogiri'
3
+ require 'yaml'
4
+ require 'framework_guesser'
5
+
6
+ require File.dirname(__FILE__) + '/support/helpers'
7
+
8
+ RSpec.configure do |config|
9
+ # == Mock Framework
10
+ #
11
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
12
+ #
13
+ # config.mock_with :mocha
14
+ # config.mock_with :flexmock
15
+ # config.mock_with :rr
16
+ config.mock_with :rspec
17
+
18
+ config.include(Helpers)
19
+
20
+ FakeWeb.allow_net_connect = false
21
+ end
@@ -0,0 +1,18 @@
1
+ module Helpers
2
+
3
+ def run_matcher_on_fixture(fixture)
4
+ matcher = FrameworkGuesser::Matcher.new
5
+ headers, body = load_headers_and_body(fixture)
6
+ matcher.match(headers, body)
7
+ end
8
+
9
+ def load_headers_and_body(fixture)
10
+ headers = if File.exists?(File.dirname(__FILE__) + "/../fixtures/#{fixture}.yaml")
11
+ YAML::load(File.read(File.dirname(__FILE__) + "/../fixtures/#{fixture}.yaml"))
12
+ else
13
+ {}
14
+ end
15
+ body = File.read(File.dirname(__FILE__) + "/../fixtures/#{fixture}.html")
16
+ [headers, body]
17
+ end
18
+ end
metadata ADDED
@@ -0,0 +1,178 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: framework_guesser
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Martin Lipták
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-02 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: nokogiri
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: fakeweb
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: Detection of framework and javascript libraries from HTML code.
63
+ email:
64
+ - mliptak@gmail.com
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - .gitignore
70
+ - Gemfile
71
+ - LICENSE.txt
72
+ - README.md
73
+ - Rakefile
74
+ - framework_guesser.gemspec
75
+ - lib/framework_guesser.rb
76
+ - lib/framework_guesser/matcher.rb
77
+ - lib/framework_guesser/version.rb
78
+ - spec/fixtures/adsense-1.html
79
+ - spec/fixtures/adsense-2.html
80
+ - spec/fixtures/drupal-1.html
81
+ - spec/fixtures/drupal-1.yaml
82
+ - spec/fixtures/drupal-2.html
83
+ - spec/fixtures/drupal-2.yaml
84
+ - spec/fixtures/drupal-3.html
85
+ - spec/fixtures/drupal-3.yaml
86
+ - spec/fixtures/drupal-4.html
87
+ - spec/fixtures/drupal-4.yaml
88
+ - spec/fixtures/drupal-5.html
89
+ - spec/fixtures/drupal-5.yaml
90
+ - spec/fixtures/drupal-6.html
91
+ - spec/fixtures/drupal-7.html
92
+ - spec/fixtures/etarget-1.html
93
+ - spec/fixtures/etarget-2.html
94
+ - spec/fixtures/etarget-3.html
95
+ - spec/fixtures/facebook-1.html
96
+ - spec/fixtures/facebook-1.yaml
97
+ - spec/fixtures/facebook-2.html
98
+ - spec/fixtures/facebook-2.yaml
99
+ - spec/fixtures/facebook-3.html
100
+ - spec/fixtures/facebook-3.yaml
101
+ - spec/fixtures/opencart-1.html
102
+ - spec/fixtures/opencart-2.html
103
+ - spec/fixtures/prestashop-1.html
104
+ - spec/fixtures/prestashop-2.html
105
+ - spec/fixtures/rails-30-1.html
106
+ - spec/fixtures/rails-30-2.html
107
+ - spec/fixtures/rails-30-3.html
108
+ - spec/fixtures/rails-31.html
109
+ - spec/fixtures/ubercart-1.html
110
+ - spec/fixtures/ubercart-2.html
111
+ - spec/framework_guesser_spec.rb
112
+ - spec/matcher_spec.rb
113
+ - spec/spec_helper.rb
114
+ - spec/support/helpers.rb
115
+ homepage: https://github.com/martinliptak/framework_guesser
116
+ licenses: []
117
+ post_install_message:
118
+ rdoc_options: []
119
+ require_paths:
120
+ - lib
121
+ required_ruby_version: !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ! '>='
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ required_rubygems_version: !ruby/object:Gem::Requirement
128
+ none: false
129
+ requirements:
130
+ - - ! '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ requirements: []
134
+ rubyforge_project:
135
+ rubygems_version: 1.8.24
136
+ signing_key:
137
+ specification_version: 3
138
+ summary: framework_guesser tries to detect frameworks and javascript libraries from
139
+ HTML code and HTTP headers hash. Some extra information like server, server-side
140
+ programming language, doctype, meta description and keywords are returned as well.
141
+ test_files:
142
+ - spec/fixtures/adsense-1.html
143
+ - spec/fixtures/adsense-2.html
144
+ - spec/fixtures/drupal-1.html
145
+ - spec/fixtures/drupal-1.yaml
146
+ - spec/fixtures/drupal-2.html
147
+ - spec/fixtures/drupal-2.yaml
148
+ - spec/fixtures/drupal-3.html
149
+ - spec/fixtures/drupal-3.yaml
150
+ - spec/fixtures/drupal-4.html
151
+ - spec/fixtures/drupal-4.yaml
152
+ - spec/fixtures/drupal-5.html
153
+ - spec/fixtures/drupal-5.yaml
154
+ - spec/fixtures/drupal-6.html
155
+ - spec/fixtures/drupal-7.html
156
+ - spec/fixtures/etarget-1.html
157
+ - spec/fixtures/etarget-2.html
158
+ - spec/fixtures/etarget-3.html
159
+ - spec/fixtures/facebook-1.html
160
+ - spec/fixtures/facebook-1.yaml
161
+ - spec/fixtures/facebook-2.html
162
+ - spec/fixtures/facebook-2.yaml
163
+ - spec/fixtures/facebook-3.html
164
+ - spec/fixtures/facebook-3.yaml
165
+ - spec/fixtures/opencart-1.html
166
+ - spec/fixtures/opencart-2.html
167
+ - spec/fixtures/prestashop-1.html
168
+ - spec/fixtures/prestashop-2.html
169
+ - spec/fixtures/rails-30-1.html
170
+ - spec/fixtures/rails-30-2.html
171
+ - spec/fixtures/rails-30-3.html
172
+ - spec/fixtures/rails-31.html
173
+ - spec/fixtures/ubercart-1.html
174
+ - spec/fixtures/ubercart-2.html
175
+ - spec/framework_guesser_spec.rb
176
+ - spec/matcher_spec.rb
177
+ - spec/spec_helper.rb
178
+ - spec/support/helpers.rb