reflexive 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +16 -0
- data/Rakefile +31 -0
- data/config.ru +3 -0
- data/reflexive.gemspec +1 -1
- data/spec/coderay_html_encoder_spec.rb +57 -0
- data/spec/coderay_ruby_scanner_spec.rb +194 -0
- data/spec/io_interceptor.rb +64 -0
- data/spec/method_lookup_spec.rb +0 -0
- data/spec/methods_spec.rb +202 -0
- data/spec/rails_integration_spec.rb +139 -0
- data/spec/rails_integration_spec_helper.rb +115 -0
- data/spec/reflexive_ripper_spec.rb +351 -0
- data/spec/reflexive_spec.rb +98 -0
- data/spec/ripper_events_recorder.rb +50 -0
- data/spec/ripper_spec.rb +758 -0
- data/spec/sexp_builder_with_scanner_events.rb +39 -0
- data/spec/shell_out.rb +417 -0
- data/spec/spec_helper.rb +4 -0
- data/spec/test_apps/rails2_test_app/README +243 -0
- data/spec/test_apps/rails2_test_app/Rakefile +10 -0
- data/spec/test_apps/rails2_test_app/app/controllers/application_controller.rb +10 -0
- data/spec/test_apps/rails2_test_app/app/controllers/posts_controller.rb +85 -0
- data/spec/test_apps/rails2_test_app/app/helpers/application_helper.rb +3 -0
- data/spec/test_apps/rails2_test_app/app/helpers/posts_helper.rb +2 -0
- data/spec/test_apps/rails2_test_app/app/models/post.rb +5 -0
- data/spec/test_apps/rails2_test_app/app/views/layouts/posts.html.erb +17 -0
- data/spec/test_apps/rails2_test_app/app/views/posts/edit.html.erb +12 -0
- data/spec/test_apps/rails2_test_app/app/views/posts/index.html.erb +18 -0
- data/spec/test_apps/rails2_test_app/app/views/posts/new.html.erb +11 -0
- data/spec/test_apps/rails2_test_app/app/views/posts/show.html.erb +3 -0
- data/spec/test_apps/rails2_test_app/config/boot.rb +110 -0
- data/spec/test_apps/rails2_test_app/config/database.yml +22 -0
- data/spec/test_apps/rails2_test_app/config/environment.rb +43 -0
- data/spec/test_apps/rails2_test_app/config/environments/development.rb +17 -0
- data/spec/test_apps/rails2_test_app/config/environments/production.rb +28 -0
- data/spec/test_apps/rails2_test_app/config/environments/test.rb +28 -0
- data/spec/test_apps/rails2_test_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/test_apps/rails2_test_app/config/initializers/inflections.rb +10 -0
- data/spec/test_apps/rails2_test_app/config/initializers/mime_types.rb +5 -0
- data/spec/test_apps/rails2_test_app/config/initializers/new_rails_defaults.rb +21 -0
- data/spec/test_apps/rails2_test_app/config/initializers/session_store.rb +15 -0
- data/spec/test_apps/rails2_test_app/config/locales/en.yml +5 -0
- data/spec/test_apps/rails2_test_app/config/routes.rb +45 -0
- data/spec/test_apps/rails2_test_app/db/development.sqlite3 +0 -0
- data/spec/test_apps/rails2_test_app/db/migrate/20100512073155_create_posts.rb +12 -0
- data/spec/test_apps/rails2_test_app/db/schema.rb +19 -0
- data/spec/test_apps/rails2_test_app/db/seeds.rb +7 -0
- data/spec/test_apps/rails2_test_app/doc/README_FOR_APP +2 -0
- data/spec/test_apps/rails2_test_app/log/development.log +251 -0
- data/spec/test_apps/rails2_test_app/log/production.log +0 -0
- data/spec/test_apps/rails2_test_app/log/server.log +0 -0
- data/spec/test_apps/rails2_test_app/log/test.log +0 -0
- data/spec/test_apps/rails2_test_app/public/404.html +30 -0
- data/spec/test_apps/rails2_test_app/public/422.html +30 -0
- data/spec/test_apps/rails2_test_app/public/500.html +30 -0
- data/spec/test_apps/rails2_test_app/public/favicon.ico +0 -0
- data/spec/test_apps/rails2_test_app/public/images/rails.png +0 -0
- data/spec/test_apps/rails2_test_app/public/index.html +275 -0
- data/spec/test_apps/rails2_test_app/public/javascripts/application.js +2 -0
- data/spec/test_apps/rails2_test_app/public/javascripts/controls.js +963 -0
- data/spec/test_apps/rails2_test_app/public/javascripts/dragdrop.js +973 -0
- data/spec/test_apps/rails2_test_app/public/javascripts/effects.js +1128 -0
- data/spec/test_apps/rails2_test_app/public/javascripts/prototype.js +4320 -0
- data/spec/test_apps/rails2_test_app/public/robots.txt +5 -0
- data/spec/test_apps/rails2_test_app/public/stylesheets/1.css +0 -0
- data/spec/test_apps/rails2_test_app/public/stylesheets/scaffold.css +54 -0
- data/spec/test_apps/rails2_test_app/script/about +4 -0
- data/spec/test_apps/rails2_test_app/script/console +3 -0
- data/spec/test_apps/rails2_test_app/script/dbconsole +3 -0
- data/spec/test_apps/rails2_test_app/script/destroy +3 -0
- data/spec/test_apps/rails2_test_app/script/generate +3 -0
- data/spec/test_apps/rails2_test_app/script/performance/benchmarker +3 -0
- data/spec/test_apps/rails2_test_app/script/performance/profiler +3 -0
- data/spec/test_apps/rails2_test_app/script/plugin +3 -0
- data/spec/test_apps/rails2_test_app/script/runner +3 -0
- data/spec/test_apps/rails2_test_app/script/server +3 -0
- data/spec/test_apps/rails2_test_app/test/fixtures/posts.yml +7 -0
- data/spec/test_apps/rails2_test_app/test/functional/posts_controller_test.rb +45 -0
- data/spec/test_apps/rails2_test_app/test/performance/browsing_test.rb +9 -0
- data/spec/test_apps/rails2_test_app/test/test_helper.rb +38 -0
- data/spec/test_apps/rails2_test_app/test/unit/helpers/posts_helper_test.rb +4 -0
- data/spec/test_apps/rails2_test_app/test/unit/post_test.rb +8 -0
- data/spec/test_apps/rails3_test_app/Gemfile +28 -0
- data/spec/test_apps/rails3_test_app/README +244 -0
- data/spec/test_apps/rails3_test_app/Rakefile +10 -0
- data/spec/test_apps/rails3_test_app/app/controllers/application_controller.rb +4 -0
- data/spec/test_apps/rails3_test_app/app/controllers/posts_controller.rb +83 -0
- data/spec/test_apps/rails3_test_app/app/helpers/application_helper.rb +2 -0
- data/spec/test_apps/rails3_test_app/app/helpers/posts_helper.rb +2 -0
- data/spec/test_apps/rails3_test_app/app/models/post.rb +2 -0
- data/spec/test_apps/rails3_test_app/app/views/layouts/application.html.erb +14 -0
- data/spec/test_apps/rails3_test_app/app/views/posts/_form.html.erb +16 -0
- data/spec/test_apps/rails3_test_app/app/views/posts/edit.html.erb +6 -0
- data/spec/test_apps/rails3_test_app/app/views/posts/index.html.erb +21 -0
- data/spec/test_apps/rails3_test_app/app/views/posts/new.html.erb +5 -0
- data/spec/test_apps/rails3_test_app/app/views/posts/show.html.erb +5 -0
- data/spec/test_apps/rails3_test_app/config/application.rb +49 -0
- data/spec/test_apps/rails3_test_app/config/boot.rb +6 -0
- data/spec/test_apps/rails3_test_app/config/database.yml +22 -0
- data/spec/test_apps/rails3_test_app/config/environment.rb +5 -0
- data/spec/test_apps/rails3_test_app/config/environments/development.rb +19 -0
- data/spec/test_apps/rails3_test_app/config/environments/production.rb +42 -0
- data/spec/test_apps/rails3_test_app/config/environments/test.rb +32 -0
- data/spec/test_apps/rails3_test_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/test_apps/rails3_test_app/config/initializers/inflections.rb +10 -0
- data/spec/test_apps/rails3_test_app/config/initializers/mime_types.rb +5 -0
- data/spec/test_apps/rails3_test_app/config/initializers/secret_token.rb +7 -0
- data/spec/test_apps/rails3_test_app/config/initializers/session_store.rb +8 -0
- data/spec/test_apps/rails3_test_app/config/locales/en.yml +5 -0
- data/spec/test_apps/rails3_test_app/config/routes.rb +60 -0
- data/spec/test_apps/rails3_test_app/config.ru +4 -0
- data/spec/test_apps/rails3_test_app/db/development.sqlite3 +0 -0
- data/spec/test_apps/rails3_test_app/db/migrate/20100512075428_create_posts.rb +12 -0
- data/spec/test_apps/rails3_test_app/db/schema.rb +19 -0
- data/spec/test_apps/rails3_test_app/db/seeds.rb +7 -0
- data/spec/test_apps/rails3_test_app/doc/README_FOR_APP +2 -0
- data/spec/test_apps/rails3_test_app/log/development.log +349 -0
- data/spec/test_apps/rails3_test_app/log/production.log +0 -0
- data/spec/test_apps/rails3_test_app/log/server.log +0 -0
- data/spec/test_apps/rails3_test_app/log/test.log +0 -0
- data/spec/test_apps/rails3_test_app/public/404.html +26 -0
- data/spec/test_apps/rails3_test_app/public/422.html +26 -0
- data/spec/test_apps/rails3_test_app/public/500.html +26 -0
- data/spec/test_apps/rails3_test_app/public/favicon.ico +0 -0
- data/spec/test_apps/rails3_test_app/public/images/rails.png +0 -0
- data/spec/test_apps/rails3_test_app/public/index.html +279 -0
- data/spec/test_apps/rails3_test_app/public/javascripts/application.js +2 -0
- data/spec/test_apps/rails3_test_app/public/javascripts/controls.js +965 -0
- data/spec/test_apps/rails3_test_app/public/javascripts/dragdrop.js +974 -0
- data/spec/test_apps/rails3_test_app/public/javascripts/effects.js +1123 -0
- data/spec/test_apps/rails3_test_app/public/javascripts/prototype.js +4874 -0
- data/spec/test_apps/rails3_test_app/public/javascripts/rails.js +118 -0
- data/spec/test_apps/rails3_test_app/public/robots.txt +5 -0
- data/spec/test_apps/rails3_test_app/public/stylesheets/scaffold.css +60 -0
- data/spec/test_apps/rails3_test_app/script/rails +9 -0
- data/spec/test_apps/rails3_test_app/test/fixtures/posts.yml +11 -0
- data/spec/test_apps/rails3_test_app/test/functional/posts_controller_test.rb +49 -0
- data/spec/test_apps/rails3_test_app/test/performance/browsing_test.rb +9 -0
- data/spec/test_apps/rails3_test_app/test/test_helper.rb +13 -0
- data/spec/test_apps/rails3_test_app/test/unit/helpers/posts_helper_test.rb +4 -0
- data/spec/test_apps/rails3_test_app/test/unit/post_test.rb +8 -0
- metadata +142 -2
@@ -0,0 +1,50 @@
|
|
1
|
+
require "ripper"
|
2
|
+
|
3
|
+
class RipperEventsRecorder < Ripper
|
4
|
+
attr_accessor :parser_events, :scanner_events, :all_events
|
5
|
+
|
6
|
+
def self.parser_events(src)
|
7
|
+
new(src).tap { |p| p.parse }.parser_events
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.scanner_events(src)
|
11
|
+
new(src).tap { |p| p.parse }.scanner_events
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.all_events(src)
|
15
|
+
new(src).tap { |p| p.parse }.all_events
|
16
|
+
end
|
17
|
+
|
18
|
+
def initialize(*args)
|
19
|
+
super
|
20
|
+
self.parser_events = []
|
21
|
+
self.scanner_events = []
|
22
|
+
self.all_events = []
|
23
|
+
end
|
24
|
+
|
25
|
+
Ripper::SCANNER_EVENTS.each do |meth|
|
26
|
+
define_method("on_#{ meth }") do |*args|
|
27
|
+
result = super(*args)
|
28
|
+
scanner_events << [ meth, (args.size == 1 ? args[0] : args) ]
|
29
|
+
all_events << [ meth, (args.size == 1 ? args[0] : args) ]
|
30
|
+
result
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
Ripper::PARSER_EVENTS.each do |meth|
|
35
|
+
define_method("on_#{ meth }") do |*args|
|
36
|
+
result = super(*args)
|
37
|
+
parser_events << [ meth, (args.size == 1 ? args[0] : args) ]
|
38
|
+
all_events << [ meth, (args.size == 1 ? args[0] : args) ]
|
39
|
+
result
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def scanner_event_index(scanner_event_object_id)
|
44
|
+
scanner_events.index { |s_e| s_e.object_id == scanner_event_object_id }
|
45
|
+
end
|
46
|
+
|
47
|
+
def scanner_event(scanner_event_object_id)
|
48
|
+
scanner_events.detect { |s_e| s_e.object_id == scanner_event_object_id }
|
49
|
+
end
|
50
|
+
end
|