dry_scaffold 0.3.6 → 0.3.7
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/CHANGELOG.textile +6 -0
- data/README.textile +17 -0
- data/generators/dry_scaffold/dry_scaffold_generator.rb +0 -1
- data/lib/dry_generator.rb +22 -13
- metadata +2 -2
data/CHANGELOG.textile
CHANGED
@@ -1,6 +1,12 @@
|
|
1
|
+
h1. 0.3.7 (2010-01-02)
|
2
|
+
|
3
|
+
* Feature: override DryScaffold templates seamlessly: Auto-detect and use app-specific custom templates with mapping: RAILS_ROOT/lib/scaffold_templates/**/* <=> GEM_ROOT/generators/{dry_scaffold,dry_model}/templates/**/*.
|
4
|
+
|
1
5
|
h1. 0.3.6 (2009-12-31)
|
2
6
|
|
3
7
|
* Gemcutter as gem source.
|
8
|
+
* Bugfix: Use InheritedResources (if loaded) URL helpers.
|
9
|
+
* Bugfix: Use specified test framework, test-unit was used all the time.
|
4
10
|
|
5
11
|
h1. 0.3.4 (2009-09-16)
|
6
12
|
|
data/README.textile
CHANGED
@@ -53,6 +53,7 @@ The most characteristic features:
|
|
53
53
|
* Optionally specify what actions/views to generate (stubs for specified REST-actions will be generated).
|
54
54
|
* Optionally specify what respond_to-formats to generate (stubs for the most common respond_to-formats will be generated).
|
55
55
|
* Generates default helpers/models/migrations, and REST-routes (if not already defined).
|
56
|
+
* Override default templates with app-specific ones without hassle.
|
56
57
|
|
57
58
|
h3. Formtastic Forms
|
58
59
|
|
@@ -447,6 +448,22 @@ You can set defaults for the generator args/options in @config/scaffold.yml@. To
|
|
447
448
|
|
448
449
|
<pre>rake dry_scaffold:config:generate</pre>
|
449
450
|
|
451
|
+
h3. Overriding default templates
|
452
|
+
|
453
|
+
You can very easily override the default DryScaffold templates (views, controllers, whatever...) by creating custom template files according to the same relative path as the generator templates in @RAILS_ROOT/lib/scaffold_templates@.
|
454
|
+
|
455
|
+
Example: Override the index view template
|
456
|
+
|
457
|
+
In DryScaffold the index template file is located in:
|
458
|
+
|
459
|
+
@GEM_ROOT/generators/dry_scaffold/templates/views/haml/index.html.haml@
|
460
|
+
|
461
|
+
...which means that if you want to override it, you should have your custom template in:
|
462
|
+
|
463
|
+
@RAILS_ROOT/lib/scaffold_templates/views/haml/index.html.haml@
|
464
|
+
|
465
|
+
Copying template files to this location for overriding needs to be done manually for now, but maybe there will be a generator for this later on. That would be useful at least. =)
|
466
|
+
|
450
467
|
h2. Examples
|
451
468
|
|
452
469
|
No need for more samples here, just create a new Rails project, install DryScaffold and it's dependencies, and try it out!
|
@@ -325,7 +325,6 @@ class DryScaffoldGenerator < DryGenerator
|
|
325
325
|
@collection_name = options[:resourceful] ? RESOURCEFUL_COLLECTION_NAME : @model_plural_name
|
326
326
|
@singular_name = options[:resourceful] ? RESOURCEFUL_SINGULAR_NAME : @model_singular_name
|
327
327
|
@plural_name = options[:resourceful] ? RESOURCEFUL_SINGULAR_NAME.pluralize : @model_plural_name
|
328
|
-
puts options[:resourceful], @collection_name
|
329
328
|
end
|
330
329
|
|
331
330
|
def add_options!(opt)
|
data/lib/dry_generator.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
|
1
2
|
class DryGenerator < Rails::Generator::NamedBase
|
2
3
|
|
3
4
|
HAS_WILL_PAGINATE = defined?(WillPaginate)
|
@@ -65,20 +66,21 @@ class DryGenerator < Rails::Generator::NamedBase
|
|
65
66
|
:rspec => 'spec'
|
66
67
|
}.freeze
|
67
68
|
|
68
|
-
DEFAULT_TEST_FRAMEWORK =
|
69
|
-
DEFAULT_FACTORY_FRAMEWORK =
|
69
|
+
DEFAULT_TEST_FRAMEWORK = :test_unit
|
70
|
+
DEFAULT_FACTORY_FRAMEWORK = :fixtures
|
70
71
|
|
71
|
-
TESTS_PATH =
|
72
|
-
FUNCTIONAL_TESTS_PATH =
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
UNIT_TESTS_PATH =
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
72
|
+
TESTS_PATH = File.join('test').freeze
|
73
|
+
FUNCTIONAL_TESTS_PATH = {
|
74
|
+
:test_unit => 'functional',
|
75
|
+
:shoulda => 'functional',
|
76
|
+
:rspec => 'controllers'
|
77
|
+
}
|
78
|
+
UNIT_TESTS_PATH = {
|
79
|
+
:test_unit => 'unit',
|
80
|
+
:shoulda => 'unit',
|
81
|
+
:rspec => 'models',
|
82
|
+
}
|
83
|
+
CUSTOM_TEMPLATES_PATH = Rails.root.join(*%w[lib scaffold_templates])
|
82
84
|
|
83
85
|
NON_ATTR_ARG_KEY_PREFIX = '_'.freeze
|
84
86
|
|
@@ -91,6 +93,13 @@ class DryGenerator < Rails::Generator::NamedBase
|
|
91
93
|
set_test_framework
|
92
94
|
end
|
93
95
|
|
96
|
+
def source_path(relative_source)
|
97
|
+
custom_relative_source = File.join('lib', 'scaffold_templates', relative_source)
|
98
|
+
custom_source = Rails.root.join(custom_relative_source)
|
99
|
+
puts " custom @#{custom_relative_source}" if File.exist?(custom_relative_source)
|
100
|
+
File.exist?(custom_source) ? custom_source : super(relative_source)
|
101
|
+
end
|
102
|
+
|
94
103
|
protected
|
95
104
|
|
96
105
|
def set_test_framework
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry_scaffold
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.7
|
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:
|
12
|
+
date: 2010-01-02 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|