pelle-dry_scaffold 0.3.5

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 +50 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.textile +446 -0
  4. data/Rakefile +48 -0
  5. data/TODO.textile +40 -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 +409 -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 +194 -0
  70. data/lib/setup_helper.rb +36 -0
  71. data/rails/init.rb +3 -0
  72. data/tasks/dry_scaffold.rake +95 -0
  73. metadata +129 -0
data/CHANGELOG.textile ADDED
@@ -0,0 +1,50 @@
1
+
2
+ * Added option to skip controller tests. (pelle)
3
+
4
+ h1. 0.3.4 (2009-09-14)
5
+
6
+ * Fixed code generation for RSpec (pelle)
7
+
8
+ h1. 0.3.1 (2009-09-09)
9
+
10
+ * Added Rspec tests generation
11
+
12
+ h1. 0.3.0 (2009-07-23)
13
+
14
+ * Major refactoring of the code.
15
+ * Test/Fixture-stuff re-written from the ground, now tested thoroughly and considered stable - was not before. Plenty sloppy bugs squashed.
16
+ * Added Shoulda tests generation.
17
+
18
+ h1. 0.2.5 (2009-06-12)
19
+
20
+ * Fixed typo: Gem configuration instructions in README.
21
+ * Fixed bug: Re-generated gemspec - missing files. (cjheath)
22
+
23
+ h1. 0.2.4 (2009-05-19)
24
+
25
+ * Fixed bug: Causing generator to fail if test/unit/helpers path don't exist.
26
+
27
+ h1. 0.2.3 (2009-05-12)
28
+
29
+ * Fixed bug: Missing executables in gemspec.
30
+
31
+ h1. 0.2.2 (2009-05-06)
32
+
33
+ * Feature: Specifying actions new+ instead of new, then actions new/create. Same applies to edit+, i.e. edit/update.
34
+ * Feature: For respond_to-formats ATOM/RSS; builders will be generated unless --skip-builders flag is specified
35
+ * Feature: If route is already declared in 'config/routes.rb', then don't generate the route again.
36
+ * Refactor: New template directory structure and naming conventions - more generic. Preparing for optional test frameworks.
37
+ * Refactor: Cleaned up views with generator helpers.
38
+ * Fixed bug: Options for factory_girl vs. machinist got in-versed, i.e. typo.
39
+ * Fixed bug: Options got ignored because of a typo. Grrr....
40
+
41
+ h1. 0.2.1 (2009-05-03)
42
+
43
+ * New feature: Possible to set generator default args in a config file (config/scaffold.yml), or rely on defaults.
44
+ * Fixed issue: Rails default_options don't seem to work at all; replacing it with own solution.
45
+ * Fixed bug: Typo in formats arg parser.
46
+ * Refactor: Gem requires less hardcoded.
47
+
48
+ h1. 0.2.0 (2009-05-01)
49
+
50
+ * 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.
data/MIT-LICENSE ADDED
@@ -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.
data/README.textile ADDED
@@ -0,0 +1,446 @@
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>- form_for(@duck) do |f|
66
+ = f.error_messages
67
+ %ul
68
+ %li
69
+ = f.label :name, 'Name'
70
+ = f.text_field :name
71
+ %li
72
+ = f.label :about, 'About'
73
+ = f.text_area :about
74
+ %p.buttons
75
+ = f.submit 'Create'</pre>
76
+
77
+ h4. Formtastic
78
+
79
+ HAML + Formtastic:
80
+
81
+ <pre>- semantic_form_for(@duck) do |f|
82
+ - f.inputs do
83
+ = f.input :name
84
+ = f.input :about
85
+ - f.buttons do
86
+ = f.commit_button 'Create'</pre>
87
+
88
+ Find out more about *formtastic*: "http://github.com/justinfrench/formtastic":http://github.com/justinfrench/formtastic
89
+
90
+ h3. Resourceful Controllers
91
+
92
+ 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.
93
+
94
+ h4. Standard
95
+
96
+ Using ActionController:
97
+
98
+ <pre>def new
99
+ @duck = Duck.new
100
+
101
+ respond_to do |format|
102
+ format.html # new.html.haml
103
+ format.xml { render :xml => @duck }
104
+ format.json { render :json => @duck }
105
+ end
106
+ end</pre>
107
+
108
+ h4. Resourceful
109
+
110
+ Using InheritedResources:
111
+
112
+ <pre>actions :new
113
+ respond_to :html, :xml, :json</pre>
114
+
115
+ Find out more about *inherited_resources*: "http://github.com/josevalim/inherited_resources":http://github.com/josevalim/inherited_resources
116
+
117
+ h3. Pagination
118
+
119
+ 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.
120
+
121
+ Find out more about *will_paginate*: "http://github.com/mislav/will_paginate":http://github.com/mislav/will_paginate
122
+
123
+ h3. DRYying Patterns
124
+
125
+ 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.
126
+
127
+ h4. Standard
128
+
129
+ ActionController with pagination:
130
+
131
+ <pre>before_filter :load_resource, :only => [:show, :edit, :update, :destroy]
132
+ before_filter :load_and_paginate_resources, :only => [:index]
133
+
134
+ ...
135
+
136
+ protected
137
+
138
+ def collection
139
+ paginate_options ||= {}
140
+ paginate_options[:page] ||= (params[:page] || 1)
141
+ paginate_options[:per_page] ||= (params[:per_page] || 20)
142
+ @collection = @resources ||= Duck.paginate(paginate_options)
143
+ end
144
+ alias :load_and_paginate_resources :collection
145
+
146
+ def resource
147
+ @resource = @resource = ||= Duck.find(params[:id])
148
+ end
149
+ alias :load_resource :resource</pre>
150
+
151
+ h4. Resourceful
152
+
153
+ InheritedResources with pagination:
154
+
155
+ <pre>protected
156
+
157
+ def collection
158
+ paginate_options ||= {}
159
+ paginate_options[:page] ||= (params[:page] || 1)
160
+ paginate_options[:per_page] ||= (params[:per_page] || 20)
161
+ @resources ||= end_of_association_chain.paginate(paginate_options)
162
+ end</pre>
163
+
164
+ h3. View Partials
165
+
166
+ A very common pattern is to break up views in partials, which is also what DryScaffold does:
167
+
168
+ * @new@/@edit@ => @_form@
169
+ * @index@ => @_item@
170
+
171
+ h3. More To Come... (TODO)
172
+
173
+ These are things I have in mind:
174
+
175
+ * Handle belongs_to, i.e. specify MODEL --belongs-to PARENT_MODEL, which generates proper routes, proper before-filters if inherited_resources-controller, adding belongs_to-association in model, and correct form_for arguments.
176
+ * RSpec-support?
177
+
178
+ h2. Setup
179
+
180
+ Installing DryScaffold is easy:
181
+
182
+ h3. 1. Installation
183
+
184
+ Install DryScaffold...
185
+
186
+ h4. Gem (Recommended)
187
+
188
+ <pre>sudo gem install grimen-dry_scaffold --source http://gems.github.com</pre>
189
+
190
+ ...and in config: @config/environments/development.rb@
191
+
192
+ <pre>config.gem 'grimen-dry_scaffold', :lib => false, :source => 'http://gems.github.com'</pre>
193
+
194
+ h4. Plugin
195
+
196
+ <pre>./script/plugin install git://github.com/grimen/dry_scaffold.git</pre>
197
+
198
+ h3. 2. Install Dependencies (Partly optional)
199
+
200
+ Install dependencies to release the full power of dry_scaffold. Only HAML is really required of these, but how could anyone resist candy? =)
201
+
202
+ h4. Automatic/Express
203
+
204
+ For us lazy ones... =)
205
+
206
+ <pre>rake dry_scaffold:setup</pre>
207
+
208
+ 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).
209
+
210
+ h4. Manual
211
+
212
+ Get the gems...you want:
213
+
214
+ <pre>sudo gem install haml
215
+ sudo gem install mislav-will_paginate
216
+ sudo gem install justinfrench-formtastic
217
+ sudo gem install josevalim-inherited_resources</pre>
218
+
219
+ ...and same for the config config: @config/environments/development.rb@
220
+
221
+ <pre>config.gem 'haml'
222
+ config.gem 'will_paginate'
223
+ config.gem 'justinfrench-formtastic', :lib => 'formtastic', :source => 'http://gems.github.com'
224
+ config.gem 'josevalim-inherited_resources', :lib => 'inherited_resources', :source => 'http://gems.github.com'</pre>
225
+
226
+ Also configure @config/environments/test.rb@ with the Rspec library if you want to
227
+
228
+ <pre>config.gem 'rspec'
229
+ config.gem 'rspec-rails'</pre>
230
+
231
+ And don't forget to initialize it as well:
232
+
233
+ <pre>./script/generate rspec</pre>
234
+
235
+ h2. Usage
236
+
237
+ <pre>./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]</pre>
238
+
239
+ ...or use the alias @dscaffold@ instead of @dry_scaffold@.
240
+
241
+ For generating just a *model*, then use:
242
+
243
+ <pre>./script/generate dry_model ModelName [attribute:type attribute:type] [_indexes:attribute,...] [--skip-migration] [--skip-timestamps] [--skip-tests] [--tunit] [--shoulda] [--rspec] [--fixtures] [--fgirl] [--machinist] [--odaddy]</pre>
244
+
245
+ ...or use the alias @dmodel@ instead of @dry_model@.
246
+
247
+ h3. Model Name
248
+
249
+ Example:
250
+
251
+ <pre>Duck</pre>
252
+
253
+ Same as in the default scaffold/model generator; the name of a new/existing model.
254
+
255
+ h3. Model Attributes
256
+
257
+ Example:
258
+
259
+ <pre>name:string about:text ...</pre>
260
+
261
+ Same as in the default scaffold/model generator; model attributes and database migration column types.
262
+
263
+ h3. Controller Actions
264
+
265
+ Example:
266
+
267
+ <pre>_actions:new,create,quack,index,...</pre>
268
+
269
+ You can override what actions that should be generated directly - including custom actions.
270
+
271
+ h4. Default Actions (REST)
272
+
273
+ If no actions are specified, the following REST-actions will be generated by default:
274
+
275
+ * @show@
276
+ * @index@
277
+ * @new@
278
+ * @edit@
279
+ * @create@
280
+ * @update@
281
+ * @destroy@
282
+
283
+ Default controller action stubs, controller action test stubs, and corresponding views (and required partials), are generated for all of these actions.
284
+
285
+ 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:
286
+
287
+ <pre>_actions:quack # => quack</pre>
288
+ <pre>_actions:*,quack # => show,index,new,edit,create,update,destroy,quack</pre>
289
+ <pre>_actions:new+,edit,quack # => new,edit,create,quack</pre>
290
+ <pre>_actions:new+,edit+,quack # => new,edit,create,update,quack</pre>
291
+
292
+ h4. Custom Actions
293
+
294
+ 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.
295
+
296
+ h3. Controller Formats
297
+
298
+ Example:
299
+
300
+ <pre>_formats:html,xml,txt,... # <=> _respond_to:html,xml,txt,...</pre>
301
+
302
+ 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.
303
+
304
+ h4. Default Formats
305
+
306
+ If no formats are specified, the following formats will be generated by default:
307
+
308
+ * @html@ => Template: resource.html.haml
309
+ * @js@ => Template: resource.js.rjs
310
+ * @xml@ => Render: resource.to_xml
311
+ * @json@ => Render: resource.to_json
312
+
313
+ Default respond block stubs are generated for all of these formats - for each generated REST-action.
314
+
315
+ 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:
316
+
317
+ <pre>_formats:iphone # => _formats:iphone</pre>
318
+ <pre>_formats:*,iphone # => _formats:html,js,xml,json,iphone</pre>
319
+
320
+ h4. Additional Formats
321
+
322
+ Also, default respond block stubs are generated for any of these formats - for each generated REST-action - if they are specified:
323
+
324
+ * @atom@ => Template: index.atom.builder
325
+ * @rss@ => Template: index.rss.builder
326
+ * @yaml@/@yml@ => Render: resource.to_yaml
327
+ * @txt@/@text@ => Render: resource.to_s
328
+
329
+ NOTE: Only for Non-InheritedResources controllers for now.
330
+
331
+ For the feed formats @atom@ and @rss@, builders are automatically generated if @index@-action is specified. Example:
332
+
333
+ @app/views/ducks/index.atom.builder@
334
+
335
+ <pre>
336
+ atom_feed(:language => I18n.locale) do |feed|
337
+ feed.title 'Resources'
338
+ feed.subtitle 'Index of all resources.'
339
+ feed.updated (@resources.first.created_at rescue Time.now.utc).strftime('%Y-%m-%dT%H:%M:%SZ'))
340
+
341
+ @resources.each do |resource|
342
+ feed.entry(resource) do |entry|
343
+ entry.title 'title'
344
+ entry.summary 'summary'
345
+
346
+ resource.author do |author|
347
+ author.name 'author_name'
348
+ end
349
+ end
350
+ end
351
+ end
352
+ </pre>
353
+
354
+ Builder generation can be skipped by specifying the @--skip-builders@ flag.
355
+
356
+ h4. Custom Formats
357
+
358
+ 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.
359
+
360
+ h3. Model Indexes
361
+
362
+ Example:
363
+
364
+ If model attributes are specified as:
365
+
366
+ <pre>name:string owner:reference</pre>
367
+
368
+ ...then we could do this (for polymorphic association):
369
+
370
+ <pre>_indexes:owner_id # => (In migration:) add_index :duck, :owner_id</pre>
371
+
372
+ ...or in account for a polymorphic association:
373
+
374
+ <pre>_indexes:owner_id+owner_type # => (In migration:) add_index :duck, [:owner_id, :owner_type]</pre>
375
+
376
+ 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.
377
+
378
+ h3. Options/Flags
379
+
380
+ Example:
381
+
382
+ <pre>--skip-resourceful --layout</pre>
383
+
384
+ h4. Scaffold
385
+
386
+ These are the options for the scaffold-generator.
387
+
388
+ * @--skip-pagination@ - Don't generate pagination of collections in controller and views, i.e. don't use *will_paginate*.
389
+ * @--skip-resourceful@ - Don't generate resourceful controller, i.e. don't use *inherited_resources*.
390
+ * @--skip-formtastic@ - Don't generate formtastic forms in views, i.e. don't use *formtastic*.
391
+ * @--skip-views@ - Don't generate views.
392
+ * @--skip-helpers@ - Don't generate helpers.
393
+ * @--skip-builders@ - Don't generate builders.
394
+ * @--skip-controller-tests@ - Don't generate controller tests
395
+ * @--layout@ - Generate layout.
396
+
397
+ h4. Model
398
+
399
+ These are the options for the model/scaffold-generators.
400
+
401
+ * @--skip-timestamps@ - Don't add timestamps to the migration file.
402
+ * @--skip-migration@ - Skip generation of migration file.
403
+
404
+ h4. All
405
+
406
+ * @--skip-tests@ - Don't generate tests (functional/unit/...).
407
+ * @--tunit@ - Generate/Use test_unit tests. Note: Rails default.
408
+ * @--shoulda@ - Generate/Use *shoulda* tests.
409
+ * @--rspec@ - Generate/Use *rspec* tests.
410
+ * @--fixtures@ - Generate/Use fixtures. Note: Rails default.
411
+ * @--fgirl@ - Generate/Use *factory_girl* factories.
412
+ * @--machinist@ - Generate/Use *machinist* blueprints (factories).
413
+ * @--odaddy@ - Generate/Use *object_daddy* generator/factory methods.
414
+
415
+ As DryScaffold is built upon Rails generator, the default generator options is available as well. For more details; see Rails documentation.
416
+
417
+ h3. Setting Defaults
418
+
419
+ You can set defaults for the generator args/options in @config/scaffold.yml@. To generate this file, simply do:
420
+
421
+ <pre>rake dry_scaffold:config:generate</pre>
422
+
423
+ h2. Examples
424
+
425
+ No need for more samples here, just create a new Rails project, install DryScaffold and it's dependencies, and try it out!
426
+
427
+ For your inspiration, you could try the following:
428
+
429
+ <pre>./script/generate dry_scaffold Zebra name:string about:text --skip-resourceful
430
+ ./script/generate dscaffold Kangaroo name:string about:text --skip-formtastic
431
+ ./script/generate dscaffold Duck name:string about:text _actions:new,create,index,quack
432
+ ./script/generate dscaffold Parrot name:string about:text _formats:html,xml,yml
433
+ ./script/generate dmodel GoldFish name:string about:text _indexes:name --fgirl
434
+ ./script/generate dmodel Frog name:string about:text _indexes:name,name+about --fixtures</pre>
435
+
436
+ ...or just go crazy!
437
+
438
+ h2. Bugs & Feedback
439
+
440
+ If you experience any issues/bugs or have feature requests, just file a GitHub-issue or send me a message.
441
+ If you think parts of my implementation could be implemented nicer somehow, please let me know...or just fork it and fix it yourself! =)
442
+ At last, positive feedback is always appreciated!
443
+
444
+ h2. License
445
+
446
+ Copyright (c) 2009 Jonas Grimfelt, released under the MIT-license.