rack-plastic 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. data/CHANGELOG +7 -0
  2. data/{README.rdoc → README.md} +22 -13
  3. data/Rakefile +2 -5
  4. data/lib/plastic_test_helper.rb +2 -2
  5. metadata +14 -147
  6. data/examples/middlewares/initial.rb +0 -34
  7. data/examples/middlewares/intro.rb +0 -17
  8. data/examples/middlewares/l337.rb +0 -22
  9. data/examples/middlewares/stylizer.rb +0 -16
  10. data/examples/rackapp/app.rb +0 -105
  11. data/examples/railsapp/app/controllers/application_controller.rb +0 -10
  12. data/examples/railsapp/app/controllers/tommy_boy_controller.rb +0 -9
  13. data/examples/railsapp/app/helpers/application_helper.rb +0 -3
  14. data/examples/railsapp/app/helpers/tommy_boy_helper.rb +0 -2
  15. data/examples/railsapp/config/boot.rb +0 -110
  16. data/examples/railsapp/config/environment.rb +0 -50
  17. data/examples/railsapp/config/environments/development.rb +0 -17
  18. data/examples/railsapp/config/environments/production.rb +0 -28
  19. data/examples/railsapp/config/environments/test.rb +0 -28
  20. data/examples/railsapp/config/initializers/backtrace_silencers.rb +0 -7
  21. data/examples/railsapp/config/initializers/inflections.rb +0 -10
  22. data/examples/railsapp/config/initializers/mime_types.rb +0 -5
  23. data/examples/railsapp/config/initializers/new_rails_defaults.rb +0 -21
  24. data/examples/railsapp/config/initializers/session_store.rb +0 -15
  25. data/examples/railsapp/config/routes.rb +0 -4
  26. data/examples/railsapp/db/seeds.rb +0 -7
  27. data/examples/railsapp/test/functional/tommy_boy_controller_test.rb +0 -8
  28. data/examples/railsapp/test/performance/browsing_test.rb +0 -9
  29. data/examples/railsapp/test/test_helper.rb +0 -38
  30. data/examples/railsapp/test/unit/helpers/tommy_boy_helper_test.rb +0 -4
  31. data/examples/sinatraapp/app.rb +0 -105
data/CHANGELOG CHANGED
@@ -1,3 +1,10 @@
1
+ 0.1.3 (November 6, 2011)
2
+ * Required current Jeweler (>= 1.6.0).
3
+ * Updated gem dependencies and gemspec to reflect the new Jeweler interface.
4
+ * Made gem dependency versions more robust.
5
+ * Changed the obsoleted "dirb" gem to the new "diffy" gem.
6
+ * Added a cautionary statement in the README about using this gem with Rails HTTP streaming.
7
+
1
8
  0.1.2 (February 21, 2011)
2
9
  * BUGFIX: process_html test helper was not working in Ruby 1.9.
3
10
  * Moved test apps into the examples directory.
@@ -1,25 +1,25 @@
1
- = Rack::Plastic
1
+ # Rack::Plastic
2
2
 
3
- == Description
3
+ ## Description
4
4
 
5
5
  If you are creating Rack middleware that changes the HTML response, use
6
6
  Rack::Plastic to get a head start. Rack::Plastic takes care of the
7
7
  boilerplate Rack glue so that you can focus on simply changing the HTML.
8
8
 
9
- == Usage
9
+ ## Usage
10
10
 
11
11
  There are two ways you can change the HTML: as a Nokogiri document or as
12
12
  a string. Simply define one of the following methods:
13
13
 
14
- def change_nokogiri_doc(doc)
15
- ... insert code that changes the doc ...
16
- doc
17
- end
14
+ def change_nokogiri_doc(doc)
15
+ ... insert code that changes the doc ...
16
+ doc
17
+ end
18
18
 
19
- def change_html_string(html)
20
- ... insert code that changes the html string ...
21
- html
22
- end
19
+ def change_html_string(html)
20
+ ... insert code that changes the html string ...
21
+ html
22
+ end
23
23
 
24
24
  If you define both methods, change_nokogiri_doc will be called first, then
25
25
  the doc will be converted to an HTML string, then the string will be
@@ -28,12 +28,18 @@ passed to change_html_string.
28
28
  Rack::Plastic also provides some convenience methods for interacting with
29
29
  Rack and Nokogiri as well as some convenience methods for testing.
30
30
 
31
- == Examples
31
+ ## Examples
32
32
 
33
33
  The examples/middlewares directory has examples of writing middleware using
34
34
  Rack::Plastic.
35
35
 
