grimen-dry_scaffold 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.textile +38 -8
- data/TODO.textile +4 -3
- data/generators/dry_model/dry_model_generator.rb +23 -16
- data/generators/dry_model/prototypes/active_record_migration.rb +17 -0
- data/generators/dry_model/prototypes/active_record_model.rb +9 -0
- data/generators/dry_model/prototypes/test_data/active_record_fixtures.yml +3 -0
- data/generators/dry_model/prototypes/test_data/factory_girl_factories.rb +4 -0
- data/generators/dry_model/prototypes/test_data/machinist_factories.rb +8 -0
- data/generators/dry_model/prototypes/tests/test_unit/unit_test.rb +9 -0
- data/generators/dry_model/templates/{migration_standard.rb → models/active_record_migration.rb} +0 -0
- data/generators/dry_model/templates/{model_standard.rb → models/active_record_model.rb} +0 -0
- data/generators/dry_model/templates/{fixtures_standard.yml → models/test_data/active_record_fixtures.yml} +0 -0
- data/generators/dry_model/templates/{factories_factory_girl.rb → models/test_data/factory_girl_factories.rb} +0 -0
- data/generators/dry_model/templates/{factories_machinist.rb → models/test_data/machinist_factories.rb} +0 -0
- data/generators/dry_model/templates/{unit_test_standard.rb → models/tests/test_unit/unit_test.rb} +0 -0
- data/generators/dry_scaffold/dry_scaffold_generator.rb +137 -31
- data/generators/dry_scaffold/{templates/prototypes/controller_standard.rb → prototypes/controllers/action_controller.rb} +2 -0
- data/generators/dry_scaffold/{templates/prototypes/controller_inherited_resources.rb → prototypes/controllers/inherited_resources_controller.rb} +1 -0
- data/generators/dry_scaffold/{templates/prototypes/controller_test_standard.rb → prototypes/controllers/tests/unit_test/functional_test.rb} +1 -1
- data/generators/dry_scaffold/{templates/prototypes/helper_standard.rb → prototypes/helpers/helper.rb} +0 -0
- data/generators/dry_scaffold/{templates/prototypes/helper_test_standard.rb → prototypes/helpers/tests/test_unit/unit_test.rb} +0 -0
- data/generators/dry_scaffold/prototypes/views/builder/index.atom.builder +20 -0
- data/generators/dry_scaffold/prototypes/views/builder/index.rss.builder +21 -0
- data/generators/dry_scaffold/{templates/prototypes/view__form.html.haml → prototypes/views/haml/_form.html.haml} +0 -0
- data/generators/dry_scaffold/{templates/prototypes/view__item.html.haml → prototypes/views/haml/_item.html.haml} +0 -0
- data/generators/dry_scaffold/{templates/prototypes/view_edit.html.haml → prototypes/views/haml/edit.html.haml} +0 -0
- data/generators/dry_scaffold/{templates/prototypes/view_index.html.haml → prototypes/views/haml/index.html.haml} +0 -0
- data/generators/dry_scaffold/{templates/prototypes → prototypes/views/haml}/layout.html.haml +0 -0
- data/generators/dry_scaffold/{templates/prototypes/view_new.html.haml → prototypes/views/haml/new.html.haml} +0 -0
- data/generators/dry_scaffold/{templates/prototypes/view_show.html.haml → prototypes/views/haml/show.html.haml} +0 -0
- data/generators/dry_scaffold/templates/{controller_standard.rb → controllers/action_controller.rb} +27 -21
- data/generators/dry_scaffold/templates/{controller_inherited_resources.rb → controllers/inherited_resources_controller.rb} +3 -2
- data/generators/dry_scaffold/templates/{functional_test_standard.rb → controllers/tests/test_unit/functional_test.rb} +1 -1
- data/generators/dry_scaffold/templates/{helper_standard.rb → helpers/helper.rb} +0 -0
- data/generators/dry_scaffold/templates/{helper_test_standard.rb → helpers/tests/test_unit/unit_test.rb} +0 -0
- data/generators/dry_scaffold/templates/views/builder/index.atom.builder +20 -0
- data/generators/dry_scaffold/templates/views/builder/index.rss.builder +21 -0
- data/generators/dry_scaffold/templates/{view__form.html.haml → views/haml/_form.html.haml} +0 -0
- data/generators/dry_scaffold/templates/{view__item.html.haml → views/haml/_item.html.haml} +3 -3
- data/generators/dry_scaffold/templates/{view_edit.html.haml → views/haml/edit.html.haml} +4 -4
- data/generators/dry_scaffold/templates/{view_index.html.haml → views/haml/index.html.haml} +3 -3
- data/generators/dry_scaffold/templates/{view_layout.html.haml → views/haml/layout.html.haml} +0 -0
- data/generators/dry_scaffold/templates/{view_new.html.haml → views/haml/new.html.haml} +3 -3
- data/generators/dry_scaffold/templates/views/haml/show.html.haml +13 -0
- metadata +42 -32
- data/generators/dry_scaffold/templates/view_show.html.haml +0 -13
data/README.textile
CHANGED
@@ -268,10 +268,12 @@ If no actions are specified, the following REST-actions will be generated by def
|
|
268
268
|
|
269
269
|
Default controller action stubs, controller action test stubs, and corresponding views (and required partials), are generated for all of these actions.
|
270
270
|
|
271
|
-
These default actions can also be included using the
|
271
|
+
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:
|
272
272
|
|
273
|
-
<pre>_actions:quack
|
274
|
-
<pre>_actions:*,quack
|
273
|
+
<pre>_actions:quack # => quack</pre>
|
274
|
+
<pre>_actions:*,quack # => show,index,new,edit,create,update,destroy,quack</pre>
|
275
|
+
<pre>_actions:new+,edit,quack # => new,edit,create,quack</pre>
|
276
|
+
<pre>_actions:new+,edit+,quack # => new,edit,create,update,quack</pre>
|
275
277
|
|
276
278
|
h4. Custom Actions
|
277
279
|
|
@@ -291,8 +293,8 @@ h4. Default Formats
|
|
291
293
|
|
292
294
|
If no formats are specified, the following formats will be generated by default:
|
293
295
|
|
294
|
-
* @html@ =>
|
295
|
-
* @js@ =>
|
296
|
+
* @html@ => Template: resource.html.haml
|
297
|
+
* @js@ => Template: resource.js.rjs
|
296
298
|
* @xml@ => Render: resource.to_xml
|
297
299
|
* @json@ => Render: resource.to_json
|
298
300
|
|
@@ -307,10 +309,37 @@ h4. Additional Formats
|
|
307
309
|
|
308
310
|
Also, default respond block stubs are generated for any of these formats - for each generated REST-action - if they are specified:
|
309
311
|
|
310
|
-
* @
|
311
|
-
* @
|
312
|
+
* @atom@ => Template: index.atom.builder
|
313
|
+
* @rss@ => Template: index.rss.builder
|
314
|
+
* @yaml@/@yml@ => Render: resource.to_yaml
|
315
|
+
* @txt@/@text@ => Render: resource.to_s
|
316
|
+
|
317
|
+
NOTE: Only for Non-InheritedResources controllers for now.
|
318
|
+
|
319
|
+
For the feed formats @atom@ and @rss@, builders are automatically generated if @index@-action is specified. Example:
|
320
|
+
|
321
|
+
@app/views/ducks/index.atom.builder@
|
322
|
+
|
323
|
+
<pre>
|
324
|
+
atom_feed(:language => I18n.locale) do |feed|
|
325
|
+
feed.title 'Resources'
|
326
|
+
feed.subtitle 'Index of all resources.'
|
327
|
+
feed.updated (@resources.first.created_at rescue Time.now.utc).strftime('%Y-%m-%dT%H:%M:%SZ'))
|
328
|
+
|
329
|
+
@resources.each do |resource|
|
330
|
+
feed.entry(resource) do |entry|
|
331
|
+
entry.title 'title'
|
332
|
+
entry.summary 'summary'
|
333
|
+
|
334
|
+
resource.author do |author|
|
335
|
+
author.name 'author_name'
|
336
|
+
end
|
337
|
+
end
|
338
|
+
end
|
339
|
+
end
|
340
|
+
</pre>
|
312
341
|
|
313
|
-
|
342
|
+
Builder generation can be skipped by specifying the @--skip-builders@ flag.
|
314
343
|
|
315
344
|
h4. Custom Formats
|
316
345
|
|
@@ -348,6 +377,7 @@ h4. General
|
|
348
377
|
* @--skip-views@ - Don't generate views.
|
349
378
|
* @--skip-helpers@ - Don't generate helpers.
|
350
379
|
* @--skip-tests@ - Don't generate tests (functional/unit/...).
|
380
|
+
* @--skip-builders@ - Don't generate builders.
|
351
381
|
* @--layout@ - Generate layout.
|
352
382
|
|
353
383
|
h4. Model-specific
|
data/TODO.textile
CHANGED
@@ -2,11 +2,12 @@ h1. TODO
|
|
2
2
|
|
3
3
|
h2. Next
|
4
4
|
|
5
|
-
* Feature:
|
6
|
-
*
|
5
|
+
* Feature: 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.
|
6
|
+
* Choose test suits: testunit/shoulda/rspec
|
7
7
|
|
8
8
|
h2. Maybe later
|
9
9
|
|
10
10
|
* Clean-up: Comment the code a bit more =)
|
11
11
|
* Refactor: Break up in different generators: dry_controller, dry_views, etc., and use as dependencies in dry_scaffold?
|
12
|
-
* Feature: Check for overridden templates in: RAILS_ROOT/lib/dry_scaffold/templates/
|
12
|
+
* Feature: Check for overridden templates in: RAILS_ROOT/lib/dry_scaffold/templates/
|
13
|
+
* Feature: Builder for podcast-feed, similar to RSS/Atom-builders.
|
@@ -5,7 +5,7 @@ require 'rubygems'
|
|
5
5
|
rescue MissingSourceFile
|
6
6
|
eval("#{lib.upcase} = #{false}")
|
7
7
|
else
|
8
|
-
eval("#{lib.upcase} = #{
|
8
|
+
eval("#{lib.upcase} = #{true}")
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
@@ -24,12 +24,14 @@ class DryModelGenerator < Rails::Generator::NamedBase
|
|
24
24
|
:fixtures => CONFIG_OPTIONS['fixtures'] || false,
|
25
25
|
:factory_girl => CONFIG_OPTIONS['factory_girl'] || false,
|
26
26
|
:machinist => CONFIG_OPTIONS['machinist'] || false,
|
27
|
-
:object_daddy =>
|
28
|
-
:skip_timestamps => !CONFIG_OPTIONS['
|
29
|
-
:skip_migration => !CONFIG_OPTIONS['
|
30
|
-
:skip_tests => CONFIG_OPTIONS['
|
27
|
+
:object_daddy => CONFIG_OPTIONS['object_daddy'] || false,
|
28
|
+
:skip_timestamps => !CONFIG_OPTIONS['timestamps'] || false,
|
29
|
+
:skip_migration => !CONFIG_OPTIONS['migration'] || false,
|
30
|
+
:skip_tests => !CONFIG_OPTIONS['tests'] || false
|
31
31
|
}
|
32
32
|
|
33
|
+
DEFAULT_TEST_FRAMEWORK = :test_unit
|
34
|
+
|
33
35
|
MODELS_PATH = File.join('app', 'models').freeze
|
34
36
|
MIGRATIONS_PATH = File.join('db', 'migrate').freeze
|
35
37
|
TESTS_PATH = File.join('test').freeze
|
@@ -41,11 +43,14 @@ class DryModelGenerator < Rails::Generator::NamedBase
|
|
41
43
|
NON_ATTR_ARG_KEY_PREFIX = '_'.freeze
|
42
44
|
|
43
45
|
attr_reader :indexes,
|
44
|
-
:references
|
46
|
+
:references,
|
47
|
+
:test_framework
|
45
48
|
|
46
49
|
def initialize(runtime_args, runtime_options = {})
|
47
50
|
super
|
48
51
|
|
52
|
+
@test_framework = DEFAULT_TEST_FRAMEWORK
|
53
|
+
|
49
54
|
@attributes ||= []
|
50
55
|
args_for_model = []
|
51
56
|
|
@@ -70,13 +75,12 @@ class DryModelGenerator < Rails::Generator::NamedBase
|
|
70
75
|
|
71
76
|
@args = args_for_model
|
72
77
|
@references = attributes.select(&:reference?)
|
73
|
-
@options = DEFAULT_OPTIONS.merge(
|
78
|
+
@options = DEFAULT_OPTIONS.merge(options)
|
74
79
|
end
|
75
80
|
|
76
81
|
def manifest
|
77
82
|
record do |m|
|
78
83
|
# Check for class naming collisions.
|
79
|
-
m.class_collisions class_name, "#{class_name}"
|
80
84
|
m.class_collisions class_name, "#{class_name}Test"
|
81
85
|
|
82
86
|
# Directories.
|
@@ -86,31 +90,34 @@ class DryModelGenerator < Rails::Generator::NamedBase
|
|
86
90
|
m.directory File.join(FACTORY_GIRL_FACTORIES_PATH, class_path) if options[:factory_girl]
|
87
91
|
m.directory File.join(MACHINIST_FACTORIES_PATH, class_path) if options[:machinist]
|
88
92
|
|
89
|
-
# Model
|
90
|
-
m.template
|
93
|
+
# Model
|
94
|
+
m.template File.join('models', 'active_record_model.rb'),
|
95
|
+
File.join(MODELS_PATH, class_path, "#{file_name}.rb")
|
96
|
+
|
97
|
+
# Model Tests.
|
91
98
|
unless options[:skip_tests]
|
92
|
-
|
93
|
-
|
99
|
+
m.template File.join('models', 'tests', "#{test_framework}", 'unit_test.rb'),
|
100
|
+
File.join(UNIT_TESTS_PATH, class_path, "#{file_name}_test.rb")
|
94
101
|
end
|
95
102
|
|
96
103
|
# Fixtures/Factories.
|
97
104
|
if options[:fixtures]
|
98
|
-
m.template '
|
105
|
+
m.template File.join('models', 'test_data', 'active_record_fixtures.yml'),
|
99
106
|
File.join(FIXTURES_PATH, "#{file_name}.yml")
|
100
107
|
end
|
101
108
|
if options[:factory_girl]
|
102
|
-
m.template '
|
109
|
+
m.template File.join('models', 'test_data', 'factory_girl_factories.rb'),
|
103
110
|
File.join(FACTORY_GIRL_FACTORIES_PATH, "#{file_name}.rb")
|
104
111
|
end
|
105
112
|
if options[:machinist]
|
106
|
-
m.template '
|
113
|
+
m.template File.join('models', 'test_data', 'machinist_factories.rb'),
|
107
114
|
File.join(MACHINIST_FACTORIES_PATH, "#{file_name}.rb")
|
108
115
|
end
|
109
116
|
# NOTE: :object_daddy handled in model
|
110
117
|
|
111
118
|
# Migration.
|
112
119
|
unless options[:skip_migration]
|
113
|
-
m.migration_template '
|
120
|
+
m.migration_template File.join('models', 'active_record_migration.rb') , MIGRATIONS_PATH,
|
114
121
|
:assigns => {:migration_name => "Create#{class_name.pluralize.gsub(/::/, '')}"},
|
115
122
|
:migration_file_name => "create_#{file_path.gsub(/\//, '_').pluralize}"
|
116
123
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class CreateResources < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :resources, :force => true do |t|
|
4
|
+
t.string :name
|
5
|
+
t.text :description
|
6
|
+
|
7
|
+
t.timestamps
|
8
|
+
end
|
9
|
+
|
10
|
+
add_index :resources, :name
|
11
|
+
add_index :resources, [:name, :description]
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.down
|
15
|
+
drop_table :resources
|
16
|
+
end
|
17
|
+
end
|
data/generators/dry_model/templates/{migration_standard.rb → models/active_record_migration.rb}
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/generators/dry_model/templates/{unit_test_standard.rb → models/tests/test_unit/unit_test.rb}
RENAMED
File without changes
|
@@ -5,7 +5,7 @@ require 'rubygems'
|
|
5
5
|
rescue MissingSourceFile
|
6
6
|
eval("#{lib.upcase} = #{false}")
|
7
7
|
else
|
8
|
-
eval("#{lib.upcase} = #{
|
8
|
+
eval("#{lib.upcase} = #{true}")
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
@@ -25,6 +25,7 @@ class DryScaffoldGenerator < Rails::Generator::NamedBase
|
|
25
25
|
:actions => (CONFIG_ARGS['actions'].split(',').compact.uniq.collect { |v| v.downcase.to_sym } rescue nil),
|
26
26
|
:formats => (CONFIG_ARGS['formats'].split(',').compact.uniq.collect { |v| v.downcase.to_sym } rescue nil)
|
27
27
|
}
|
28
|
+
|
28
29
|
DEFAULT_OPTIONS = {
|
29
30
|
:resourceful => CONFIG_OPTIONS['resourceful'] || INHERITED_RESOURCES,
|
30
31
|
:formtastic => CONFIG_OPTIONS['formtastic'] || FORMTASTIC,
|
@@ -32,10 +33,15 @@ class DryScaffoldGenerator < Rails::Generator::NamedBase
|
|
32
33
|
:skip_tests => !CONFIG_OPTIONS['tests'] || false,
|
33
34
|
:skip_helpers => !CONFIG_OPTIONS['helpers'] || false,
|
34
35
|
:skip_views => !CONFIG_OPTIONS['views'] || false,
|
35
|
-
:
|
36
|
+
:layout => CONFIG_OPTIONS['layout'] || false
|
36
37
|
}
|
37
38
|
|
39
|
+
# Formats.
|
38
40
|
DEFAULT_RESPOND_TO_FORMATS = [:html, :xml, :json].freeze
|
41
|
+
ENHANCED_RESPOND_TO_FORMATS = [:yml, :yaml, :txt, :text, :atom, :rss].freeze
|
42
|
+
RESPOND_TO_FEED_FORMATS = [:atom, :rss].freeze
|
43
|
+
|
44
|
+
# Actions.
|
39
45
|
DEFAULT_MEMBER_ACTIONS = [:show, :new, :edit, :create, :update, :destroy].freeze
|
40
46
|
DEFAULT_MEMBER_AUTOLOAD_ACTIONS = (DEFAULT_MEMBER_ACTIONS - [:new, :create])
|
41
47
|
DEFAULT_COLLECTION_ACTIONS = [:index].freeze
|
@@ -43,6 +49,7 @@ class DryScaffoldGenerator < Rails::Generator::NamedBase
|
|
43
49
|
DEFAULT_CONTROLLER_ACTIONS = (DEFAULT_COLLECTION_ACTIONS + DEFAULT_MEMBER_ACTIONS)
|
44
50
|
|
45
51
|
DEFAULT_VIEW_TEMPLATE_FORMAT = :haml
|
52
|
+
DEFAULT_TEST_FRAMEWORK = :test_unit
|
46
53
|
|
47
54
|
CONTROLLERS_PATH = File.join('app', 'controllers').freeze
|
48
55
|
HELPERS_PATH = File.join('app', 'helpers').freeze
|
@@ -50,7 +57,8 @@ class DryScaffoldGenerator < Rails::Generator::NamedBase
|
|
50
57
|
LAYOUTS_PATH = File.join(VIEWS_PATH, 'layouts').freeze
|
51
58
|
MODELS_PATH = File.join('app', 'models').freeze
|
52
59
|
FUNCTIONAL_TESTS_PATH = File.join('test', 'functional').freeze
|
53
|
-
UNIT_TESTS_PATH = File.join('test', 'unit'
|
60
|
+
UNIT_TESTS_PATH = File.join('test', 'unit').freeze
|
61
|
+
ROUTES_FILE_PATH = File.join(Rails.root, 'config', 'routes.rb').freeze
|
54
62
|
|
55
63
|
RESOURCEFUL_COLLECTION_NAME = 'collection'.freeze
|
56
64
|
RESOURCEFUL_SINGULAR_NAME = 'resource'.freeze
|
@@ -58,13 +66,17 @@ class DryScaffoldGenerator < Rails::Generator::NamedBase
|
|
58
66
|
NON_ATTR_ARG_KEY_PREFIX = '_'.freeze
|
59
67
|
|
60
68
|
# :{action} => [:{partial}, ...]
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
69
|
+
ACTION_VIEW_TEMPLATES = {
|
70
|
+
:index => [:item],
|
71
|
+
:show => [],
|
72
|
+
:new => [:form],
|
73
|
+
:edit => [:form]
|
74
|
+
}.freeze
|
67
75
|
|
76
|
+
ACTION_FORMAT_BUILDERS = {
|
77
|
+
:index => [:atom, :rss]
|
78
|
+
}
|
79
|
+
|
68
80
|
attr_reader :controller_name,
|
69
81
|
:controller_class_path,
|
70
82
|
:controller_file_path,
|
@@ -78,6 +90,7 @@ class DryScaffoldGenerator < Rails::Generator::NamedBase
|
|
78
90
|
:model_singular_name,
|
79
91
|
:model_plural_name,
|
80
92
|
:view_template_format,
|
93
|
+
:test_framework,
|
81
94
|
:actions,
|
82
95
|
:formats,
|
83
96
|
:config
|
@@ -100,6 +113,7 @@ class DryScaffoldGenerator < Rails::Generator::NamedBase
|
|
100
113
|
end
|
101
114
|
|
102
115
|
@view_template_format = DEFAULT_VIEW_TEMPLATE_FORMAT
|
116
|
+
@test_framework = DEFAULT_TEST_FRAMEWORK
|
103
117
|
|
104
118
|
@attributes ||= []
|
105
119
|
@args_for_model ||= []
|
@@ -109,13 +123,17 @@ class DryScaffoldGenerator < Rails::Generator::NamedBase
|
|
109
123
|
arg_entities = arg.split(':')
|
110
124
|
if arg =~ /^#{NON_ATTR_ARG_KEY_PREFIX}/
|
111
125
|
if arg =~ /^#{NON_ATTR_ARG_KEY_PREFIX}action/
|
112
|
-
# Replace
|
126
|
+
# Replace quantifiers with default actions
|
113
127
|
arg_entities[1].gsub!(/\*/, DEFAULT_CONTROLLER_ACTIONS.join(','))
|
128
|
+
arg_entities[1].gsub!(/new\+/, [:new, :create].join(','))
|
129
|
+
arg_entities[1].gsub!(/edit\+/, [:edit, :update].join(','))
|
130
|
+
|
114
131
|
arg_actions = arg_entities[1].split(',').compact.uniq
|
115
132
|
@actions = arg_actions.collect { |action| action.downcase.to_sym }
|
116
133
|
elsif arg =~ /^#{NON_ATTR_ARG_KEY_PREFIX}(format|respond_to)/
|
117
|
-
# Replace
|
134
|
+
# Replace quantifiers with default respond_to-formats
|
118
135
|
arg_entities[1].gsub!(/\*/, DEFAULT_RESPOND_TO_FORMATS.join(','))
|
136
|
+
|
119
137
|
arg_formats = arg_entities[1].split(',').compact.uniq
|
120
138
|
@formats = arg_formats.collect { |format| format.downcase.to_sym }
|
121
139
|
elsif arg =~ /^#{NON_ATTR_ARG_KEY_PREFIX}index/
|
@@ -129,7 +147,7 @@ class DryScaffoldGenerator < Rails::Generator::NamedBase
|
|
129
147
|
|
130
148
|
@actions ||= DEFAULT_ARGS[:actions] || DEFAULT_CONTROLLER_ACTIONS
|
131
149
|
@formats ||= DEFAULT_ARGS[:formats] || DEFAULT_RESPOND_TO_FORMATS
|
132
|
-
@options = DEFAULT_OPTIONS.merge(
|
150
|
+
@options = DEFAULT_OPTIONS.merge(options)
|
133
151
|
end
|
134
152
|
|
135
153
|
def manifest
|
@@ -137,7 +155,6 @@ class DryScaffoldGenerator < Rails::Generator::NamedBase
|
|
137
155
|
# Check for class naming collisions.
|
138
156
|
m.class_collisions "#{controller_class_name}Controller", "#{controller_class_name}ControllerTest"
|
139
157
|
m.class_collisions "#{controller_class_name}Helper", "#{controller_class_name}HelperTest"
|
140
|
-
m.class_collisions "#{class_path}", "#{class_name}"
|
141
158
|
|
142
159
|
# Directories.
|
143
160
|
m.directory File.join(CONTROLLERS_PATH, controller_class_path)
|
@@ -147,56 +164,140 @@ class DryScaffoldGenerator < Rails::Generator::NamedBase
|
|
147
164
|
m.directory File.join(UNIT_TESTS_PATH, controller_class_path) unless options[:skip_tests]
|
148
165
|
|
149
166
|
# Controllers.
|
150
|
-
controller_template = options[:resourceful] ? 'inherited_resources' : '
|
151
|
-
m.template "
|
167
|
+
controller_template = options[:resourceful] ? 'inherited_resources' : 'action'
|
168
|
+
m.template File.join('controllers', "#{controller_template}_controller.rb"),
|
152
169
|
File.join(CONTROLLERS_PATH, controller_class_path, "#{controller_file_name}_controller.rb")
|
153
170
|
|
154
171
|
# Controller Tests.
|
155
172
|
unless options[:skip_tests]
|
156
|
-
m.template '
|
173
|
+
m.template File.join('controllers', 'tests',"#{test_framework}", 'functional_test.rb'),
|
157
174
|
File.join(FUNCTIONAL_TESTS_PATH, controller_class_path, "#{controller_file_name}_controller_test.rb")
|
158
175
|
end
|
159
176
|
|
160
177
|
# Helpers.
|
161
178
|
unless options[:skip_helpers]
|
162
|
-
m.template '
|
179
|
+
m.template File.join('helpers', 'helper.rb'),
|
163
180
|
File.join(HELPERS_PATH, controller_class_path, "#{controller_file_name}_helper.rb")
|
181
|
+
|
164
182
|
# Helper Tests
|
165
183
|
unless options[:skip_tests]
|
166
|
-
m.template '
|
167
|
-
File.join(UNIT_TESTS_PATH, controller_class_path, "#{controller_file_name}_helper_test.rb")
|
184
|
+
m.template File.join('helpers', 'tests', "#{test_framework}", 'unit_test.rb'),
|
185
|
+
File.join(UNIT_TESTS_PATH, 'helpers', controller_class_path, "#{controller_file_name}_helper_test.rb")
|
168
186
|
end
|
169
187
|
end
|
170
188
|
|
171
189
|
# Views.
|
172
190
|
unless options[:skip_views]
|
173
191
|
# View template for each action.
|
174
|
-
(actions &
|
175
|
-
m.template "
|
192
|
+
(actions & ACTION_VIEW_TEMPLATES.keys).each do |action|
|
193
|
+
m.template File.join('views', "#{view_template_format}", "#{action}.html.#{view_template_format}"),
|
194
|
+
File.join(VIEWS_PATH, controller_file_name, "#{action}.html.#{view_template_format}")
|
195
|
+
|
176
196
|
# View template for each partial - if not already copied.
|
177
|
-
(
|
178
|
-
m.template "
|
197
|
+
(ACTION_VIEW_TEMPLATES[action] || []).each do |partial|
|
198
|
+
m.template File.join('views', "#{view_template_format}", "_#{partial}.html.#{view_template_format}"),
|
179
199
|
File.join(VIEWS_PATH, controller_file_name, "_#{partial}.html.#{view_template_format}")
|
180
200
|
end
|
181
201
|
end
|
182
202
|
end
|
183
203
|
|
204
|
+
# Builders.
|
205
|
+
unless options[:skip_builders]
|
206
|
+
(actions & ACTION_FORMAT_BUILDERS.keys).each do |action|
|
207
|
+
(formats & ACTION_FORMAT_BUILDERS[action] || []).each do |format|
|
208
|
+
m.template File.join('views', 'builder', "#{action}.#{format}.builder"),
|
209
|
+
File.join(VIEWS_PATH, controller_file_name, "#{action}.#{format}.builder")
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
184
214
|
# Layout.
|
185
|
-
if options[:
|
186
|
-
m.template "
|
215
|
+
if options[:layout]
|
216
|
+
m.template File.join('views', "#{view_template_format}", "layout.html.#{view_template_format}"),
|
187
217
|
File.join(LAYOUTS_PATH, "#{controller_file_name}.html.#{view_template_format}")
|
188
218
|
end
|
189
219
|
|
190
220
|
# Routes.
|
191
|
-
|
221
|
+
unless resource_route_exists?
|
222
|
+
m.route_resources controller_file_name
|
223
|
+
end
|
192
224
|
|
193
225
|
# Models - use Rails default generator.
|
194
|
-
m.dependency 'dry_model', [name] + @args_for_model, :collision => :skip
|
226
|
+
m.dependency 'dry_model', [name] + @args_for_model, options.merge(:collision => :skip)
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
def collection_instance
|
231
|
+
"@#{collection_name}"
|
232
|
+
end
|
233
|
+
|
234
|
+
def resource_instance
|
235
|
+
"@#{singular_name}"
|
236
|
+
end
|
237
|
+
|
238
|
+
def index_link
|
239
|
+
"#{collection_name}_url"
|
240
|
+
end
|
241
|
+
|
242
|
+
def new_link
|
243
|
+
"new_#{singular_name}_url"
|
244
|
+
end
|
245
|
+
|
246
|
+
def show_link(object_name = resource_instance)
|
247
|
+
"#{singular_name}_url(#{object_name})"
|
248
|
+
end
|
249
|
+
|
250
|
+
def edit_link(object_name = resource_instance)
|
251
|
+
"edit_#{show_link(object_name)}"
|
252
|
+
end
|
253
|
+
|
254
|
+
def destroy_link(object_name = resource_instance)
|
255
|
+
"#{object_name}"
|
256
|
+
end
|
257
|
+
|
258
|
+
def feed_link(format)
|
259
|
+
case format
|
260
|
+
when :atom then
|
261
|
+
":href => #{plural_name}_url(:#{format}), :rel => 'self'"
|
262
|
+
when :rss then
|
263
|
+
"#{plural_name}_url(#{singular_name}, :#{format})"
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
def feed_entry_link(format)
|
268
|
+
case format
|
269
|
+
when :atom then
|
270
|
+
":href => #{singular_name}_url(#{singular_name}, :#{format})"
|
271
|
+
when :rss then
|
272
|
+
"#{singular_name}_url(#{singular_name}, :#{format})"
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
def feed_date(format)
|
277
|
+
case format
|
278
|
+
when :atom then
|
279
|
+
"(#{collection_instance}.first.created_at rescue Time.now.utc).strftime('%Y-%m-%dT%H:%M:%SZ')"
|
280
|
+
when :rss then
|
281
|
+
"(#{collection_instance}.first.created_at rescue Time.now.utc).to_s(:rfc822)"
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
def feed_entry_date(format)
|
286
|
+
case format
|
287
|
+
when :atom then
|
288
|
+
"#{singular_name}.try(:updated_at).strftime('%Y-%m-%dT%H:%M:%SZ')"
|
289
|
+
when :rss then
|
290
|
+
"#{singular_name}.try(:updated_at).to_s(:rfc822)"
|
195
291
|
end
|
196
292
|
end
|
197
293
|
|
198
294
|
protected
|
199
295
|
|
296
|
+
def resource_route_exists?
|
297
|
+
route_exp = "map.resources :#{controller_file_name}"
|
298
|
+
File.read(ROUTES_FILE_PATH) =~ /(#{route_exp.strip}|#{route_exp.strip.tr('\'', '\"')})/
|
299
|
+
end
|
300
|
+
|
200
301
|
def symbol_array_to_expression(array)
|
201
302
|
":#{array.compact.join(', :')}" if array.present?
|
202
303
|
end
|
@@ -232,7 +333,7 @@ class DryScaffoldGenerator < Rails::Generator::NamedBase
|
|
232
333
|
end
|
233
334
|
|
234
335
|
opt.on('--layout', "Generate layout.") do |v|
|
235
|
-
options[:
|
336
|
+
options[:layout] = v
|
236
337
|
end
|
237
338
|
|
238
339
|
opt.on('--skip-views', "Skip generation of views.") do |v|
|
@@ -243,6 +344,10 @@ class DryScaffoldGenerator < Rails::Generator::NamedBase
|
|
243
344
|
options[:skip_helpers] = v
|
244
345
|
end
|
245
346
|
|
347
|
+
opt.on('--skip-builders', "Skip generation of helpers.") do |v|
|
348
|
+
options[:skip_builders] = v
|
349
|
+
end
|
350
|
+
|
246
351
|
### CONTROLLERS + MODELS
|
247
352
|
|
248
353
|
opt.on('--skip-tests', "Skip generation of tests.") do |v|
|
@@ -256,11 +361,11 @@ class DryScaffoldGenerator < Rails::Generator::NamedBase
|
|
256
361
|
end
|
257
362
|
|
258
363
|
opt.on('--fgirl', "Model: Generate \"factory_girl\" factories.") do |v|
|
259
|
-
options[:
|
364
|
+
options[:factory_girl] = v
|
260
365
|
end
|
261
366
|
|
262
367
|
opt.on('--machinist', "Model: Generate \"machinist\" blueprints (factories).") do |v|
|
263
|
-
options[:
|
368
|
+
options[:machinist] = v
|
264
369
|
end
|
265
370
|
|
266
371
|
opt.on('--odaddy', "Model: Generate \"object_daddy\" generator/factory methods.") do |v|
|
@@ -288,13 +393,14 @@ class DryScaffoldGenerator < Rails::Generator::NamedBase
|
|
288
393
|
"[--skip-views]",
|
289
394
|
"[--skip-helpers]",
|
290
395
|
"[--skip-tests]",
|
396
|
+
"[--skip-builders]",
|
291
397
|
"[--layout]",
|
292
398
|
"[--fixtures]",
|
293
399
|
"[--factory_girl]",
|
294
400
|
"[--machinist]",
|
295
401
|
"[--object_daddy]",
|
296
402
|
"[--skip-timestamps]",
|
297
|
-
"[--skip-migration]"
|
403
|
+
"[--skip-migration]"
|
298
404
|
].join(' ')
|
299
405
|
end
|
300
406
|
|
File without changes
|
File without changes
|
@@ -0,0 +1,20 @@
|
|
1
|
+
atom_feed(:language => I18n.locale) do |feed|
|
2
|
+
feed.title 'Resources'
|
3
|
+
feed.subtitle 'Index of all resources.'
|
4
|
+
# Optional: feed.link :href => resources_url(:atom), :rel => 'self'
|
5
|
+
feed.updated (@resources.first.created_at rescue Time.now.utc).strftime('%Y-%m-%dT%H:%M:%SZ'))
|
6
|
+
|
7
|
+
@resources.each do |resource|
|
8
|
+
feed.entry(resource) do |entry|
|
9
|
+
entry.title 'title'
|
10
|
+
entry.summary 'summary'
|
11
|
+
# Optional: entry.content 'content', :type => 'html'
|
12
|
+
# Optional: entry.updated resource.try(:updated_at).strftime('%Y-%m-%dT%H:%M:%SZ')
|
13
|
+
# Optional: entry.link :href => resource_url(resource, :atom)
|
14
|
+
|
15
|
+
resource.author do |author|
|
16
|
+
author.name 'author_name'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
xml.instruct! :xml, :version => '1.0'
|
2
|
+
xml.rss(:version => '2.0') do
|
3
|
+
xml.channel do
|
4
|
+
xml.title 'Resources'
|
5
|
+
xml.description 'Index of all resources.'
|
6
|
+
xml.link resources_url(:rss)
|
7
|
+
xml.lastBuildDate (@resources.first.created_at rescue Time.now.utc).to_s(:rfc822)
|
8
|
+
xml.language I18n.locale
|
9
|
+
|
10
|
+
@resources.each do |resource|
|
11
|
+
xml.item do
|
12
|
+
xml.title 'title'
|
13
|
+
xml.description 'summary'
|
14
|
+
xml.pubDate resource.try(:created_at).to_s(:rfc822)
|
15
|
+
xml.link resource_url(resource, :rss)
|
16
|
+
|
17
|
+
xml.author 'author_name'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/generators/dry_scaffold/{templates/prototypes → prototypes/views/haml}/layout.html.haml
RENAMED
File without changes
|
File without changes
|
File without changes
|
data/generators/dry_scaffold/templates/{controller_standard.rb → controllers/action_controller.rb}
RENAMED
@@ -24,6 +24,12 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
24
24
|
format.yaml { render :text => @<%= plural_name %>.to_yaml, :content_type => :'text/yaml' }
|
25
25
|
<% when :txt, :text then -%>
|
26
26
|
format.txt { render :text => @<%= plural_name %>.to_s, :content_type => :text }
|
27
|
+
<% when :atom, :rss then -%>
|
28
|
+
<% unless options[:skip_builders] -%>
|
29
|
+
format.<%= _format %> # index.<%= _format %>.builder
|
30
|
+
<% else -%>
|
31
|
+
format.<%= _format %> { }
|
32
|
+
<% end -%>
|
27
33
|
<% else -%>
|
28
34
|
format.<%= _format %> { }
|
29
35
|
<% end -%>
|
@@ -62,7 +68,7 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
62
68
|
# GET /<%= plural_name %>/new<%= ".#{_format}" unless _format == :html %>
|
63
69
|
<% end -%>
|
64
70
|
def new
|
65
|
-
|
71
|
+
<%= resource_instance %> = <%= class_name %>.new
|
66
72
|
|
67
73
|
respond_to do |format|
|
68
74
|
<% formats.each do |_format| -%>
|
@@ -71,11 +77,11 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
71
77
|
<% when :js then -%>
|
72
78
|
format.js # new.js.rjs
|
73
79
|
<% when :xml, :json then -%>
|
74
|
-
format.<%= _format %> { render :<%= _format %> =>
|
80
|
+
format.<%= _format %> { render :<%= _format %> => <%= resource_instance %> }
|
75
81
|
<% when :yml, :yaml then -%>
|
76
|
-
format.yaml { render :text =>
|
82
|
+
format.yaml { render :text => <%= resource_instance %>.to_yaml, :content_type => :'text/yaml' }
|
77
83
|
<% when :txt, :text then -%>
|
78
|
-
format.txt { render :text =>
|
84
|
+
format.txt { render :text => <%= resource_instance %>.to_s, :content_type => :text }
|
79
85
|
<% else -%>
|
80
86
|
format.<%= _format %> { }
|
81
87
|
<% end -%>
|
@@ -95,22 +101,22 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
95
101
|
# POST /<%= plural_name %><%= ".#{_format}" unless _format == :html %>
|
96
102
|
<% end -%>
|
97
103
|
def create
|
98
|
-
|
104
|
+
<%= resource_instance %> = <%= class_name %>.new(params[:<%= singular_name %>])
|
99
105
|
|
100
106
|
respond_to do |format|
|
101
|
-
if
|
107
|
+
if <%= resource_instance %>.save
|
102
108
|
flash[:notice] = '<%= singular_name.humanize %> was successfully created.'
|
103
109
|
<% formats.each do |_format| -%>
|
104
110
|
<% case _format when :html then -%>
|
105
|
-
format.html { redirect_to(
|
111
|
+
format.html { redirect_to(<%= resource_instance %>) }
|
106
112
|
<% when :js then -%>
|
107
113
|
format.js # create.js.rjs
|
108
114
|
<% when :xml, :json then -%>
|
109
|
-
format.<%= _format %> { render :<%= _format %> =>
|
115
|
+
format.<%= _format %> { render :<%= _format %> => <%= resource_instance %>, :status => :created, :location => <%= resource_instance %> }
|
110
116
|
<% when :yml, :yaml then -%>
|
111
|
-
format.yaml { render :text =>
|
117
|
+
format.yaml { render :text => <%= resource_instance %>.to_yaml, :content_type => :'text/yaml', :status => :created, :location => <%= resource_instance %> }
|
112
118
|
<% when :txt, :text then -%>
|
113
|
-
format.txt { render :text =>
|
119
|
+
format.txt { render :text => <%= resource_instance %>.to_s, :content_type => :text, :status => :created, :location => <%= resource_instance %> }
|
114
120
|
<% else -%>
|
115
121
|
format.<%= _format %> { }
|
116
122
|
<% end -%>
|
@@ -123,11 +129,11 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
123
129
|
<% when :js then -%>
|
124
130
|
format.js # create.js.rjs
|
125
131
|
<% when :xml, :json then -%>
|
126
|
-
format.<%= _format %> { render :<%= _format %> =>
|
132
|
+
format.<%= _format %> { render :<%= _format %> => <%= resource_instance %>.errors, :status => :unprocessable_entity }
|
127
133
|
<% when :yml, :yaml then -%>
|
128
|
-
format.yaml { render :text =>
|
134
|
+
format.yaml { render :text => <%= resource_instance %>.errors.to_yaml, :content_type => :'text/yaml', :status => :unprocessable_entity }
|
129
135
|
<% when :txt, :text then -%>
|
130
|
-
format.txt { render :text =>
|
136
|
+
format.txt { render :text => <%= resource_instance %>.errors.to_s, :content_type => :text, :status => :unprocessable_entity }
|
131
137
|
<% else -%>
|
132
138
|
format.<%= _format %> { }
|
133
139
|
<% end -%>
|
@@ -143,10 +149,10 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
143
149
|
<% end -%>
|
144
150
|
def update
|
145
151
|
respond_to do |format|
|
146
|
-
if
|
152
|
+
if <%= resource_instance %>.update_attributes(params[:<%= singular_name %>])
|
147
153
|
<% formats.each do |_format| -%>
|
148
154
|
<% case _format when :html then -%>
|
149
|
-
format.html { redirect_to(
|
155
|
+
format.html { redirect_to(<%= resource_instance %>) }
|
150
156
|
<% when :js then -%>
|
151
157
|
format.js # update.js.rjs
|
152
158
|
<% when :xml, :json, :yml, :yaml, :txt, :text then -%>
|
@@ -163,11 +169,11 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
163
169
|
<% when :js then -%>
|
164
170
|
format.js # update.js.rjs
|
165
171
|
<% when :xml, :json then -%>
|
166
|
-
format.<%= _format %> { render :<%= _format %> =>
|
172
|
+
format.<%= _format %> { render :<%= _format %> => <%= resource_instance %>.errors, :status => :unprocessable_entity }
|
167
173
|
<% when :yml, :yaml then -%>
|
168
|
-
format.yaml { render :text =>
|
174
|
+
format.yaml { render :text => <%= resource_instance %>.errors.to_yaml, :status => :unprocessable_entity }
|
169
175
|
<% when :txt, :text then -%>
|
170
|
-
format.txt { render :text =>
|
176
|
+
format.txt { render :text => <%= resource_instance %>.errors.to_s, :status => :unprocessable_entity }
|
171
177
|
<% else -%>
|
172
178
|
format.<%= _format %> { head :unprocessable_entity }
|
173
179
|
<% end -%>
|
@@ -183,7 +189,7 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
183
189
|
<% end -%>
|
184
190
|
def destroy
|
185
191
|
respond_to do |format|
|
186
|
-
if
|
192
|
+
if <%= resource_instance %>.destroy
|
187
193
|
flash[:notice] = '<%= singular_name.humanize %> was successfully destroyed.'
|
188
194
|
<% formats.each do |_format| -%>
|
189
195
|
<% case _format when :html then -%>
|
@@ -200,7 +206,7 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
200
206
|
flash[:error] = '<%= singular_name.humanize %> could not be destroyed.'
|
201
207
|
<% formats.each do |_format| -%>
|
202
208
|
<% case _format when :html then -%>
|
203
|
-
format.html { redirect_to(<%= singular_name %>_url(
|
209
|
+
format.html { redirect_to(<%= singular_name %>_url(<%= resource_instance %>)) }
|
204
210
|
<% when :js then -%>
|
205
211
|
format.js # destroy.js.rjs
|
206
212
|
<% when :xml, :json, :yml, :yaml, :txt, :text then -%>
|
@@ -236,7 +242,7 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
236
242
|
alias :load_and_paginate_resources :collection
|
237
243
|
|
238
244
|
def resource
|
239
|
-
@resource =
|
245
|
+
@resource = <%= resource_instance %> ||= <%= class_name %>.find(params[:id])
|
240
246
|
end
|
241
247
|
alias :load_resource :resource
|
242
248
|
|
@@ -14,6 +14,7 @@ class <%= controller_class_name %>Controller < InheritedResources::Base
|
|
14
14
|
before_filter :load_and_paginate_resources, :only => [<%= symbol_array_to_expression(actions & DryScaffoldGenerator::DEFAULT_COLLECTION_AUTOLOAD_ACTIONS) %>]
|
15
15
|
|
16
16
|
<% end -%>
|
17
|
+
|
17
18
|
<% (actions - DryScaffoldGenerator::DEFAULT_CONTROLLER_ACTIONS).each do |action| -%>
|
18
19
|
# GET /<%= plural_name %>/<%= action.to_s %>
|
19
20
|
def <%= action.to_s %>
|
@@ -30,12 +31,12 @@ class <%= controller_class_name %>Controller < InheritedResources::Base
|
|
30
31
|
paginate_options[:per_page] ||= (params[:per_page] || 20)
|
31
32
|
@<%= plural_name %> = @<%= model_plural_name %> ||= end_of_association_chain.paginate(paginate_options)
|
32
33
|
<% else -%>
|
33
|
-
|
34
|
+
@collection = @<%= model_plural_name %> ||= end_of_association_chain.all
|
34
35
|
<% end -%>
|
35
36
|
end
|
36
37
|
|
37
38
|
def resource
|
38
|
-
|
39
|
+
@resource = @<%= model_singular_name %> ||= end_of_association_chain.find(params[:id])
|
39
40
|
end
|
40
41
|
|
41
42
|
end
|
@@ -20,7 +20,7 @@ class <%= controller_class_name %>ControllerTest < ActionController::TestCase
|
|
20
20
|
test "destroy" do
|
21
21
|
<%= class_name %>.any_instance.expects(:destroy).returns(true)
|
22
22
|
delete :destroy, :id => <%= table_name %>(:one).to_param
|
23
|
-
assert_not_nil flash[:notice]
|
23
|
+
assert_not_nil flash[:notice]
|
24
24
|
assert_response :redirect
|
25
25
|
end
|
26
26
|
|
File without changes
|
File without changes
|
@@ -0,0 +1,20 @@
|
|
1
|
+
atom_feed(:language => I18n.locale) do |feed|
|
2
|
+
feed.title '<%= class_name.pluralize %>'
|
3
|
+
feed.subtitle 'Index of all <%= plural_name %>.'
|
4
|
+
# Optional: feed.link <%= feed_link(:atom) %>
|
5
|
+
feed.updated <%= feed_date(:atom) %>
|
6
|
+
|
7
|
+
<%= collection_instance %>.each do |<%= singular_name %>|
|
8
|
+
feed.entry(<%= singular_name %>) do |entry|
|
9
|
+
entry.title 'title'
|
10
|
+
entry.summary 'summary'
|
11
|
+
# Optional: entry.content 'content', :type => 'html'
|
12
|
+
# Optional: entry.updated <%= feed_entry_date(:atom) %>
|
13
|
+
# Optional: entry.link <%= feed_entry_link(:atom) %>
|
14
|
+
|
15
|
+
<%= singular_name %>.author do |author|
|
16
|
+
author.name 'author_name'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
xml.instruct! :xml, :version => '1.0'
|
2
|
+
xml.rss(:version => '2.0') do
|
3
|
+
xml.channel do
|
4
|
+
xml.title '<%= class_name.pluralize %>'
|
5
|
+
xml.description 'Index of all <%= plural_name %>.'
|
6
|
+
xml.link <%= feed_link(:rss) %>
|
7
|
+
xml.lastBuildDate <%= feed_date(:rss) %>
|
8
|
+
xml.language I18n.locale
|
9
|
+
|
10
|
+
<%= collection_instance %>.each do |<%= singular_name %>|
|
11
|
+
xml.item do
|
12
|
+
xml.title 'title'
|
13
|
+
xml.description 'summary'
|
14
|
+
xml.pubDate <%= feed_entry_date(:rss) %>
|
15
|
+
xml.link <%= feed_entry_link(:rss) %>
|
16
|
+
|
17
|
+
xml.author 'author_name'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
File without changes
|
@@ -3,8 +3,8 @@
|
|
3
3
|
%td.<%= attribute.name %>= h <%= singular_name %>.try(:<%= attribute.name %>)
|
4
4
|
<% end -%>
|
5
5
|
%td.actions
|
6
|
-
= link_to 'Show', <%= singular_name %>
|
6
|
+
= link_to 'Show', <%= show_link(singular_name) %>
|
7
7
|
|
|
8
|
-
= link_to 'Edit',
|
8
|
+
= link_to 'Edit', <%= edit_link(singular_name) %>
|
9
9
|
|
|
10
|
-
= link_to 'Destroy', <%= singular_name %>, :confirm => 'Are you sure?', :method => :delete
|
10
|
+
= link_to 'Destroy', <%= destroy_link(singular_name) %>, :confirm => 'Are you sure?', :method => :delete
|
@@ -1,13 +1,13 @@
|
|
1
1
|
%h1.heading
|
2
|
-
= "Editing <%= singular_name %> %s" %
|
2
|
+
= "Editing <%= singular_name %> %s" % <%= resource_instance %>.id
|
3
3
|
|
4
4
|
<% if options[:formtastic] -%>
|
5
|
-
- semantic_form_for(
|
5
|
+
- semantic_form_for(<%= resource_instance %>) do |form|
|
6
6
|
= render 'form', :form => form
|
7
7
|
- form.buttons do
|
8
8
|
= form.commit_button 'Update'
|
9
9
|
<% else -%>
|
10
|
-
- form_for(
|
10
|
+
- form_for(<%= resource_instance %>) do |form|
|
11
11
|
= form.error_messages
|
12
12
|
= render 'form', :form => form
|
13
13
|
%p.buttons
|
@@ -15,4 +15,4 @@
|
|
15
15
|
<% end -%>
|
16
16
|
|
17
17
|
%p.actions
|
18
|
-
= link_to 'Cancel', <%=
|
18
|
+
= link_to 'Cancel', <%= index_link %>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
= "<%= plural_name.humanize %>"
|
3
3
|
|
4
4
|
%p.actions
|
5
|
-
= link_to 'New <%= singular_name.humanize %>',
|
5
|
+
= link_to 'New <%= singular_name.humanize %>', <%= new_link %>
|
6
6
|
|
7
7
|
%table
|
8
8
|
%thead.header
|
@@ -12,9 +12,9 @@
|
|
12
12
|
<% end -%>
|
13
13
|
%th.actions= 'Actions'
|
14
14
|
%tbody.items.<%= plural_name %>
|
15
|
-
-
|
15
|
+
- <%= collection_instance %>.each do |<%= singular_name %>|
|
16
16
|
= render 'item', :<%= singular_name %> => <%= singular_name %>
|
17
17
|
|
18
18
|
<% if options[:pagination] -%>
|
19
|
-
= will_paginate(
|
19
|
+
= will_paginate(<%= collection_instance %>)
|
20
20
|
<% end -%>
|
data/generators/dry_scaffold/templates/{view_layout.html.haml → views/haml/layout.html.haml}
RENAMED
File without changes
|
@@ -2,12 +2,12 @@
|
|
2
2
|
= 'New <%= singular_name.humanize %>'
|
3
3
|
|
4
4
|
<% if options[:formtastic] -%>
|
5
|
-
- semantic_form_for(
|
5
|
+
- semantic_form_for(<%= resource_instance %>) do |form|
|
6
6
|
= render 'form', :form => form
|
7
7
|
- form.buttons do
|
8
8
|
= form.commit_button 'Create'
|
9
9
|
<% else -%>
|
10
|
-
- form_for(
|
10
|
+
- form_for(<%= resource_instance %>) do |form|
|
11
11
|
= form.error_messages
|
12
12
|
= render 'form', :form => form
|
13
13
|
%p.buttons
|
@@ -15,4 +15,4 @@
|
|
15
15
|
<% end -%>
|
16
16
|
|
17
17
|
%p.actions
|
18
|
-
= link_to 'Cancel', <%=
|
18
|
+
= link_to 'Cancel', <%= index_link %>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
%h1.heading
|
2
|
+
= "<%= singular_name.humanize %> %s" % <%= resource_instance %>.id
|
3
|
+
|
4
|
+
- content_tag_for(:dl, <%= resource_instance %>) do
|
5
|
+
<% attributes.each do |attribute| -%>
|
6
|
+
%dt.label= '<%= attribute.name.humanize %>'
|
7
|
+
%dd.<%= attribute.name -%>= h <%= resource_instance %>.try(:<%= attribute.name %>)
|
8
|
+
<% end -%>
|
9
|
+
|
10
|
+
%p.actions
|
11
|
+
= link_to 'Edit', <%= edit_link %>
|
12
|
+
|
|
13
|
+
= link_to 'Index', <%= index_link %>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grimen-dry_scaffold
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonas Grimfelt
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-05-
|
12
|
+
date: 2009-05-07 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -29,38 +29,48 @@ files:
|
|
29
29
|
- generators/dmodel/dmodel_generator.rb
|
30
30
|
- generators/dry_model/USAGE
|
31
31
|
- generators/dry_model/dry_model_generator.rb
|
32
|
-
- generators/dry_model/
|
33
|
-
- generators/dry_model/
|
34
|
-
- generators/dry_model/
|
35
|
-
- generators/dry_model/
|
36
|
-
- generators/dry_model/
|
37
|
-
- generators/dry_model/
|
32
|
+
- generators/dry_model/prototypes/active_record_migration.rb
|
33
|
+
- generators/dry_model/prototypes/active_record_model.rb
|
34
|
+
- generators/dry_model/prototypes/test_data/active_record_fixtures.yml
|
35
|
+
- generators/dry_model/prototypes/test_data/factory_girl_factories.rb
|
36
|
+
- generators/dry_model/prototypes/test_data/machinist_factories.rb
|
37
|
+
- generators/dry_model/prototypes/tests/test_unit/unit_test.rb
|
38
|
+
- generators/dry_model/templates/models/active_record_migration.rb
|
39
|
+
- generators/dry_model/templates/models/active_record_model.rb
|
40
|
+
- generators/dry_model/templates/models/test_data/active_record_fixtures.yml
|
41
|
+
- generators/dry_model/templates/models/test_data/factory_girl_factories.rb
|
42
|
+
- generators/dry_model/templates/models/test_data/machinist_factories.rb
|
43
|
+
- generators/dry_model/templates/models/tests/test_unit/unit_test.rb
|
38
44
|
- generators/dry_scaffold/USAGE
|
39
45
|
- generators/dry_scaffold/dry_scaffold_generator.rb
|
40
|
-
- generators/dry_scaffold/
|
41
|
-
- generators/dry_scaffold/
|
42
|
-
- generators/dry_scaffold/
|
43
|
-
- generators/dry_scaffold/
|
44
|
-
- generators/dry_scaffold/
|
45
|
-
- generators/dry_scaffold/
|
46
|
-
- generators/dry_scaffold/
|
47
|
-
- generators/dry_scaffold/
|
48
|
-
- generators/dry_scaffold/
|
49
|
-
- generators/dry_scaffold/
|
50
|
-
- generators/dry_scaffold/
|
51
|
-
- generators/dry_scaffold/
|
52
|
-
- generators/dry_scaffold/
|
53
|
-
- generators/dry_scaffold/
|
54
|
-
- generators/dry_scaffold/templates/
|
55
|
-
- generators/dry_scaffold/templates/
|
56
|
-
- generators/dry_scaffold/templates/
|
57
|
-
- generators/dry_scaffold/templates/
|
58
|
-
- generators/dry_scaffold/templates/
|
59
|
-
- generators/dry_scaffold/templates/
|
60
|
-
- generators/dry_scaffold/templates/
|
61
|
-
- generators/dry_scaffold/templates/
|
62
|
-
- generators/dry_scaffold/templates/
|
63
|
-
- generators/dry_scaffold/templates/
|
46
|
+
- generators/dry_scaffold/prototypes/controllers/action_controller.rb
|
47
|
+
- generators/dry_scaffold/prototypes/controllers/inherited_resources_controller.rb
|
48
|
+
- generators/dry_scaffold/prototypes/controllers/tests/unit_test/functional_test.rb
|
49
|
+
- generators/dry_scaffold/prototypes/helpers/helper.rb
|
50
|
+
- generators/dry_scaffold/prototypes/helpers/tests/test_unit/unit_test.rb
|
51
|
+
- generators/dry_scaffold/prototypes/views/builder/index.atom.builder
|
52
|
+
- generators/dry_scaffold/prototypes/views/builder/index.rss.builder
|
53
|
+
- generators/dry_scaffold/prototypes/views/haml/_form.html.haml
|
54
|
+
- generators/dry_scaffold/prototypes/views/haml/_item.html.haml
|
55
|
+
- generators/dry_scaffold/prototypes/views/haml/edit.html.haml
|
56
|
+
- generators/dry_scaffold/prototypes/views/haml/index.html.haml
|
57
|
+
- generators/dry_scaffold/prototypes/views/haml/layout.html.haml
|
58
|
+
- generators/dry_scaffold/prototypes/views/haml/new.html.haml
|
59
|
+
- generators/dry_scaffold/prototypes/views/haml/show.html.haml
|
60
|
+
- generators/dry_scaffold/templates/controllers/action_controller.rb
|
61
|
+
- generators/dry_scaffold/templates/controllers/inherited_resources_controller.rb
|
62
|
+
- generators/dry_scaffold/templates/controllers/tests/test_unit/functional_test.rb
|
63
|
+
- generators/dry_scaffold/templates/helpers/helper.rb
|
64
|
+
- generators/dry_scaffold/templates/helpers/tests/test_unit/unit_test.rb
|
65
|
+
- generators/dry_scaffold/templates/views/builder/index.atom.builder
|
66
|
+
- generators/dry_scaffold/templates/views/builder/index.rss.builder
|
67
|
+
- generators/dry_scaffold/templates/views/haml/_form.html.haml
|
68
|
+
- generators/dry_scaffold/templates/views/haml/_item.html.haml
|
69
|
+
- generators/dry_scaffold/templates/views/haml/edit.html.haml
|
70
|
+
- generators/dry_scaffold/templates/views/haml/index.html.haml
|
71
|
+
- generators/dry_scaffold/templates/views/haml/layout.html.haml
|
72
|
+
- generators/dry_scaffold/templates/views/haml/new.html.haml
|
73
|
+
- generators/dry_scaffold/templates/views/haml/show.html.haml
|
64
74
|
- generators/dscaffold/dscaffold_generator.rb
|
65
75
|
- rails/init.rb
|
66
76
|
- tasks/dry_scaffold.rake
|
@@ -1,13 +0,0 @@
|
|
1
|
-
%h1.heading
|
2
|
-
= "<%= singular_name.humanize %> %s" % @<%= singular_name %>.id
|
3
|
-
|
4
|
-
- content_tag_for(:dl, @<%= singular_name %>) do
|
5
|
-
<% attributes.each do |attribute| -%>
|
6
|
-
%dt.label= '<%= attribute.name.humanize %>'
|
7
|
-
%dd.<%= attribute.name -%>= h @<%= singular_name %>.try(:<%= attribute.name %>)
|
8
|
-
<% end -%>
|
9
|
-
|
10
|
-
%p.actions
|
11
|
-
= link_to 'Edit', edit_<%= singular_name %>_url(@<%= singular_name %>)
|
12
|
-
|
|
13
|
-
= link_to 'Index', <%= collection_name %>_url
|