dry_scaffold 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. data/CHANGELOG.textile +55 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.textile +473 -0
  4. data/Rakefile +54 -0
  5. data/TODO.textile +36 -0
  6. data/bin/dmodel +3 -0
  7. data/bin/dry_model +3 -0
  8. data/bin/dry_scaffold +3 -0
  9. data/bin/dscaffold +3 -0
  10. data/config/scaffold.yml +33 -0
  11. data/generators/dmodel/dmodel_generator.rb +15 -0
  12. data/generators/dry_model/USAGE +9 -0
  13. data/generators/dry_model/dry_model_generator.rb +134 -0
  14. data/generators/dry_model/prototypes/active_record_migration.rb +17 -0
  15. data/generators/dry_model/prototypes/active_record_model.rb +9 -0
  16. data/generators/dry_model/prototypes/fixture_data/active_record_fixtures.yml +3 -0
  17. data/generators/dry_model/prototypes/fixture_data/factory_girl_factories.rb +4 -0
  18. data/generators/dry_model/prototypes/fixture_data/machinist_blueprints.rb +8 -0
  19. data/generators/dry_model/prototypes/tests/rspec/unit_test.rb +9 -0
  20. data/generators/dry_model/prototypes/tests/shoulda/unit_test.rb +20 -0
  21. data/generators/dry_model/prototypes/tests/test_unit/unit_test.rb +15 -0
  22. data/generators/dry_model/templates/models/active_record_migration.rb +23 -0
  23. data/generators/dry_model/templates/models/active_record_model.rb +15 -0
  24. data/generators/dry_model/templates/models/fixture_data/active_record_fixtures.yml +6 -0
  25. data/generators/dry_model/templates/models/fixture_data/factory_girl_factories.rb +5 -0
  26. data/generators/dry_model/templates/models/fixture_data/machinist_blueprints.rb +9 -0
  27. data/generators/dry_model/templates/models/tests/rspec/unit_test.rb +11 -0
  28. data/generators/dry_model/templates/models/tests/shoulda/unit_test.rb +23 -0
  29. data/generators/dry_model/templates/models/tests/test_unit/unit_test.rb +17 -0
  30. data/generators/dry_scaffold/USAGE +11 -0
  31. data/generators/dry_scaffold/dry_scaffold_generator.rb +410 -0
  32. data/generators/dry_scaffold/prototypes/controllers/action_controller.rb +135 -0
  33. data/generators/dry_scaffold/prototypes/controllers/inherited_resources_controller.rb +25 -0
  34. data/generators/dry_scaffold/prototypes/controllers/tests/rspec/functional_test.rb +57 -0
  35. data/generators/dry_scaffold/prototypes/controllers/tests/shoulda/functional_test.rb +99 -0
  36. data/generators/dry_scaffold/prototypes/controllers/tests/test_unit/functional_test.rb +70 -0
  37. data/generators/dry_scaffold/prototypes/helpers/helper.rb +3 -0
  38. data/generators/dry_scaffold/prototypes/helpers/tests/rspec/unit_test.rb +9 -0
  39. data/generators/dry_scaffold/prototypes/helpers/tests/shoulda/unit_test.rb +9 -0
  40. data/generators/dry_scaffold/prototypes/helpers/tests/test_unit/unit_test.rb +9 -0
  41. data/generators/dry_scaffold/prototypes/views/builder/index.atom.builder +20 -0
  42. data/generators/dry_scaffold/prototypes/views/builder/index.rss.builder +21 -0
  43. data/generators/dry_scaffold/prototypes/views/haml/_form.html.haml +3 -0
  44. data/generators/dry_scaffold/prototypes/views/haml/_item.html.haml +9 -0
  45. data/generators/dry_scaffold/prototypes/views/haml/edit.html.haml +10 -0
  46. data/generators/dry_scaffold/prototypes/views/haml/index.html.haml +17 -0
  47. data/generators/dry_scaffold/prototypes/views/haml/layout.html.haml +18 -0
  48. data/generators/dry_scaffold/prototypes/views/haml/new.html.haml +10 -0
  49. data/generators/dry_scaffold/prototypes/views/haml/show.html.haml +13 -0
  50. data/generators/dry_scaffold/templates/controllers/action_controller.rb +250 -0
  51. data/generators/dry_scaffold/templates/controllers/inherited_resources_controller.rb +26 -0
  52. data/generators/dry_scaffold/templates/controllers/tests/rspec/functional_test.rb +85 -0
  53. data/generators/dry_scaffold/templates/controllers/tests/shoulda/functional_test.rb +90 -0
  54. data/generators/dry_scaffold/templates/controllers/tests/test_unit/functional_test.rb +87 -0
  55. data/generators/dry_scaffold/templates/helpers/helper.rb +3 -0
  56. data/generators/dry_scaffold/templates/helpers/tests/rspec/unit_test.rb +9 -0
  57. data/generators/dry_scaffold/templates/helpers/tests/shoulda/unit_test.rb +9 -0
  58. data/generators/dry_scaffold/templates/helpers/tests/test_unit/unit_test.rb +9 -0
  59. data/generators/dry_scaffold/templates/views/builder/index.atom.builder +20 -0
  60. data/generators/dry_scaffold/templates/views/builder/index.rss.builder +21 -0
  61. data/generators/dry_scaffold/templates/views/haml/_form.html.haml +13 -0
  62. data/generators/dry_scaffold/templates/views/haml/_item.html.haml +10 -0
  63. data/generators/dry_scaffold/templates/views/haml/edit.html.haml +18 -0
  64. data/generators/dry_scaffold/templates/views/haml/index.html.haml +20 -0
  65. data/generators/dry_scaffold/templates/views/haml/layout.html.haml +19 -0
  66. data/generators/dry_scaffold/templates/views/haml/new.html.haml +18 -0
  67. data/generators/dry_scaffold/templates/views/haml/show.html.haml +13 -0
  68. data/generators/dscaffold/dscaffold_generator.rb +15 -0
  69. data/lib/dry_generator.rb +197 -0
  70. data/lib/dry_scaffold/tasks.rb +5 -0
  71. data/lib/setup_helper.rb +36 -0
  72. data/tasks/dry_scaffold.rake +95 -0
  73. metadata +140 -0