36
- == Testing
36
+ ## Rails Streaming
37
+
38
+ This middleware is not compatible with Rails HTTP streaming. According to [Railscast #266](http://asciicasts.com/episodes/266-http-streaming):
39
+ "Also, streaming is incompatible with some middleware. If the middleware modifies the response
40
+ then it will not work with streaming."
41
+
42
+ ## Testing
37
43
 
38
44
  Rack::Plastic comes with some test helpers that make it easier for you to
39
45
  write tests for your Rack middleware. Refer to the documentation for
@@ -44,16 +50,19 @@ but it provides manual tests. Each of the example middlewares is inserted into
44
50
  Sinatra, Rails, and Rack test app.
45
51
 
46
52
  To run the Rails test app:
53
+
47
54
  * cd examples/railsapp
48
55
  * script/server
49
56
  * point your browser to http://localhost:3000
50
57
 
51
58
  To run the Sinatra test app:
59
+
52
60
  * cd examples/sinatraapp
53
61
  * ruby app.rb
54
62
  * point your browser to http://localhost:4567
55
63
 
56
64
  To run the Rack test app:
65
+
57
66
  * cd examples/rackapp
58
67
  * rackup config.ru
59
68
  * point your browser to http://localhost:9292
data/Rakefile CHANGED
@@ -24,7 +24,7 @@ begin
24
24
  require 'jeweler'
25
25
  Jeweler::Tasks.new do |s|
26
26
  s.name = "rack-plastic"
27
- s.version = "0.1.2"
27
+ s.version = "0.1.3"
28
28
  s.author = "Wyatt Greene"
29
29
  s.email = "techiferous@gmail.com"
30
30
  s.summary = "Helps you write Rack middleware using Nokogiri."
@@ -33,10 +33,7 @@ begin
33
33
  Rack::Plastic to get a head start. Rack::Plastic takes care of the
34
34
  boilerplate Rack glue so that you can focus on simply changing the HTML.
35
35
  }
36
- s.add_dependency('rack', '>= 1.0.0')
37
- s.add_dependency('nokogiri', '>= 1.4.0')
38
- s.add_development_dependency('dirb', '2.0.0')
39
- s.add_development_dependency('colored')
36
+ # As of Jeweler 1.? (documented in 1.6.0), dependencies handled in Gemfile
40
37
  s.require_path = "lib"
41
38
  s.files = []
42
39
  s.files << "README.rdoc"
@@ -1,5 +1,5 @@
1
1
  require 'rack/mock'
2
- require 'dirb'
2
+ require 'diffy'
3
3
  require 'colored'
4
4
 
5
5
  # Mix this module into Test::Unit::TestCase to have access to these
@@ -92,7 +92,7 @@ module PlasticTestHelper
92
92
  preamble << "* The differences are highlighted below. *\n"
93
93
  preamble << "*****************************************************\n"
94
94
  message = preamble.magenta
95
- message << Dirb::Diff.new(expected, actual).to_s(:color)
95
+ message << Diffy::Diff.new(expected, actual).to_s(:color)
96
96
  assert_block(message) { expected == actual }
97
97
  end
98
98
 
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-plastic
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 1
8
- - 2
9
- version: 0.1.2
4
+ prerelease:
5
+ version: 0.1.3
10
6
  platform: ruby
11
7
  authors:
12
8
  - Wyatt Greene
@@ -14,21 +10,16 @@ autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2011-02-21 00:00:00 -05:00
18
- default_executable:
13
+ date: 2011-11-06 00:00:00 Z
19
14
  dependencies:
20
15
  - !ruby/object:Gem::Dependency
21
16
  name: rack
22
17
  requirement: &id001 !ruby/object:Gem::Requirement
23
18
  none: false
24
19
  requirements:
25
- - - ">="
20
+ - - ~>
26
21
  - !ruby/object:Gem::Version
27
- segments:
28
- - 1
29
- - 0
30
- - 0
31
- version: 1.0.0
22
+ version: "1.0"
32
23
  type: :runtime
33
24
  prerelease: false
34
25
  version_requirements: *id001
@@ -37,13 +28,9 @@ dependencies:
37
28
  requirement: &id002 !ruby/object:Gem::Requirement
38
29
  none: false
39
30
  requirements:
40
- - - ">="
31
+ - - ~>
41
32
  - !ruby/object:Gem::Version
42
- segments:
43
- - 1
44
- - 4
45
- - 0
46
- version: 1.4.0
33
+ version: "1.4"
47
34
  type: :runtime
48
35
  prerelease: false
49
36
  version_requirements: *id002
@@ -52,11 +39,9 @@ dependencies:
52
39
  requirement: &id003 !ruby/object:Gem::Requirement
53
40
  none: false
54
41
  requirements:
55
- - - ">="
42
+ - - ~>
56
43
  - !ruby/object:Gem::Version
57
- segments:
58
- - 0
59
- version: "0"
44
+ version: "1.6"
60
45
  type: :development
61
46
  prerelease: false
62
47
  version_requirements: *id003
@@ -67,70 +52,10 @@ dependencies:
67
52
  requirements:
68
53
  - - ">="
69
54
  - !ruby/object:Gem::Version
70
- segments:
71
- - 0
72
55
  version: "0"
73
56
  type: :development
74
57
  prerelease: false
75
58
  version_requirements: *id004
