happy_place 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.coveralls.yml +0 -0
  3. data/.travis.yml +9 -0
  4. data/Gemfile +3 -0
  5. data/README.md +21 -9
  6. data/happy_place.gemspec +7 -3
  7. data/lib/happy_place/controller.rb +22 -19
  8. data/lib/happy_place/version.rb +1 -1
  9. data/spec/dummy/.gitignore +16 -0
  10. data/spec/dummy/README.rdoc +261 -0
  11. data/spec/dummy/Rakefile +7 -0
  12. data/spec/dummy/app/controllers/application_controller.rb +2 -0
  13. data/spec/dummy/app/controllers/examples_controller.rb +7 -0
  14. data/spec/dummy/app/models/.gitkeep +0 -0
  15. data/spec/dummy/config/application.rb +63 -0
  16. data/spec/dummy/config/boot.rb +10 -0
  17. data/spec/dummy/config/database.yml +19 -0
  18. data/spec/dummy/config/environment.rb +5 -0
  19. data/spec/dummy/config/environments/development.rb +30 -0
  20. data/spec/dummy/config/environments/production.rb +67 -0
  21. data/spec/dummy/config/environments/test.rb +34 -0
  22. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  23. data/spec/dummy/config/initializers/inflections.rb +15 -0
  24. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  25. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  26. data/spec/dummy/config/initializers/session_store.rb +8 -0
  27. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  28. data/spec/dummy/config/locales/en.yml +5 -0
  29. data/spec/dummy/config/routes.rb +58 -0
  30. data/spec/dummy/config.ru +4 -0
  31. data/spec/dummy/db/migration_helper.rb +42 -0
  32. data/spec/dummy/db/schema.rb +16 -0
  33. data/spec/dummy/db/seeds.rb +17 -0
  34. data/spec/dummy/db/static/bottles.csv +201 -0
  35. data/spec/dummy/db/static/varietal_aliases.csv +433 -0
  36. data/spec/dummy/db/static/varietals.csv +295 -0
  37. data/spec/dummy/dummy_test +0 -0
  38. data/spec/dummy/lib/assets/.gitkeep +0 -0
  39. data/spec/dummy/public/404.html +26 -0
  40. data/spec/dummy/public/422.html +26 -0
  41. data/spec/dummy/public/500.html +25 -0
  42. data/spec/dummy/public/favicon.ico +0 -0
  43. data/spec/dummy/script/rails +6 -0
  44. data/spec/dummy/spec/controllers/examples_controller_spec.rb +9 -0
  45. data/spec/dummy/spec/tmp/app/models/foo_alias.rb +4 -0
  46. data/spec/spec_helper.rb +17 -0
  47. metadata +138 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aa25386c08b4e740ceac1ab66d337a1f0577c5a0
4
- data.tar.gz: 1dcc0f29128bdeae412ab7d5a6fb693decf73099
3
+ metadata.gz: 58871e4b4f1abdb54f2c046d9d261cac9decda64
4
+ data.tar.gz: f05bb1733e86c031ac98c0048551ff6c614ffe5d
5
5
  SHA512:
6
- metadata.gz: 8bda773c9d66986e0f973a34c921f91f419efaac3fc218d3c10d2ab252996e67c311d8282aa4ec6b5a5d53e9709d59a1f4418655858c35d895151b0f93b930d7
7
- data.tar.gz: f6a627ca590200639e5224ce7db825a71ebae3c6ec021b807bc8b3a548426815f7c3c69c12571c18893311519f2187ca03f6d6722489b60be73fc16721966262
6
+ metadata.gz: a0028a5ca51a7687c96cfadb5efe992f9e6476a6d73806aacf9e88234d272587250cce0786df0632d2cf320d40ba5a33a461f345d80aea66c7ed398236fce658
7
+ data.tar.gz: 98d0032101a3d8720ba3d02d55e61d6dbd78056cb85987f921805ec12282354133d36b3eaaf2a68a78c9fb7148d90b00eca581d506a255ea3a9308f564821c0d
data/.coveralls.yml ADDED
File without changes
data/.travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.4
4
+
5
+ before_install:
6
+ - gem install bundler -v '= 1.7.4'
7
+
8
+ script:
9
+ - bundle exec rspec
data/Gemfile CHANGED
@@ -1,4 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ gem 'coveralls', require: false
4
+ gem "happy_place", path: "."
5
+
3
6
  # Specify your gem's dependencies in happy_place.gemspec