@@ -0,0 +1,55 @@
1
+ h1. 0.3.6 (2009-12-31)
2
+
3
+ * Gemcutter as gem source.
4
+
5
+ h1. 0.3.4 (2009-09-16)
6
+
7
+ * Fixed bug: Make it possible to require rake tasks (In Rakefile: require 'dry_scaffold/tasks')
8
+
9
+ h1. 0.3.2/0.3.3 (2009-09-14)
10
+
11
+ * Fixed bug: Rspec tests issues
12
+
13
+ h1. 0.3.1 (2009-09-09)
14
+
15
+ * Feature: Added Rspec tests generation
16
+
17
+ h1. 0.3.0 (2009-07-23)
18
+
19
+ * Major refactoring of the code.
20
+ * Test/Fixture-stuff re-written from the ground, now tested thoroughly and considered stable - was not before. Plenty sloppy bugs squashed.
21
+ * Added Shoulda tests generation.
22
+
23
+ h1. 0.2.5 (2009-06-12)
24
+
25
+ * Fixed typo: Gem configuration instructions in README.
26
+ * Fixed bug: Re-generated gemspec - missing files. (cjheath)
27
+
28
+ h1. 0.2.4 (2009-05-19)
29
+
30
+ * Fixed bug: Causing generator to fail if test/unit/helpers path don't exist.
31
+
32
+ h1. 0.2.3 (2009-05-12)
33
+
34
+ * Fixed bug: Missing executables in gemspec.
35
+
36
+ h1. 0.2.2 (2009-05-06)
37
+
38
+ * Feature: Specifying actions new+ instead of new, then actions new/create. Same applies to edit+, i.e. edit/update.
39
+ * Feature: For respond_to-formats ATOM/RSS; builders will be generated unless --skip-builders flag is specified
40
+ * Feature: If route is already declared in 'config/routes.rb', then don't generate the route again.
41
+ * Refactor: New template directory structure and naming conventions - more generic. Preparing for optional test frameworks.
42
+ * Refactor: Cleaned up views with generator helpers.
43
+ * Fixed bug: Options for factory_girl vs. machinist got in-versed, i.e. typo.
44
+ * Fixed bug: Options got ignored because of a typo. Grrr....
45
+
46
+ h1. 0.2.1 (2009-05-03)
47
+
48
+ * New feature: Possible to set generator default args in a config file (config/scaffold.yml), or rely on defaults.
49
+ * Fixed issue: Rails default_options don't seem to work at all; replacing it with own solution.
50
+ * Fixed bug: Typo in formats arg parser.
51
+ * Refactor: Gem requires less hardcoded.
52
+
53
+ h1. 0.2.0 (2009-05-01)
54
+
55
+ * New dry model generator: Extends Rails default model generator with features such as generation of factory_girl/machinis/object_daddy-factories if available and requested (or fixtures), and specifying database column indexes upon generation in a very convenient way.
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Jonas Grimfelt
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,473 @@
1
+ h1. DRY SCAFFOLD
2
+
3
+ _A Rails scaffold generator that generates DRYer, cleaner, and more useful code._
4
+
5
+ h2. Description
6
+
7
+ DryScaffold is a replacement for the Rails scaffold generator that generates code that most people end up deleting or rewriting anyway because of the unusable code. The scaffold concept is powerful, but it has more potential than generating messy and almost useless code - something that might change with Rails 3 though. The goal with DryScaffold is to generate DRY, beautiful, and standards compliant code based on common patterns without adding a lot of assumptions.
8
+
9
+ *Key Concepts:*
10
+
11
+ * Controllers that are DRY, RESTful, no code-smells, following conventions, and implementing VERY common patterns.
12
+ * Views that are DRY, semantic, standards compliant, valid, and more useful in development.
13
+ * Factories instead of fixtures.
14
+ * Generator that gets smart with additional arguments - but not stupid without them.
15
+ * Any Rails developer should be able to switch generator with no effort - follow current conventions, but extend them.
16
+
17
+ h2. Dependencies
18
+
19
+ h3. Required:
20
+
21
+ * "*haml*":http://github.com/nex3/haml - ERB sucks like PHP, end of story
22
+
23
+ h3. Optional:
24
+
25
+ h4. Controllers/Views
26
+
27
+ * "*inherited_resources*":http://github.com/josevalim/inherited_resources - DRY/Resourceful controllers
28
+ * "*formtastic*":http://github.com/justinfrench/formtastic - DRY and semantic forms
29
+ * "*will_paginate*":http://github.com/mislav/will_paginate - Pagination
30
+
31
+ h4. Models
32
+
33
+ * "*factory_girl*":http://github.com/thoughtbot/factory_girl - Fixture-replacement
34
+ * "*machinist*":http://github.com/notahat/machinist - Fixture-replacement
35
+ * "*object_daddy*":http://github.com/flogic/object_daddy - Fixture-replacement
36
+
37
+ h4. Testing
38
+
39
+ * "*shoulda*":http://github.com/thoughtbot/shoulda - Testing framework
40
+ * "*rspec*":http://wiki.github.com/dchelimsky/rspec - Testing framework
41
+
42
+ h2. Features
43
+
44
+ h3. Overview
45
+
46
+ The most characteristic features:
47
+
48
+ * Generates DRY controllers + functional tests.
49
+ * Generates DRY, semantic, and standard compliant views in HAML - not just HAMLized templates.
50
+ * Generates formtastic - very DRY - forms (using "formtastic" by Justin French et. al.) by default. Note: Can be turned off.
51
+ * Generates resourceful - even DRYer - controllers (using the "inherited_resources" by José Valim) by default. Note: Can be turned off.
52
+ * Collection pagination using will_paginate by default. Note: Can be turned off.
53
+ * Optionally specify what actions/views to generate (stubs for specified REST-actions will be generated).
54
+ * Optionally specify what respond_to-formats to generate (stubs for the most common respond_to-formats will be generated).
55
+ * Generates default helpers/models/migrations, and REST-routes (if not already defined).
56
+
57
+ h3. Formtastic Forms
58
+
59
+ Quick and dirty; Formtastic makes your form views cleaner, and your life as a Rails developer easier (for real). Formtastic forms can be turned off, but I would recommend any Rails developer to consider using it - there is really no good reason not to if you not running very old version of Rails.
60
+
61
+ h4. Standard
62
+
63
+ HAML + ActionView FormHelpers:
64
+
65
+ <pre>
66
+ - form_for(@duck) do |f|
67
+ = f.error_messages
68
+ %ul
69
+ %li
70
+ = f.label :name, 'Name'
71
+ = f.text_field :name
72
+ %li
73
+ = f.label :about, 'About'
74
+ = f.text_area :about
75
+ %p.buttons
76
+ = f.submit 'Create'
77
+ </pre>
78
+
79
+ h4. Formtastic
80
+
81
+ HAML + Formtastic:
82
+
83
+ <pre>
84
+ - semantic_form_for(@duck) do |f|
85
+ - f.inputs do
86
+ = f.input :name
87
+ = f.input :about
88
+ - f.buttons do
89
+ = f.commit_button 'Create'
90
+ </pre>
91
+
92
+ Find out more about *formtastic*: "http://github.com/justinfrench/formtastic":http://github.com/justinfrench/formtastic
93
+
94
+ h3. Resourceful Controllers
95
+
96
+ Quick and dirty; InheritedResources makes your controllers controllers cleaner, and might make experienced Rails developer's life DRYer code wise. This is possible because of REST as a convention in Rails, and therefore the patterns that arise in controllers can be DRYed up A LOT. Resourceful - InheritedResources-based - controllers can be turned off, but I would recommend any experienced Rails developer to consider using it - there is really no good reason not to unless maybe if you are a Rails beginner, then you should consider get used to the basic Rails building blocks first.
97
+
98
+ h4. Standard
99
+
100
+ Using ActionController:
101
+
102
+ <pre>
103
+ def new
104
+ @duck = Duck.new
105
+
106
+ respond_to do |format|
107
+ format.html # new.html.haml
108
+ format.xml { render :xml => @duck }
109
+ format.json { render :json => @duck }
110
+ end
111
+ end
112
+ </pre>
113
+
114
+ h4. Resourceful
115
+
116
+ Using InheritedResources:
117
+
118
+ <pre>
119
+ actions :new
120
+ respond_to :html, :xml, :json
121
+ </pre>
122
+
123
+ Find out more about *inherited_resources*: "http://github.com/josevalim/inherited_resources":http://github.com/josevalim/inherited_resources
124
+
125
+ h3. Pagination
126
+
127
+ Pagination is such a common feature that always seems to be implemented anyway, so DryScaffold will generate a DRY solution for this in each controller that you can tweak - even thought that will not be needed in most cases. See DRY Patterns beneath for more details how it's done. Pagination - using WillPaginate - can be turned off.
128
+
129
+ Find out more about *will_paginate*: "http://github.com/mislav/will_paginate":http://github.com/mislav/will_paginate
130
+
131
+ h3. DRYying Patterns
132
+
133
+ Either if you choosing default or resourceful controllers, this pattern is used to DRYing up controllers a bit more, and at the same time loading resources in the same place using before_filter while adding automatic pagination for collections.
134
+
135
+ h4. Standard
136
+
137
+ ActionController with pagination:
138
+
139
+ <pre>
140
+ before_filter :load_resource, :only => [:show, :edit, :update, :destroy]
141
+ before_filter :load_and_paginate_resources, :only => [:index]
142
+
143
+ ...
144
+
145
+ protected
146
+
147
+ def collection
148
+ paginate_options ||= {}
149
+ paginate_options[:page] ||= (params[:page] || 1)
150
+ paginate_options[:per_page] ||= (params[:per_page] || 20)
151
+ @collection = @resources ||= Duck.paginate(paginate_options)
152
+ end
153
+ alias :load_and_paginate_resources :collection
154
+
155
+ def resource
156
+ @resource = @resource = ||= Duck.find(params[:id])
157
+ end
158
+ alias :load_resource :resource
159
+ </pre>
160
+
161
+ h4. Resourceful
162
+
163
+ InheritedResources with pagination:
164
+
165
+ <pre>
166
+ protected
167
+
168
+ def collection
169
+ paginate_options ||= {}
170
+ paginate_options[:page] ||= (params[:page] || 1)
171
+ paginate_options[:per_page] ||= (params[:per_page] || 20)
172
+ @resources ||= end_of_association_chain.paginate(paginate_options)
173
+ end
174
+ </pre>
175
+
176
+ h3. View Partials
177
+
178
+ A very common pattern is to break up views in partials, which is also what DryScaffold does:
179
+
180
+ * @new@/@edit@ => @_form@
181
+ * @index@ => @_item@
182
+
183
+ h2. Setup
184
+
185
+ Installing DryScaffold is easy:
186
+
187
+ h3. 1. Installation
188
+
189
+ Install DryScaffold...
190
+
191
+ h4. Gem (Recommended)
192
+
193
+ <pre>sudo gem install dry_scaffold</pre>
194
+
195
+ ...and in config: @config/environments/development.rb@
196
+
197
+ <pre>config.gem 'dry_scaffold', :lib => false</pre>
198
+
199
+ h4. Plugin
200
+
201
+ <pre>./script/plugin install git://github.com/grimen/dry_scaffold.git</pre>
202
+
203
+ h3. 2. Install Dependencies (Partly optional)
204
+
205
+ Install dependencies to release the full power of dry_scaffold. Only HAML is really required of these, but how could anyone resist candy? =)
206
+
207
+ h4. Automatic/Express
208
+
209
+ For us lazy ones... =) *Note:* Probably won't work without require the rake tasks first in the project @Rakefile@: @require 'dry_scaffold/tasks'@
210
+
211
+ <pre>rake dry_scaffold:setup</pre>
212
+
213
+ Will install the dependencies, initialize HAML within current Rails project if not already done, and automatically referencing the dependency gems within the current Rails project environment config if they are not already in there (note: nothing will be overwritten).
214
+
215
+ h4. Manual
216
+
217
+ Get the gems...you want:
218
+
219
+ <pre>
220
+ sudo gem install haml
221
+ sudo gem install will_paginate
222
+ sudo gem install formtastic
223
+ sudo gem install inherited_resources
224
+ </pre>
225
+
226
+ ...and same for the config config: @config/environments/development.rb@
227
+
228
+ <pre>
229
+ config.gem 'haml'
230
+ config.gem 'will_paginate'
231
+ config.gem 'formtastic'
232
+ config.gem 'inherited_resources'
233
+ </pre>
234
+
235
+ Also configure @config/environments/test.rb@ with the RSpec library if you want to
236
+
237
+ <pre>
238
+ config.gem 'rspec'
239
+ config.gem 'rspec-rails'
240
+ </pre>
241
+
242
+ And don't forget to initialize it as well:
243
+
244
+ <pre>
245
+ ./script/generate rspec
246
+ </pre>
247
+
248
+ To access Rake tasks in Rails from the gem version of DryScaffold you need to do this:
249
+
250
+ In your project @Rakefile@:
251
+
252
+ <pre>
253
+ require 'dry_scaffold/tasks'
254
+ </pre>
255
+
256
+ Don't ask me why me why this is the only way with gems...Ask the Rails core team, because this is not conventions over configuration. Raur...
257
+
258
+ h2. Usage
259
+
260
+ <pre>
261
+ ./script/generate dry_scaffold ModelName [attribute:type attribute:type] [_actions:new,create,...] [_formats:html,json,...] [_indexes:attribute,...] [--skip-pagination] [--skip-resourceful] [--skip-formtastic] [--skip-views] [--skip-helpers] [--skip-migration] [--skip-timestamps] [--skip-tests] [--skip-controller-tests] [--layout] [--tunit] [--shoulda] [--rspec] [--fixtures] [--fgirl] [--machinist] [--odaddy]
262
+ </pre>
263
+
264
+ ...or use the alias @dscaffold@ instead of @dry_scaffold@.
265
+
266
+ For generating just a *model*, then use:
267
+
268
+ <pre>
269
+ ./script/generate dry_model ModelName [attribute:type attribute:type] [_indexes:attribute,...] [--skip-migration] [--skip-timestamps] [--skip-tests] [--tunit] [--shoulda] [--rspec] [--fixtures] [--fgirl] [--machinist] [--odaddy]
270
+ </pre>
271
+
272
+ ...or use the alias @dmodel@ instead of @dry_model@.
273
+
274
+ h3. Model Name
275
+
276
+ Example:
277
+
278
+ <pre>Duck</pre>
279
+
280
+ Same as in the default scaffold/model generator; the name of a new/existing model.
281
+
282
+ h3. Model Attributes
283
+
284
+ Example:
285
+
286
+ <pre>name:string about:text ...</pre>
287
+
288
+ Same as in the default scaffold/model generator; model attributes and database migration column types.
289
+
290
+ h3. Controller Actions
291
+
292
+ Example:
293
+
294
+ <pre>_actions:new,create,quack,index,...</pre>
295
+
296
+ You can override what actions that should be generated directly - including custom actions.
297
+
298
+ h4. Default Actions (REST)
299
+
300
+ If no actions are specified, the following REST-actions will be generated by default:
301
+
302
+ * @show@
303
+ * @index@
304
+ * @new@
305
+ * @edit@
306
+ * @create@
307
+ * @update@
308
+ * @destroy@
309
+
310
+ Default controller action stubs, controller action test stubs, and corresponding views (and required partials), are generated for all of these actions.
311
+
312
+ These default actions can also be included using the quantifiers @*@ and @+@, which makes it easier to add new actions without having to specify all the default actions explicit. Example:
313
+
314
+ <pre>_actions:quack # => quack</pre>
315
+ <pre>_actions:*,quack # => show,index,new,edit,create,update,destroy,quack</pre>
316
+ <pre>_actions:new+,edit,quack # => new,edit,create,quack</pre>
317
+ <pre>_actions:new+,edit+,quack # => new,edit,create,update,quack</pre>
318
+
319
+ h4. Custom Actions
320
+
321
+ The above REST actions are in many RESTful applications the only ones needed. Any other specified actions will generate empty action function stubs for manual implementation. No views will be generated for custom actions.
322
+
323
+ h3. Controller Formats
324
+
325
+ Example:
326
+
327
+ <pre>_formats:html,xml,txt,... # <=> _respond_to:html,xml,txt,...</pre>
328
+
329
+ You can override what respond_to-formats that should be generated directly - only for REST-actions right now because I tried to avoid bad assumptions.
330
+
331
+ h4. Default Formats
332
+
333
+ If no formats are specified, the following formats will be generated by default:
334
+
335
+ * @html@ => Template: resource.html.haml
336
+ * @js@ => Template: resource.js.rjs
337
+ * @xml@ => Render: resource.to_xml
338
+ * @json@ => Render: resource.to_json
339
+
340
+ Default respond block stubs are generated for all of these formats - for each generated REST-action.
341
+
342
+ Like for actions, these default respond_to-formats can also be included using the alias symbol @*@, which makes it easier to add new formats without having to specify all the default formats explicit. Example:
343
+
344
+ <pre>_formats:iphone # => _formats:iphone</pre>
345
+ <pre>_formats:*,iphone # => _formats:html,js,xml,json,iphone</pre>
346
+
347
+ h4. Additional Formats
348
+
349
+ Also, default respond block stubs are generated for any of these formats - for each generated REST-action - if they are specified:
350
+
351
+ * @atom@ => Template: index.atom.builder
352
+ * @rss@ => Template: index.rss.builder
353
+ * @yaml@/@yml@ => Render: resource.to_yaml
354
+ * @txt@/@text@ => Render: resource.to_s
355
+
356
+ NOTE: Only for Non-InheritedResources controllers for now.
357
+
358
+ For the feed formats @atom@ and @rss@, builders are automatically generated if @index@-action is specified. Example:
359
+
360
+ @app/views/ducks/index.atom.builder@
361
+
362
+ <pre>
363
+ atom_feed(:language => I18n.locale) do |feed|
364
+ feed.title 'Resources'
365
+ feed.subtitle 'Index of all resources.'
366
+ feed.updated (@resources.first.created_at rescue Time.now.utc).strftime('%Y-%m-%dT%H:%M:%SZ'))
367
+
368
+ @resources.each do |resource|
369
+ feed.entry(resource) do |entry|
370
+ entry.title 'title'
371
+ entry.summary 'summary'
372
+
373
+ resource.author do |author|
374
+ author.name 'author_name'
375
+ end
376
+ end
377
+ end
378
+ end
379
+ </pre>
380
+
381
+ Builder generation can be skipped by specifying the @--skip-builders@ flag.
382
+
383
+ h4. Custom Formats
384
+
385
+ The above formats are the most commonly used ones, and respond blocks are already implemented using Rails default dependencies. Any other specified formats (such as PDF, CSV, etc.) will generate empty respond block stubs for manual implementation with help of additional dependencies.
386
+
387
+ h3. Model Indexes
388
+
389
+ Example:
390
+
391
+ If model attributes are specified as:
392
+
393
+ <pre>name:string owner:reference</pre>
394
+
395
+ ...then we could do this (for polymorphic association):
396
+
397
+ <pre>_indexes:owner_id # => (In migration:) add_index :duck, :owner_id</pre>
398
+
399
+ ...or in account for a polymorphic association:
400
+
401
+ <pre>_indexes:owner_id+owner_type # => (In migration:) add_index :duck, [:owner_id, :owner_type]</pre>
402
+
403
+ NOTE: Of course...you need to specify indexes based on attributes that exists for this model, otherwise your migration will not be valid - DryScaffold is leaving this responsible to you.
404
+
405
+ h3. Options/Flags
406
+
407
+ Example:
408
+
409
+ <pre>--skip-resourceful --layout</pre>
410
+
411
+ h4. Scaffold
412
+
413
+ These are the options for the scaffold-generator.
414
+
415
+ * @--skip-pagination@ - Don't generate pagination of collections in controller and views, i.e. don't use *will_paginate*.
416
+ * @--skip-resourceful@ - Don't generate resourceful controller, i.e. don't use *inherited_resources*.
417
+ * @--skip-formtastic@ - Don't generate formtastic forms in views, i.e. don't use *formtastic*.
418
+ * @--skip-views@ - Don't generate views.
419
+ * @--skip-helpers@ - Don't generate helpers.
420
+ * @--skip-builders@ - Don't generate builders.
421
+ * @--skip-controller-tests@ - Don't generate controller tests
422
+ * @--layout@ - Generate layout.
423
+
424
+ h4. Model
425
+
426
+ These are the options for the model/scaffold-generators.
427
+
428
+ * @--skip-timestamps@ - Don't add timestamps to the migration file.
429
+ * @--skip-migration@ - Skip generation of migration file.
430
+
431
+ h4. All
432
+
433
+ * @--skip-tests@ - Don't generate tests (functional/unit/...).
434
+ * @--tunit@ - Generate/Use test_unit tests. Note: Rails default.
435
+ * @--shoulda@ - Generate/Use *shoulda* tests.
436
+ * @--rspec@ - Generate/Use *rspec* tests.
437
+ * @--fixtures@ - Generate/Use fixtures. Note: Rails default.
438
+ * @--fgirl@ - Generate/Use *factory_girl* factories.
439
+ * @--machinist@ - Generate/Use *machinist* blueprints (factories).
440
+ * @--odaddy@ - Generate/Use *object_daddy* generator/factory methods.
441
+
442
+ As DryScaffold is built upon Rails generator, the default generator options is available as well. For more details; see Rails documentation.
443
+
444
+ h3. Setting Defaults
445
+
446
+ You can set defaults for the generator args/options in @config/scaffold.yml@. To generate this file, simply do:
447
+
448
+ <pre>rake dry_scaffold:config:generate</pre>
449
+
450
+ h2. Examples
451
+
452
+ No need for more samples here, just create a new Rails project, install DryScaffold and it's dependencies, and try it out!
453
+
454
+ For your inspiration, you could try the following:
455
+
456
+ <pre>./script/generate dry_scaffold Zebra name:string about:text --skip-resourceful
457
+ ./script/generate dscaffold Kangaroo name:string about:text --skip-formtastic
458
+ ./script/generate dscaffold Duck name:string about:text _actions:new,create,index,quack
459
+ ./script/generate dscaffold Parrot name:string about:text _formats:html,xml,yml
460
+ ./script/generate dmodel GoldFish name:string about:text _indexes:name --fgirl
461
+ ./script/generate dmodel Frog name:string about:text _indexes:name,name+about --fixtures</pre>
462
+
463
+ ...or just go crazy!
464
+
465
+ h2. Bugs & Feedback
466
+
467
+ If you experience any issues/bugs or have feature requests, just file a GitHub-issue or send me a message.
468
+ If you think parts of my implementation could be implemented nicer somehow, please let me know...or just fork it and fix it yourself! =)
469
+ At last, positive feedback is always appreciated!
470
+
471
+ h2. License
472
+
473
+ Copyright (c) 2009 Jonas Grimfelt, released under the MIT-license.