76
- - !ruby/object:Gem::Dependency
77
- name: rack
78
- requirement: &id005 !ruby/object:Gem::Requirement
79
- none: false
80
- requirements:
81
- - - ">="
82
- - !ruby/object:Gem::Version
83
- segments:
84
- - 1
85
- - 0
86
- - 0
87
- version: 1.0.0
88
- type: :runtime
89
- prerelease: false
90
- version_requirements: *id005
91
- - !ruby/object:Gem::Dependency
92
- name: nokogiri
93
- requirement: &id006 !ruby/object:Gem::Requirement
94
- none: false
95
- requirements:
96
- - - ">="
97
- - !ruby/object:Gem::Version
98
- segments:
99
- - 1
100
- - 4
101
- - 0
102
- version: 1.4.0
103
- type: :runtime
104
- prerelease: false
105
- version_requirements: *id006
106
- - !ruby/object:Gem::Dependency
107
- name: dirb
108
- requirement: &id007 !ruby/object:Gem::Requirement
109
- none: false
110
- requirements:
111
- - - "="
112
- - !ruby/object:Gem::Version
113
- segments:
114
- - 2
115
- - 0
116
- - 0
117
- version: 2.0.0
118
- type: :development
119
- prerelease: false
120
- version_requirements: *id007
121
- - !ruby/object:Gem::Dependency
122
- name: colored
123
- requirement: &id008 !ruby/object:Gem::Requirement
124
- none: false
125
- requirements:
126
- - - ">="
127
- - !ruby/object:Gem::Version
128
- segments:
129
- - 0
130
- version: "0"
131
- type: :development
132
- prerelease: false
133
- version_requirements: *id008
134
59
  description: "\n If you are creating Rack middleware that changes the HTML response, use\n Rack::Plastic to get a head start. Rack::Plastic takes care of the\n boilerplate Rack glue so that you can focus on simply changing the HTML.\n "
135
60
  email: techiferous@gmail.com
136
61
  executables: []
@@ -139,44 +64,17 @@ extensions: []
139
64
 
140
65
  extra_rdoc_files:
141
66
  - LICENSE
142
- - README.rdoc
67
+ - README.md
143
68
  files:
144
69
  - CHANGELOG
145
70
  - LICENSE
146
- - README.rdoc
147
71
  - Rakefile
148
72
  - lib/plastic_helper.rb
149
73
  - lib/plastic_test_helper.rb
150
74
  - lib/rack-plastic.rb
151
75
  - test/rack-plastic_test.rb
152
76
  - test/test_helper.rb
153
- - examples/middlewares/initial.rb
154
- - examples/middlewares/intro.rb
155
- - examples/middlewares/l337.rb
156
- - examples/middlewares/stylizer.rb
157
- - examples/rackapp/app.rb
158
- - examples/railsapp/app/controllers/application_controller.rb
159
- - examples/railsapp/app/controllers/tommy_boy_controller.rb
160
- - examples/railsapp/app/helpers/application_helper.rb
161
- - examples/railsapp/app/helpers/tommy_boy_helper.rb
162
- - examples/railsapp/config/boot.rb
163
- - examples/railsapp/config/environment.rb
164
- - examples/railsapp/config/environments/development.rb
165
- - examples/railsapp/config/environments/production.rb
166
- - examples/railsapp/config/environments/test.rb
167
- - examples/railsapp/config/initializers/backtrace_silencers.rb
168
- - examples/railsapp/config/initializers/inflections.rb
169
- - examples/railsapp/config/initializers/mime_types.rb
170
- - examples/railsapp/config/initializers/new_rails_defaults.rb
171
- - examples/railsapp/config/initializers/session_store.rb
172
- - examples/railsapp/config/routes.rb
173
- - examples/railsapp/db/seeds.rb
174
- - examples/railsapp/test/functional/tommy_boy_controller_test.rb
175
- - examples/railsapp/test/performance/browsing_test.rb
176
- - examples/railsapp/test/test_helper.rb
177
- - examples/railsapp/test/unit/helpers/tommy_boy_helper_test.rb
178
- - examples/sinatraapp/app.rb
179
- has_rdoc: true
77
+ - README.md
180
78
  homepage: http://github.com/techiferous/rack-plastic
181
79
  licenses: []
182
80
 
@@ -190,50 +88,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
190
88
  requirements:
191
89
  - - ">="
192
90
  - !ruby/object:Gem::Version
193
- segments:
194
- - 0
195
91
  version: "0"
196
92
  required_rubygems_version: !ruby/object:Gem::Requirement
197
93
  none: false
198
94
  requirements:
199
95
  - - ">="
200
96
  - !ruby/object:Gem::Version
201
- segments:
202
- - 0
203
97
  version: "0"
204
98
  requirements:
205
99
  - none
206
100
  rubyforge_project:
207
- rubygems_version: 1.3.7
101
+ rubygems_version: 1.8.10
208
102
  signing_key:
209
103
  specification_version: 3
210
104
  summary: Helps you write Rack middleware using Nokogiri.