4
7
  gemspec
data/README.md CHANGED
@@ -7,7 +7,7 @@ happy_place
7
7
  | Version | [![Gem Version](https://badge.fury.io/rb/happy_place.png)](http://badge.fury.io/rb/happy_place) |
8
8
  | Continuous Integration | [![Build Status](https://travis-ci.org/mfpiccolo/happy_place.png?branch=master)](https://travis-ci.org/mfpiccolo/happy_place)
9
9
  | Test Coverage | [![Coverage Status](https://coveralls.io/repos/mfpiccolo/happy_place/badge.png?branch=master)](https://coveralls.io/r/mfpiccolo/happy_place?branch=coveralls)
10
- | Grade | [![Code Climate](https://codeclimate.com/github/mfpiccolo/happy_place.png)](https://codeclimate.com/github/mfpiccolo/happy_place)
10
+ | Grade | [![Code Climate](https://codeclimate.com/github/mfpiccolo/happy_place/badges/gpa.svg)](https://codeclimate.com/github/mfpiccolo/happy_place)
11
11
  | Dependencies | [![Dependency Status](https://gemnasium.com/mfpiccolo/happy_place.png)](https://gemnasium.com/mfpiccolo/happy_place)
12
12
  | Homepage | [http://mfpiccolo.github.io/happy_place][homepage] |
13
13
  | Documentation | [http://rdoc.info/github/mfpiccolo/happy_place/frames][documentation] |
@@ -42,7 +42,7 @@ The `js` method accepts the following keyword arguments:
42
42
 
43
43
  `js_class:` String name of the js class that you want to use
44
44
 
45
- `function:` Sting of the name of the function you would like to call
45
+ `function:` String of the name of the function you would like to call
46
46
 
47
47
  `partials:` Hash of keyword arguments with partials that will be rendered and available in your js function
48
48
 
@@ -113,7 +113,7 @@ class this.ExampleController
113
113
 
114
114
  If your controller action is only ever going to be hit by one format type or you want the same js to run for both html or js formats then you don't need the responds to and you can use the js method directly in the action definition.
115
115
 
116
- Also if you do not need to pass along args or a partial then you can simply call js
116
+ Also if you do not need to pass along args or a partial then you can simply call js.
117
117
 
118
118
  ```ruby
119
119
  class ExampleContorller
@@ -135,7 +135,7 @@ class this.ExampleController
135
135
  ## Naming and Directory Structure
136
136
  Technically you can put your code anywhere you want but to make it to your happy place you should follow the naming and directory structure used by rails.
137
137
 
138
- If you are adding code that is conroller and action specific, then add a directory called controllers in your `app/assets/javascripts` directory. If your controllers are namespaced then namespace them just like you do in your rails controllers. Here is an example of a namespaced coffee class:
138
+ If you are adding code that is controller and action specific, then add a directory called controllers in your `app/assets/javascripts` directory. If your controllers are namespaced then namespace them just like you do in your rails controllers. Here is an example of a namespaced coffee class:
139
139
 
140
140
  ```coffeescript
141
141
  # app/assets/javascripts/controllers/admin/special/orders_controller
@@ -169,7 +169,7 @@ Or require them explicitly:
169
169
 
170
170
  ### Stop using js views after remote actions!
171
171
 
172
- Lets say you have a blog where you can see a list of posts. (Imagine that!) You use the Posts#index to display this and it is loaded noramally with :html.
172
+ Lets say you have a blog where you can see a list of posts (Imagine that!). You use the Posts#index to display this and it is loaded noramally with :html.
173
173
 
174
174
  ```html
175
175
  <!-- posts/index.html.erb -->
@@ -206,16 +206,16 @@ Lets say you have a blog where you can see a list of posts. (Imagine that!) You
206
206
  </table>
207
207
  ```
208
208
 
209
- However you want to be able to updat the posts table with a filter that uses ajax. Normally, you would create view of `views/posts/index.coffee` with the following code:
209
+ However you want to be able to update the posts table with a filter that uses ajax. Normally, you would create view of `views/posts/index.coffee` with the following code:
210
210
 
211
211
  ```coffee
212
212
  # views/posts/index.coffee
213
213
  $(".posts-table).html("""<%=j render(partial: "/posts_table", posts: @posts ) %>""");
214
214
  ```
215
215
 
216
- I really do not like this patern. This leaves your you javascript spread out all over your application and it is hard to keep track your apps workflow.
216
+ I really do not like this patern. This leaves your javascript spread out all over your application and it is hard to keep track your apps workflow.
217
217
 
218
- Here is my happy place for this
218
+ Here is my happy place for this:
219
219
 
220
220
  Step 1. Add the gem to gemfile and bundle
221
221
 
@@ -234,7 +234,7 @@ class PostsController
234
234
  end
235
235
  ```
236
236
 
237
- Step 3. in `app/assets/javascripts/controllers/posts_controller.coffee`
237
+ Step 3. in `app/assets/javascripts/controllers/posts_controller.coffee`.
238
238
 
239
239
  ```ruby
240
240
  class this.PostsController
@@ -252,6 +252,18 @@ Step 4. Add `assets/controllers` to your manifest application.js
252
252
 
253
253
  Step 5. Rejoice!
254
254
 
255
+ ## Change!
256
+
257
+ ![alt text](http://www.quickmeme.com/img/01/014e589af009a1b458ee234119a6c5478e52365976f85ba3590552e44f04fc81.jpg "Stewie dosn't like change")
258
+
259
+ I expect many rails developers will not be so keen to jump on board. Some will have legitimate reasons. If you have a legitimate reason or think that this pattern could be improved upon, open an issue and I would love to get a discussion going, but lets try to not be like Stewie Griffin and fear change and be more like Winston Churchill.
260
+
261
+ "To improve is to change; to be perfect is to change often." - Winston Churchill
262
+
263
+ ## Shout-out
264
+
265
+ I started building this gem and part way though found the [paloma gem](http://www.github.com/kbparagua/paloma). Paloma is a cool implemention that is similar to happy_place. I leaned on palomas source code during development of happy_place so I thought it would be appropriate to shout out to [@kbparagua](https://github.com/kbparagua).
266
+
255
267
  ## Donating
256
268
  Support this project and [others by mfpiccolo][gittip-mfpiccolo] via [gittip][gittip-mfpiccolo].
257
269
 
data/happy_place.gemspec CHANGED
@@ -18,8 +18,12 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_runtime_dependency "rails", ">= 3.0"
21
+ spec.add_runtime_dependency "rails", ">= 3.0"
22
22
 
23
- spec.add_development_dependency "bundler", "~> 1.7"
24
- spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "bundler", "~> 1.7"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "mocha", "~> 1.0.0"
26
+ spec.add_development_dependency "rspec", "~> 2.14"
27
+ spec.add_development_dependency "yard", "~> 0.8"
28
+ spec.add_development_dependency "sqlite3", "~> 1.3.10"
25
29
  end
@@ -14,11 +14,30 @@ module HappyPlace
14
14
 
15
15
  # instance methods to go on every controller go here
16
16
  def js(js_class: nil, function: nil, partials: {}, args: {})
17
- return unless [:js, :html].include?(request.format.to_sym)
17
+ class_and_function = build_class_and_function(js_class, function)
18
+ built_args = build_args(partials, args)
19
+ case request.format.to_sym
20
+ when :js
21
+ render js: class_and_function + built_args
22
+ when :html
23
+ render
24
+ response_body = response.body
25
+ before_body_end_index = response_body.rindex('</body>')
26
+
27
+ before_body = response_body[0, before_body_end_index].html_safe
28
+ after_body = response_body[before_body_end_index..-1].html_safe
18
29
 
30
+ response.body = before_body + auto_exec_function(class_and_function, built_args).html_safe + after_body
31
+ end
32
+ end
33
+
34
+ def build_class_and_function(js_class, function)
19
35
  js_class ||= self.class.name.gsub("::", ".")
20
36
  function ||= action_name
37
+ [js_class, function].join(".")
38
+ end
21
39
 
40
+ def build_args(partials, args)
22
41
  if partials.present?
23
42
  built_args = "({" +
24
43
  (build_partials_string(partials) + hash_to_js_args(args)).join(", ") +
@@ -26,26 +45,10 @@ module HappyPlace
26
45
  else
27
46
  built_args = "({" + hash_to_js_args(args).join(", ") + "});"
28
47
  end
29
-
30
- class_function = [js_class, function].join(".")
31
- if request.format.to_sym == :js
32
- render js: class_function + built_args
33
- elsif request.format.to_sym == :html
34
- render
35
- response_body = response.body
36
- before_body_end_index = response_body.rindex('</body>')
37
-
38
- if before_body_end_index.present?
39
- before_body = response_body[0, before_body_end_index].html_safe
40
- after_body = response_body[before_body_end_index..-1].html_safe
41
-
42
- response.body = before_body + clean_script(class_function, built_args).html_safe + after_body
43
- end
44
- end
45
48
  end
46
49
 
47
- def clean_script(class_function, args)
48
- "<script type='application/javascript'>jQuery(document).ready(function($) {" + render_to_string(js: class_function + args) + "});</script>"
50
+ def auto_exec_function(class_and_function, args)
51
+ "<script type='application/javascript'>jQuery(document).ready(function($) {" + render_to_string(js: class_and_function + args) + "});</script>"
49
52
  end
50
53
 
51
54
  def hash_to_js_args(args)
@@ -1,3 +1,3 @@
1
1
  module HappyPlace
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -0,0 +1,16 @@
1
+ *.gem
2
+ *.rbc
3
+ .DS_Store
4
+ .bundle
5
+ .rvmrc
6
+ .yardoc
7
+ .rake_tasks~
8
+ Gemfile.lock
9
+ coverage/*
10
+ doc/*
11
+ log/*
12
+ pkg/*
13
+ .idea/*
14
+ pg*
15
+ .bundle*
16
+ *.log
@@ -0,0 +1,261 @@
1
+ == Welcome to Rails
2
+
3
+ Rails is a web-application framework that includes everything needed to create
4
+ database-backed web applications according to the Model-View-Control pattern.
5
+
6
+ This pattern splits the view (also called the presentation) into "dumb"
7
+ templates that are primarily responsible for inserting pre-built data in between
8
+ HTML tags. The model contains the "smart" domain objects (such as Account,
9
+ Product, Person, Post) that holds all the business logic and knows how to
10
+ persist themselves to a database. The controller handles the incoming requests
11
+ (such as Save New Account, Update Product, Show Post) by manipulating the model
12
+ and directing data to the view.
13
+
14
+ In Rails, the model is handled by what's called an object-relational mapping
15
+ layer entitled Active Record. This layer allows you to present the data from
16
+ database rows as objects and embellish these data objects with business logic
17
+ methods. You can read more about Active Record in
18
+ link:files/vendor/rails/activerecord/README.html.
19
+
20
+ The controller and view are handled by the Action Pack, which handles both
21
+ layers by its two parts: Action View and Action Controller. These two layers
22
+ are bundled in a single package due to their heavy interdependence. This is
23
+ unlike the relationship between the Active Record and Action Pack that is much
24
+ more separate. Each of these packages can be used independently outside of
25
+ Rails. You can read more about Action Pack in
26
+ link:files/vendor/rails/actionpack/README.html.
27
+
28
+
29
+ == Getting Started
30
+
31
+ 1. At the command prompt, create a new Rails application:
32
+ <tt>rails new myapp</tt> (where <tt>myapp</tt> is the application name)
33
+
34
+ 2. Change directory to <tt>myapp</tt> and start the web server:
35
+ <tt>cd myapp; rails server</tt> (run with --help for options)
36
+
37
+ 3. Go to http://localhost:3000/ and you'll see:
38
+ "Welcome aboard: You're riding Ruby on Rails!"
39
+
40
+ 4. Follow the guidelines to start developing your application. You can find
41
+ the following resources handy:
42
+
43
+ * The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html
44
+ * Ruby on Rails Tutorial Book: http://www.railstutorial.org/
45
+
46
+
47
+ == Debugging Rails
48
+
49
+ Sometimes your application goes wrong. Fortunately there are a lot of tools that
50
+ will help you debug it and get it back on the rails.
51
+
52
+ First area to check is the application log files. Have "tail -f" commands
53
+ running on the server.log and development.log. Rails will automatically display
54
+ debugging and runtime information to these files. Debugging info will also be
55
+ shown in the browser on requests from 127.0.0.1.
56
+
57
+ You can also log your own messages directly into the log file from your code
58
+ using the Ruby logger class from inside your controllers. Example:
59
+
60
+ class WeblogController < ActionController::Base
61
+ def destroy
62
+ @weblog = Weblog.find(params[:id])
63
+ @weblog.destroy
64
+ logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
65
+ end
66
+ end
67
+
68
+ The result will be a message in your log file along the lines of:
69
+
70
+ Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1!
71
+
72
+ More information on how to use the logger is at http://www.ruby-doc.org/core/
73
+
74
+ Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are
75
+ several books available online as well:
76
+
77
+ * Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe)
78
+ * Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
79
+
80
+ These two books will bring you up to speed on the Ruby language and also on
81
+ programming in general.
82
+
83
+
84
+ == Debugger
85
+
86
+ Debugger support is available through the debugger command when you start your
87
+ Mongrel or WEBrick server with --debugger. This means that you can break out of
88
+ execution at any point in the code, investigate and change the model, and then,
89
+ resume execution! You need to install ruby-debug to run the server in debugging
90
+ mode. With gems, use <tt>sudo gem install ruby-debug</tt>. Example:
91
+
92
+ class WeblogController < ActionController::Base
93
+ def index
94
+ @posts = Post.all
95
+ debugger
96
+ end
97
+ end
98
+
99
+ So the controller will accept the action, run the first line, then present you
100
+ with a IRB prompt in the server window. Here you can do things like:
101
+
102
+ >> @posts.inspect
103
+ => "[#<Post:0x14a6be8
104
+ @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>,
105
+ #<Post:0x14a6620
106
+ @attributes={"title"=>"Rails", "body"=>"Only ten..", "id"=>"2"}>]"
107
+ >> @posts.first.title = "hello from a debugger"
108
+ => "hello from a debugger"
109
+
110
+ ...and even better, you can examine how your runtime objects actually work:
111
+
112
+ >> f = @posts.first
113
+ => #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
114
+ >> f.
115
+ Display all 152 possibilities? (y or n)
116
+
117
+ Finally, when you're ready to resume execution, you can enter "cont".
118
+
119
+
120
+ == Console
121
+
122
+ The console is a Ruby shell, which allows you to interact with your
123
+ application's domain model. Here you'll have all parts of the application
124
+ configured, just like it is when the application is running. You can inspect
125
+ domain models, change values, and save to the database. Starting the script
126
+ without arguments will launch it in the development environment.
127
+
128
+ To start the console, run <tt>rails console</tt> from the application
129
+ directory.
130
+
131
+ Options:
132
+
133
+ * Passing the <tt>-s, --sandbox</tt> argument will rollback any modifications
134
+ made to the database.
135
+ * Passing an environment name as an argument will load the corresponding
136
+ environment. Example: <tt>rails console production</tt>.
137
+
138
+ To reload your controllers and models after launching the console run
139
+ <tt>reload!</tt>
140
+
141
+ More information about irb can be found at:
142
+ link:http://www.rubycentral.org/pickaxe/irb.html
143
+
144
+
145
+ == dbconsole
146
+
147
+ You can go to the command line of your database directly through <tt>rails
148
+ dbconsole</tt>. You would be connected to the database with the credentials
149
+ defined in database.yml. Starting the script without arguments will connect you
150
+ to the development database. Passing an argument will connect you to a different
151
+ database, like <tt>rails dbconsole production</tt>. Currently works for MySQL,
152
+ PostgreSQL and SQLite 3.
153
+
154
+ == Description of Contents
155
+
156
+ The default directory structure of a generated Ruby on Rails application:
157
+
158
+ |-- app
159
+ | |-- assets
160
+ | | |-- images
161
+ | | |-- javascripts
162
+ | | `-- stylesheets
163
+ | |-- controllers
164
+ | |-- helpers
165
+ | |-- mailers
166
+ | |-- models
167
+ | `-- views
168
+ | `-- layouts
169
+ |-- config
170
+ | |-- environments
171
+ | |-- initializers
172
+ | `-- locales
173
+ |-- db
174
+ |-- doc
175
+ |-- lib
176
+ | |-- assets
177
+ | `-- tasks
178
+ |-- log
179
+ |-- public
180
+ |-- script
181
+ |-- test
182
+ | |-- fixtures
183
+ | |-- functional
184
+ | |-- integration
185
+ | |-- performance
186
+ | `-- unit
187
+ |-- tmp
188
+ | `-- cache
189
+ | `-- assets
190
+ `-- vendor
191
+ |-- assets
192
+ | |-- javascripts
193
+ | `-- stylesheets
194
+ `-- plugins
195
+
196
+ app
197
+ Holds all the code that's specific to this particular application.
198
+
199
+ app/assets
200
+ Contains subdirectories for images, stylesheets, and JavaScript files.
201
+
202
+ app/controllers
203
+ Holds controllers that should be named like weblogs_controller.rb for
204
+ automated URL mapping. All controllers should descend from
205
+ ApplicationController which itself descends from ActionController::Base.
206
+
207
+ app/models
208
+ Holds models that should be named like post.rb. Models descend from
209
+ ActiveRecord::Base by default.
210
+
211
+ app/views
212
+ Holds the template files for the view that should be named like
213
+ weblogs/index.html.erb for the WeblogsController#index action. All views use
214
+ eRuby syntax by default.
215
+
216
+ app/views/layouts
217
+ Holds the template files for layouts to be used with views. This models the
218
+ common header/footer method of wrapping views. In your views, define a layout
219
+ using the <tt>layout :default</tt> and create a file named default.html.erb.
220
+ Inside default.html.erb, call <% yield %> to render the view using this
221
+ layout.
222
+
223
+ app/helpers
224
+ Holds view helpers that should be named like weblogs_helper.rb. These are
225
+ generated for you automatically when using generators for controllers.
226
+ Helpers can be used to wrap functionality for your views into methods.
227
+
228
+ config
229
+ Configuration files for the Rails environment, the routing map, the database,
230
+ and other dependencies.
231
+
232
+ db
233
+ Contains the database schema in schema.rb. db/migrate contains all the
234
+ sequence of Migrations for your schema.
235
+
236
+ doc
237
+ This directory is where your application documentation will be stored when
238
+ generated using <tt>rake doc:app</tt>
239
+
240
+ lib
241
+ Application specific libraries. Basically, any kind of custom code that
242
+ doesn't belong under controllers, models, or helpers. This directory is in
243
+ the load path.
244
+
245
+ public
246
+ The directory available for the web server. Also contains the dispatchers and the
247
+ default HTML files. This should be set as the DOCUMENT_ROOT of your web
248
+ server.
249
+
250
+ script
251
+ Helper scripts for automation and generation.
252
+
253
+ test
254
+ Unit and functional tests along with fixtures. When using the rails generate
255
+ command, template test files will be generated for you and placed in this
256
+ directory.
257
+
258
+ vendor
259
+ External libraries that the application depends on. Also includes the plugins
260
+ subdirectory. If the app has frozen rails, those gems also go here, under
261
+ vendor/rails/. This directory is in the load path.
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env rake
2
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
3
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4
+
5
+ require File.expand_path('../config/application', __FILE__)
6
+
7
+ Dummy::Application.load_tasks
@@ -0,0 +1,2 @@
1
+ class ApplicationController < ActionController::Base
2
+ end
@@ -0,0 +1,7 @@
1
+ class ExamplesController < ApplicationController
2
+
3
+ def index
4
+
5
+ end
6
+
7
+ end
File without changes
@@ -0,0 +1,63 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ Bundler.require(*Rails.groups)
6
+
7
+ module Dummy
8
+ class Application < Rails::Application
9
+ # Settings in config/environments/* take precedence over those specified here.
10
+ # Application configuration should go into files in config/initializers
11
+ # -- all .rb files in that directory are automatically loaded.
12
+
13
+ # Custom directories with classes and modules you want to be autoloadable.
14
+ # config.autoload_paths += %W(#{config.root}/extras)
15
+
16
+ # Only load the plugins named here, in the order given (default is alphabetical).
17
+ # :all can be used as a placeholder for all plugins not explicitly named.
18
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
19
+
20
+ # Activate observers that should always be running.
21
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
22
+
23
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
24
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
25
+ # config.time_zone = 'Central Time (US & Canada)'
26
+
27
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
28
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
29
+ # config.i18n.default_locale = :de
30
+
31
+ # Configure the default encoding used in templates for Ruby 1.9.
32
+ config.encoding = "utf-8"
33
+
34
+ # Configure sensitive parameters which will be filtered from the log file.
35
+ config.filter_parameters += [:password]
36
+
37
+ # Enable escaping HTML in JSON.
38
+ config.active_support.escape_html_entities_in_json = true
39
+
40
+ # Use SQL instead of Active Record's schema dumper when creating the database.
41
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
42
+ # like if you have constraints or database-specific column types
43
+ # config.active_record.schema_format = :sql
44
+
45
+ # Enforce whitelist mode for mass assignment.
46
+ # This will create an empty whitelist of attributes available for mass-assignment for all models
47
+ # in your app. As such, your models will need to explicitly whitelist or blacklist accessible
48
+ # parameters by using an attr_accessible or attr_protected declaration.
49
+
50
+ # Enable the asset pipeline
51
+ config.assets.enabled = true
52
+
53
+ # Version of your assets, change this if you want to expire all your assets
54
+ config.assets.version = '1.0'
55
+
56
+ config.generators do |g|
57
+ g.test_framework :rspec
58
+ g.fixture_replacement :factory_girl
59
+ end
60
+ # Test::Unit.run = true
61
+ end
62
+ end
63
+
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ gemfile = File.expand_path('../../../../Gemfile', __FILE__)
3
+
4
+ if File.exist?(gemfile)
5
+ ENV['BUNDLE_GEMFILE'] = gemfile
6
+ require 'bundler'
7
+ Bundler.setup
8
+ end
9
+
10
+ $:.unshift File.expand_path('../../../../lib', __FILE__)
@@ -0,0 +1,19 @@
1
+ development:
2
+ timeout: 5000
3
+ database: dummy_development
4
+ adapter: sqlite3
5
+ encoding: utf8
6
+ host: localhost
7
+ username: postgres
8
+ # password: secret
9
+
10
+ # Warning: The database defined as 'test' will be erased and
11
+ # re-generated from your development database when you run 'rake'.
12
+ # Do not set this db to the same as development or production.
13
+ test: &test
14
+ timeout: 5000
15
+ database: dummy_test<%= ENV['TEST_ENV_NUMBER'] %>
16
+ adapter: sqlite3
17
+ encoding: utf8
18
+ host: localhost
19
+ username: postgres
@@ -0,0 +1,5 @@
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ Dummy::Application.initialize!
@@ -0,0 +1,30 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the web server when you make code changes.
7
+ config.cache_classes = false
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.consider_all_requests_local = 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
18
+
19
+ # Print deprecation notices to the Rails logger
20
+ config.active_support.deprecation = :log
21
+
22
+ # Only use best-standards-support built into browsers
23
+ config.action_dispatch.best_standards_support = :builtin
24
+
25
+ # Do not compress assets
26
+ config.assets.compress = false
27
+
28
+ # Expands the lines which load the assets
29
+ config.assets.debug = true
30
+ end