211
- test_files:
212
- - examples/middlewares/initial.rb
213
- - examples/middlewares/intro.rb
214
- - examples/middlewares/l337.rb
215
- - examples/middlewares/stylizer.rb
216
- - examples/rackapp/app.rb
217
- - examples/railsapp/app/controllers/application_controller.rb
218
- - examples/railsapp/app/controllers/tommy_boy_controller.rb
219
- - examples/railsapp/app/helpers/application_helper.rb
220
- - examples/railsapp/app/helpers/tommy_boy_helper.rb
221
- - examples/railsapp/config/boot.rb
222
- - examples/railsapp/config/environment.rb
223
- - examples/railsapp/config/environments/development.rb
224
- - examples/railsapp/config/environments/production.rb
225
- - examples/railsapp/config/environments/test.rb
226
- - examples/railsapp/config/initializers/backtrace_silencers.rb
227
- - examples/railsapp/config/initializers/inflections.rb
228
- - examples/railsapp/config/initializers/mime_types.rb
229
- - examples/railsapp/config/initializers/new_rails_defaults.rb
230
- - examples/railsapp/config/initializers/session_store.rb
231
- - examples/railsapp/config/routes.rb
232
- - examples/railsapp/db/seeds.rb
233
- - examples/railsapp/test/functional/tommy_boy_controller_test.rb
234
- - examples/railsapp/test/performance/browsing_test.rb
235
- - examples/railsapp/test/test_helper.rb
236
- - examples/railsapp/test/unit/helpers/tommy_boy_helper_test.rb
237
- - examples/sinatraapp/app.rb
238
- - test/rack-plastic_test.rb
239
- - test/test_helper.rb
105
+ test_files: []
106
+
@@ -1,34 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'rack-plastic')
2
-
3
- # This middleware emphasizes the first character in every paragraph, not unlike
4
- # the initials in illuminated manuscripts of the Middle Ages.
5
- #
6
- module Rack
7
- class Initial < Plastic
8
-
9
- def change_nokogiri_doc(doc)
10
- doc.css("p").each do |p|
11
- p.traverse do |node|
12
- if node.text?
13
- if node.content =~ /(.*?)(\S)(.*)/m
14
- initial_whitespace = $1
15
- initial_character = $2
16
- rest_of_text = $3
17
- update_text(node, initial_whitespace + "openingspantag" + initial_character +
18
- "closingspantag" + rest_of_text)
19
- end
20
- break
21
- end
22
- end
23
- end
24
- doc
25
- end
26
-
27
- def change_html_string(html)
28
- html.gsub!(/openingspantag/, '<span style="font-size: 150%; font-weight: bold;">')
29
- html.gsub!(/closingspantag/, '</span>')
30
- html
31
- end
32
-
33
- end
34
- end
@@ -1,17 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'rack-plastic')
2
-
3
- # This middleware demonstrates how you would add an HTML element to the beginning
4
- # of a web page.
5
- #
6
- module Rack
7
- class Intro < Plastic
8
-
9
- def change_nokogiri_doc(doc)
10
- h1 = create_node(doc, "h1", "Holy shnikes!")
11
- h1['style'] = "text-align: center;"
12
- add_first_child(doc.at_css("body"), h1)
13
- doc
14
- end
15
-
16
- end
17
- end
@@ -1,22 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'rack-plastic')
2
-
3
- # This middleware converts the text of every paragraph to leetspeak.
4
- #
5
- module Rack
6
- class L337 < Plastic
7
-
8
- def change_nokogiri_doc(doc)
9
- doc.css("p").each do |p|
10
- p.traverse do |node|
11
- if node.text?
12
- l337_text = node.content.upcase.tr('ABCDEFGHIJKLMNOPQRSTUVWXYZ',
13
- '48CD3F6H1JKLMN0P9R57UVWxY2')
14
- update_text(node, l337_text)
15
- end
16
- end
17
- end
18
- doc
19
- end
20
-
21
- end
22
- end
@@ -1,16 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'rack-plastic')
2
-
3
- # This middleware demonstrates how to add inline CSS styles to the web page.
4
- #
5
- module Rack
6
- class Stylizer < Plastic
7
-
8
- def change_nokogiri_doc(doc)
9
- doc.at_css("body")["style"] = "font-family: Georgia, serif; font-style: italic;"
10
- doc.at_css("div#container")["style"] =
11
- "margin-left:auto;margin-right:auto;width:500px;position:relative"
12
- doc
13
- end
14
-
15
- end
16
- end
@@ -1,105 +0,0 @@
1
- class App
2
-
3
- def call(env)
4
- response = Rack::Response.new
5
- request = Rack::Request.new(env)
6
- response['Content-Type'] = 'text/html'
7
- if request.path =~ /more/
8
- response.write more
9
- else
10
- response.write front_page
11
- end
12
- response.finish
13
- end
14
-
15
- def front_page
16
- %Q{
17
- <!DOCTYPE html
18
- PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
19
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
20
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
21
- <head>
22
- <title>The Greatest Movie of All Time</title>
23
- </head>
24
- <body>
25
- <div id="container">
26
- <p>
27
- What my associate is trying to say is that our new brake pads are really cool.
28
- You're not even gonna believe it.
29
- </p>
30
- <p>
31
- Like, um, let's say you're driving along
32
- the road, with your family.<br />
33
- And you're driving along...la de da...woo...<br />
34
- And then all of a sudden
35
- there's a truck tire
36
- in the middle of the road
37
- and you hit the brakes.<br />
38
- Screeeee!
39
- </p>
40
- <p>
41
- Woah, that was close.
42
- </p>
43
- <p>
44
- Now let's see what happens when you're
45
- driving with "the other guy's brake pads".
46
- </p>
47
- <p>
48
- You're driving along,<br />
49
- you're driving along,<br />
50
- and all of a sudden your kids are
51
- yelling from the back seat:<br />
52
- "I gotta go to the bathroom, daddy!"<br />
53
- "Not now, dammit!"<br />
54
- "Truck tire! I can't stop! Aaaaa! Help!"<br />
55
- "There's a cliff! Aaaaa!"<br />
56
- And your family screaming:<br />
57
- "Oh my God, we're burning alive!"<br />
58
- "No! I can't feel my legs!"<br />
59
- Here comes the meat-wagon! Woo woo woo!<br />
60
- And the medic gets out and says:<br />
61
- "Oh! My! God!"<br />
62
- New guy's in the corner puking his guts out:<br />
63
- Blllleeeeeeeaaaaaaaaaaah!<br />
64
- Blllleeeeeeeaaaaaaaaaaah!<br />
65
- </p>
66
- <p>
67
- All because you wanna save a coupla extra pennies.
68
- </p>
69
- <a href="/more">&laquo; inflict me with more &raquo;</a>
70
- </div>
71
- </body>
72
- </html>
73
- }
74
- end
75
-
76
- def more
77
- %Q{
78
- <!DOCTYPE html
79
- PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
80
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
81
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
82
- <head>
83
- <title>More of the Greatest Movie of All Time</title>
84
- </head>
85
- <body>
86
- <div id="container">
87
- <p>
88
- D+? Oh my God! I passed! I passed! Oh, man i got a D+! I'm gonna graduate!
89
- I'm gonna graduate! D+!
90
- </p>
91
- <p>
92
- Hey guys, do i look different now that i'm a college grad?
93
- </p>
94
- <p>
95
- Apparently they give a lot fewer D+'s than D-'s.
96
- It's not a grade they like to give out, i'll tell ya that right now.
97
- </p>
98
- <a href="/">&laquo; take me back &raquo;</a>
99
- </div>
100
- </body>
101
- </html>
102
- }
103
- end
104
-
105
- end
@@ -1,10 +0,0 @@
1
- # Filters added to this controller apply to all controllers in the application.
2
- # Likewise, all the methods added will be available for all controllers.
3
-
4
- class ApplicationController < ActionController::Base
5
- helper :all # include all helpers, all the time
6
- protect_from_forgery # See ActionController::RequestForgeryProtection for details
7
-
8
- # Scrub sensitive parameters from your log
9
- # filter_parameter_logging :password
10
- end
@@ -1,9 +0,0 @@
1
- class TommyBoyController < ApplicationController
2
-
3
- def index
4
- end
5
-
6
- def more
7
- end
8
-
9
- end
@@ -1,3 +0,0 @@
1
- # Methods added to this helper will be available to all templates in the application.
2
- module ApplicationHelper
3
- end
@@ -1,2 +0,0 @@
1
- module TommyBoyHelper
2
- end
@@ -1,110 +0,0 @@
1
- # Don't change this file!
2
- # Configure your app in config/environment.rb and config/environments/*.rb
3
-
4
- RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
5
-
6
- module Rails
7
- class << self
8
- def boot!
9
- unless booted?
10
- preinitialize
11
- pick_boot.run
12
- end
13
- end
14
-
15
- def booted?
16
- defined? Rails::Initializer
17
- end
18
-
19
- def pick_boot
20
- (vendor_rails? ? VendorBoot : GemBoot).new
21
- end
22
-
23
- def vendor_rails?
24
- File.exist?("#{RAILS_ROOT}/vendor/rails")
25
- end
26
-
27
- def preinitialize
28
- load(preinitializer_path) if File.exist?(preinitializer_path)
29
- end
30
-
31
- def preinitializer_path
32
- "#{RAILS_ROOT}/config/preinitializer.rb"
33
- end
34
- end
35
-
36
- class Boot
37
- def run
38
- load_initializer
39
- Rails::Initializer.run(:set_load_path)
40
- end
41
- end
42
-
43
- class VendorBoot < Boot
44
- def load_initializer
45
- require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
46
- Rails::Initializer.run(:install_gem_spec_stubs)
47
- Rails::GemDependency.add_frozen_gem_path
48
- end
49
- end
50
-
51
- class GemBoot < Boot
52
- def load_initializer
53
- self.class.load_rubygems
54
- load_rails_gem
55
- require 'initializer'
56
- end
57
-
58
- def load_rails_gem
59
- if version = self.class.gem_version
60
- gem 'rails', version
61
- else
62
- gem 'rails'
63
- end
64
- rescue Gem::LoadError => load_error
65
- $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
66
- exit 1
67
- end
68
-
69
- class << self
70
- def rubygems_version
71
- Gem::RubyGemsVersion rescue nil
72
- end
73
-
74
- def gem_version
75
- if defined? RAILS_GEM_VERSION
76
- RAILS_GEM_VERSION
77
- elsif ENV.include?('RAILS_GEM_VERSION')
78
- ENV['RAILS_GEM_VERSION']
79
- else
80
- parse_gem_version(read_environment_rb)
81
- end
82
- end
83
-
84
- def load_rubygems
85
- min_version = '1.3.2'
86
- require 'rubygems'
87
- unless rubygems_version >= min_version
88
- $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
89
- exit 1
90
- end
91
-
92
- rescue LoadError
93
- $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
94
- exit 1
95
- end
96
-
97
- def parse_gem_version(text)
98
- $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
99
- end
100
-
101
- private
102
- def read_environment_rb
103
- File.read("#{RAILS_ROOT}/config/environment.rb")
104
- end
105
- end
106
- end
107
- end
108
-
109
- # All that for this:
110
- Rails.boot!
@@ -1,50 +0,0 @@
1
- # Be sure to restart your server when you modify this file
2
-
3
- # Specifies gem version of Rails to use when vendor/rails is not present
4
- RAILS_GEM_VERSION = '2.3.4' unless defined? RAILS_GEM_VERSION
5
-
6
- # Bootstrap the Rails environment, frameworks, and default configuration
7
- require File.join(File.dirname(__FILE__), 'boot')
8
- require File.join(File.dirname(__FILE__), '..', '..', 'middlewares', 'initial')
9
- require File.join(File.dirname(__FILE__), '..', '..', 'middlewares', 'intro')
10
- require File.join(File.dirname(__FILE__), '..', '..', 'middlewares', 'l337')
11
- require File.join(File.dirname(__FILE__), '..', '..', 'middlewares', 'stylizer')
12
-
13
- Rails::Initializer.run do |config|
14
- # Settings in config/environments/* take precedence over those specified here.
15
- # Application configuration should go into files in config/initializers
16
- # -- all .rb files in that directory are automatically loaded.
17
-
18
- config.middleware.use Rack::Intro
19
- config.middleware.use Rack::L337
20
- config.middleware.use Rack::Initial
21
- config.middleware.use Rack::Stylizer
22
-
23
- # Add additional load paths for your own custom dirs
24
- # config.load_paths += %W( #{RAILS_ROOT}/extras )
25
-
26
- # Specify gems that this application depends on and have them installed with rake gems:install
27
- # config.gem "bj"
28
- # config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
29
- # config.gem "sqlite3-ruby", :lib => "sqlite3"
30
- # config.gem "aws-s3", :lib => "aws/s3"
31
-
32
- # Only load the plugins named here, in the order given (default is alphabetical).
33
- # :all can be used as a placeholder for all plugins not explicitly named
34
- # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
35
-
36
- # Skip frameworks you're not going to use. To use Rails without a database,
37
- # you must remove the Active Record framework.
38
- # config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
39
-
40
- # Activate observers that should always be running
41
- # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
42
-
43
- # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
44
- # Run "rake -D time" for a list of tasks for finding time zone names.
45
- config.time_zone = 'UTC'
46
-
47
- # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
48
- # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
49
- # config.i18n.default_locale = :de
50
- end
@@ -1,17 +0,0 @@
1
- # Settings specified here will take precedence over those in config/environment.rb
2
-
3
- # In the development environment your application's code is reloaded on
4
- # every request. This slows down response time but is perfect for development
5
- # since you don't have to restart the webserver when you make code changes.
6
- config.cache_classes = false
7
-
8
- # Log error messages when you accidentally call methods on nil.
9
- config.whiny_nils = true
10
-
11
- # Show full error reports and disable caching
12
- config.action_controller.consider_all_requests_local = true
13
- config.action_view.debug_rjs = true
14
- config.action_controller.perform_caching = false
15
-
16
- # Don't care if the mailer can't send
17
- config.action_mailer.raise_delivery_errors = false
@@ -1,28 +0,0 @@
1
- # Settings specified here will take precedence over those in config/environment.rb
2
-
3
- # The production environment is meant for finished, "live" apps.
4
- # Code is not reloaded between requests
5
- config.cache_classes = true
6
-
7
- # Full error reports are disabled and caching is turned on
8
- config.action_controller.consider_all_requests_local = false
9
- config.action_controller.perform_caching = true
10
- config.action_view.cache_template_loading = true
11
-
12
- # See everything in the log (default is :info)
13
- # config.log_level = :debug
14
-
15
- # Use a different logger for distributed setups
16
- # config.logger = SyslogLogger.new
17
-
18
- # Use a different cache store in production
19
- # config.cache_store = :mem_cache_store
20
-
21
- # Enable serving of images, stylesheets, and javascripts from an asset server
22
- # config.action_controller.asset_host = "http://assets.example.com"
23
-
24
- # Disable delivery errors, bad email addresses will be ignored
25
- # config.action_mailer.raise_delivery_errors = false
26
-
27
- # Enable threaded mode
28
- # config.threadsafe!
@@ -1,28 +0,0 @@
1
- # Settings specified here will take precedence over those in config/environment.rb
2
-
3
- # The test environment is used exclusively to run your application's
4
- # test suite. You never need to work with it otherwise. Remember that
5
- # your test database is "scratch space" for the test suite and is wiped
6
- # and recreated between test runs. Don't rely on the data there!
7
- config.cache_classes = true
8
-
9
- # Log error messages when you accidentally call methods on nil.
10
- config.whiny_nils = true
11
-
12
- # Show full error reports and disable caching
13
- config.action_controller.consider_all_requests_local = true
14
- config.action_controller.perform_caching = false
15
- config.action_view.cache_template_loading = true
16
-
17
- # Disable request forgery protection in test environment
18
- config.action_controller.allow_forgery_protection = false
19
-
20
- # Tell Action Mailer not to deliver emails to the real world.
21
- # The :test delivery method accumulates sent emails in the
22
- # ActionMailer::Base.deliveries array.
23
- config.action_mailer.delivery_method = :test
24
-
25
- # Use SQL instead of Active Record's schema dumper when creating the test database.
26
- # This is necessary if your schema can't be completely dumped by the schema dumper,
27
- # like if you have constraints or database-specific column types
28
- # config.active_record.schema_format = :sql
@@ -1,7 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
- # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
-
6
- # You can also remove all the silencers if you're trying do debug a problem that might steem from framework code.
7
- # Rails.backtrace_cleaner.remove_silencers!
@@ -1,10 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Add new inflection rules using the following format
4
- # (all these examples are active by default):
5
- # ActiveSupport::Inflector.inflections do |inflect|
6
- # inflect.plural /^(ox)$/i, '\1en'
7
- # inflect.singular /^(ox)en/i, '\1'
8
- # inflect.irregular 'person', 'people'
9
- # inflect.uncountable %w( fish sheep )
10
- # end
@@ -1,5 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Add new mime types for use in respond_to blocks:
4
- # Mime::Type.register "text/richtext", :rtf
5
- # Mime::Type.register_alias "text/html", :iphone
@@ -1,21 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # These settings change the behavior of Rails 2 apps and will be defaults
4
- # for Rails 3. You can remove this initializer when Rails 3 is released.
5
-
6
- if defined?(ActiveRecord)
7
- # Include Active Record class name as root for JSON serialized output.
8
- ActiveRecord::Base.include_root_in_json = true
9
-
10
- # Store the full class name (including module namespace) in STI type column.
11
- ActiveRecord::Base.store_full_sti_class = true
12
- end
13
-
14
- ActionController::Routing.generate_best_match = false
15
-
16
- # Use ISO 8601 format for JSON serialized times and dates.
17
- ActiveSupport.use_standard_json_time_format = true
18
-
19
- # Don't escape HTML entities in JSON, leave that for the #json_escape helper.
20
- # if you're including raw json in an HTML page.
21
- ActiveSupport.escape_html_entities_in_json = false
@@ -1,15 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Your secret key for verifying cookie session data integrity.
4
- # If you change this key, all old sessions will become invalid!
5
- # Make sure the secret is at least 30 characters and all random,
6
- # no regular words or you'll be exposed to dictionary attacks.
7
- ActionController::Base.session = {
8
- :key => '_railsapp_session',
9
- :secret => '6d70a9e57e167a4699d60a921751576300e78c50f23bbc3276f511090577c2757cf9bf2d93218b2163c84e9275f7d8be7577f8e58290c5904d4ad74118c4542b'
10
- }
11
-
12
- # Use the database for sessions instead of the cookie-based default,
13
- # which shouldn't be used to store highly confidential information
14
- # (create the session table with "rake db:sessions:create")
15
- # ActionController::Base.session_store = :active_record_store
@@ -1,4 +0,0 @@
1
- ActionController::Routing::Routes.draw do |map|
2
- map.root :controller => "tommy_boy", :action => "index"
3
- map.connect 'more', :controller => "tommy_boy", :action => "more"
4
- end
@@ -1,7 +0,0 @@
1
- # This file should contain all the record creation needed to seed the database with its default values.
2
- # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3
- #
4
- # Examples:
5
- #
6
- # cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
7
- # Major.create(:name => 'Daley', :city => cities.first)
@@ -1,8 +0,0 @@
1
- require 'test_helper'
2
-
3
- class TommyBoyControllerTest < ActionController::TestCase
4
- # Replace this with your real tests.
5
- test "the truth" do
6
- assert true
7
- end
8
- end
@@ -1,9 +0,0 @@
1
- require 'test_helper'
2
- require 'performance_test_help'
3
-
4
- # Profiling results for each test method are written to tmp/performance.
5
- class BrowsingTest < ActionController::PerformanceTest
6
- def test_homepage
7
- get '/'
8
- end
9
- end
@@ -1,38 +0,0 @@
1
- ENV["RAILS_ENV"] = "test"
2
- require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
3
- require 'test_help'
4
-
5
- class ActiveSupport::TestCase
6
- # Transactional fixtures accelerate your tests by wrapping each test method
7
- # in a transaction that's rolled back on completion. This ensures that the
8
- # test database remains unchanged so your fixtures don't have to be reloaded
9
- # between every test method. Fewer database queries means faster tests.
10
- #
11
- # Read Mike Clark's excellent walkthrough at
12
- # http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting
13
- #
14
- # Every Active Record database supports transactions except MyISAM tables
15
- # in MySQL. Turn off transactional fixtures in this case; however, if you
16
- # don't care one way or the other, switching from MyISAM to InnoDB tables
17
- # is recommended.
18
- #
19
- # The only drawback to using transactional fixtures is when you actually
20
- # need to test transactions. Since your test is bracketed by a transaction,
21
- # any transactions started in your code will be automatically rolled back.
22
- self.use_transactional_fixtures = true
23
-
24
- # Instantiated fixtures are slow, but give you @david where otherwise you
25
- # would need people(:david). If you don't want to migrate your existing
26
- # test cases which use the @david style and don't mind the speed hit (each
27
- # instantiated fixtures translates to a database query per test method),
28
- # then set this back to true.
29
- self.use_instantiated_fixtures = false
30
-
31
- # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
32
- #
33
- # Note: You'll currently still have to declare fixtures explicitly in integration tests
34
- # -- they do not yet inherit this setting
35
- fixtures :all
36
-
37
- # Add more helper methods to be used by all tests here...
38
- end
@@ -1,4 +0,0 @@
1
- require 'test_helper'
2
-
3
- class TommyBoyHelperTest < ActionView::TestCase
4
- end
@@ -1,105 +0,0 @@
1
- require 'rubygems'
2
- require 'sinatra'
3
- require File.join(File.dirname(__FILE__), '..', 'middlewares', 'initial')
4
- require File.join(File.dirname(__FILE__), '..', 'middlewares', 'intro')
5
- require File.join(File.dirname(__FILE__), '..', 'middlewares', 'l337')
6
- require File.join(File.dirname(__FILE__), '..', 'middlewares', 'stylizer')
7
-
8
- # Note that these middlewares will seem to be applied in backwards order.
9
- # In other words, Rack::Stylizer parses the resulting HTML first, then
10
- # passes it to Rack::Initial, then to Rack::L337, and finally to Rack::Intro.
11
-
12
- use Rack::Intro
13
- use Rack::L337
14
- use Rack::Initial
15
- use Rack::Stylizer
16
-
17
- get '/' do
18
- %Q{
19
- <!DOCTYPE html
20
- PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
21
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
22
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
23
- <head>
24
- <title>The Greatest Movie of All Time</title>
25
- </head>
26
- <body>
27
- <div id="container">
28
- <p>
29
- What my associate is trying to say is that our new brake pads are really cool.
30
- You're not even gonna believe it.
31
- </p>
32
- <p>
33
- Like, um, let's say you're driving along
34
- the road, with your family.<br />
35
- And you're driving along...la de da...woo...<br />
36
- And then all of a sudden
37
- there's a truck tire
38
- in the middle of the road
39
- and you hit the brakes.<br />
40
- Screeeee!
41
- </p>
42
- <p>
43
- Woah, that was close.
44
- </p>
45
- <p>
46
- Now let's see what happens when you're
47
- driving with "the other guy's brake pads".
48
- </p>
49
- <p>
50
- You're driving along,<br />
51
- you're driving along,<br />
52
- and all of a sudden your kids are
53
- yelling from the back seat:<br />
54
- "I gotta go to the bathroom, daddy!"<br />
55
- "Not now, dammit!"<br />
56
- "Truck tire! I can't stop! Aaaaa! Help!"<br />
57
- "There's a cliff! Aaaaa!"<br />
58
- And your family screaming:<br />
59
- "Oh my God, we're burning alive!"<br />
60
- "No! I can't feel my legs!"<br />
61
- Here comes the meat-wagon! Woo woo woo!<br />
62
- And the medic gets out and says:<br />
63
- "Oh! My! God!"<br />
64
- New guy's in the corner puking his guts out:<br />
65
- Blllleeeeeeeaaaaaaaaaaah!<br />
66
- Blllleeeeeeeaaaaaaaaaaah!<br />
67
- </p>
68
- <p>
69
- All because you wanna save a coupla extra pennies.
70
- </p>
71
- <a href="/more">&laquo; inflict me with more &raquo;</a>
72
- </div>
73
- </body>
74
- </html>
75
- }
76
- end
77
-
78
- get '/more' do
79
- %Q{
80
- <!DOCTYPE html
81
- PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
82
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
83
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
84
- <head>
85
- <title>More of the Greatest Movie of All Time</title>
86
- </head>
87
- <body>
88
- <div id="container">
89
- <p>
90
- D+? Oh my God! I passed! I passed! Oh, man i got a D+! I'm gonna graduate!
91
- I'm gonna graduate! D+!
92
- </p>
93
- <p>
94
- Hey guys, do i look different now that i'm a college grad?
95
- </p>
96
- <p>
97
- Apparently they give a lot fewer D+'s than D-'s.
98
- It's not a grade they like to give out, i'll tell ya that right now.
99
- </p>
100
- <a href="/">&laquo; take me back &raquo;</a>
101
- </div>
102
- </body>
103
- </html>
104
- }
105
- end