drailties 0.4.3 → 0.5.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +6 -14
  2. data/bin/drails +4 -42
  3. data/lib/drails/app_drails_loader.rb +62 -0
  4. data/lib/drails/cli.rb +11 -0
  5. data/lib/drails/commands/application.rb +43 -0
  6. data/lib/drails/commands/destroy.rb +12 -0
  7. data/lib/drails/commands/domainserver.rb +6 -0
  8. data/lib/drails/commands/generate.rb +12 -0
  9. data/lib/drails/commands/projectionserver.rb +9 -0
  10. data/lib/drails/commands/server.rb +22 -0
  11. data/lib/drails/commands.rb +70 -0
  12. data/lib/drails/generators.rb +48 -0
  13. data/lib/drails/server/domain_server.rb +4 -1
  14. data/lib/drails/server/projection_servers.rb +5 -2
  15. data/lib/generators/drails/app/USAGE +12 -12
  16. data/lib/generators/drails/app/app_generator.rb +134 -52
  17. data/lib/generators/drails/app/templates/{event_source_controller.rb → app/controllers/event_source_controller.rb} +15 -15
  18. data/lib/generators/drails/app/templates/bin/drails +3 -0
  19. data/lib/generators/drails/app/templates/config/disco.yml +27 -0
  20. data/lib/generators/drails/app/templates/{build_validations_registry.rb → config/initializers/build_validations_registry.rb} +18 -18
  21. data/lib/generators/drails/app/templates/{create_domain.rb → config/initializers/create_domain.rb} +4 -4
  22. data/lib/generators/drails/app/templates/db/seeds.rb +14 -0
  23. data/lib/generators/drails/command/USAGE +11 -11
  24. data/lib/generators/drails/command/command_generator.rb +68 -40
  25. data/lib/generators/drails/command/templates/command.rb +24 -6
  26. data/lib/generators/drails/command/templates/event.rb +11 -10
  27. data/lib/generators/drails/command_processor/USAGE +1 -1
  28. data/lib/generators/drails/command_processor/command_processor_generator.rb +22 -15
  29. data/lib/generators/drails/command_processor/templates/command_processor.rb +5 -5
  30. data/lib/generators/drails/domain.rb +18 -18
  31. data/lib/generators/drails/event_name.rb +51 -51
  32. data/lib/generators/drails/migration/USAGE +41 -1
  33. data/lib/generators/drails/migration/migration_generator.rb +27 -28
  34. data/lib/generators/drails/migration/templates/create_table_migration.rb +19 -19
  35. data/lib/generators/drails/model/USAGE +17 -17
  36. data/lib/generators/drails/model/model_generator.rb +29 -23
  37. data/lib/generators/drails/model/templates/domain_model.rb +5 -5
  38. data/lib/generators/drails/model/templates/model.rb +4 -4
  39. data/lib/generators/drails/processor_name.rb +47 -47
  40. data/lib/generators/drails/projection/projection_generator.rb +3 -3
  41. data/lib/generators/drails/projection/templates/domain_projection.rb +9 -9
  42. data/lib/generators/drails/projection/templates/domain_projection_test.rb +6 -6
  43. data/lib/generators/drails/projection/templates/projection.rb +9 -9
  44. data/lib/generators/drails/projection/templates/projection_test.rb +6 -6
  45. data/lib/generators/drails/scaffold/USAGE +26 -26
  46. data/lib/generators/drails/scaffold/scaffold_generator.rb +91 -89
  47. data/lib/generators/drails/scaffold/templates/_eventstream.js.erb +15 -15
  48. data/lib/generators/drails/{controller → scaffold_controller}/USAGE +1 -1
  49. data/lib/generators/drails/{controller/controller_generator.rb → scaffold_controller/scaffold_controller_generator.rb} +27 -26
  50. data/lib/generators/drails/scaffold_controller/templates/controller.rb +68 -0
  51. data/lib/generators/drails/{controller → scaffold_controller}/templates/controller_test.rb +45 -45
  52. data/lib/generators/drails/use_domain_option.rb +53 -53
  53. data/lib/rails-disco/version.rb +3 -3
  54. data/lib/tasks/db.rake +187 -88
  55. metadata +33 -27
  56. data/lib/drails/application.rb +0 -8
  57. data/lib/drails/domainserver.rb +0 -5
  58. data/lib/drails/generate.rb +0 -21
  59. data/lib/drails/projectionserver.rb +0 -8
  60. data/lib/drails/server.rb +0 -18
  61. data/lib/generators/drails/app/templates/disco.yml +0 -54
  62. data/lib/generators/drails/controller/templates/controller.rb +0 -67
@@ -1,23 +1,29 @@
1
- require 'generators/drails/use_domain_option.rb'
2
-
3
- module Drails
4
- module Generators
5
- class ModelGenerator < Rails::Generators::NamedBase
6
- source_root File.expand_path('../templates', __FILE__)
7
- argument :attributes, type: :array, default: [], banner: "field[:type] field[:type]"
8
- include UseDomainOption
9
-
10
- def create_projection_file
11
- generate 'drails:projection', name, use_domain_param
12
- end
13
-
14
- def create_model_file
15
- template use_domain('model.rb'), use_domain_class_file_path('models', "#{file_name}.rb")
16
- end
17
-
18
- def create_migration
19
- generate 'drails:migration', "create_#{table_name}", attributes.map { |x| "#{x.name}:#{x.type}" }.join(' '), use_domain_param
20
- end
21
- end
22
- end
23
- end
1
+ require 'generators/drails/use_domain_option.rb'
2
+
3
+ module Drails
4
+ module Generators
5
+ class ModelGenerator < Rails::Generators::NamedBase
6
+ source_root File.expand_path('../templates', __FILE__)
7
+ argument :attributes, type: :array, default: [], banner: 'field[:type] field[:type]'
8
+ include UseDomainOption
9
+
10
+ hook_for :projection, require: true do |hook|
11
+ invoke hook, [name]
12
+ end
13
+
14
+ def create_model_file
15
+ template use_domain('model.rb'), use_domain_class_file_path('models', "#{file_name}.rb")
16
+ end
17
+
18
+ hook_for :migration, require: true do |hook|
19
+ invoke hook, ["create_#{table_name}", *attributes]
20
+ end
21
+
22
+ private
23
+
24
+ # do not parse - keep attributes for forwarding to migration
25
+ def parse_attributes!
26
+ end
27
+ end
28
+ end
29
+ end
@@ -1,5 +1,5 @@
1
- module <%=if Rails::Generators.namespace.present? then Rails::Generators.namespace.name end%>Domain
2
- class <%= class_name %> < ActiveRecord::Base
3
- self.table_name = '<%=table_name %>'
4
- end
5
- end
1
+ module <%= Rails::Generators.namespace.name if Rails::Generators.namespace.present? %>Domain
2
+ class <%= class_name %> < ActiveRecord::Base
3
+ self.table_name = '<%=table_name %>'
4
+ end
5
+ end
@@ -1,5 +1,5 @@
1
- <% module_namespacing do -%>
2
- class <%= class_name %> < ActiveRecord::Base
3
- self.table_name = '<%=table_name %>'
4
- end
1
+ <% module_namespacing do -%>
2
+ class <%= class_name %> < ActiveRecord::Base
3
+ self.table_name = '<%=table_name %>'
4
+ end
5
5
  <% end -%>
@@ -1,48 +1,48 @@
1
- require 'active_support/concern'
2
-
3
- module Drails
4
- module Generators
5
- module ProcessorName
6
- extend ActiveSupport::Concern
7
-
8
- included do
9
- class_option :processor, type: :string, default: nil, desc: "class_name of the command processor (defaults to NAME)"
10
- class_option :skip_processor, type: :boolean, default: false, desc: "Skip command processor generation"
11
- end
12
-
13
- def initialize(args, *options)
14
- super
15
- assign_processor_names!(processor_name)
16
- end
17
-
18
- protected
19
-
20
- attr_reader :processor_file_name
21
- attr_reader :processor_class_path
22
-
23
- def skip_processor?
24
- options[:skip_processor]
25
- end
26
-
27
- def processor_name
28
- options[:processor] || name
29
- end
30
-
31
- def processor_file_path
32
- @processor_file_path ||= (processor_class_path + [processor_file_name]).join('/')
33
- end
34
-
35
- def processor_domain_class_path
36
- @processor_domain_class_path ||= class_path_domain processor_class_path
37
- end
38
-
39
- private
40
-
41
- def assign_processor_names!(processor_name)
42
- @processor_class_path = processor_name.include?('/') ? processor_name.split('/') : processor_name.split('::')
43
- @processor_class_path.map! &:underscore
44
- @processor_file_name = @processor_class_path.pop
45
- end
46
- end
47
- end
1
+ require 'active_support/concern'
2
+
3
+ module Drails
4
+ module Generators
5
+ module ProcessorName
6
+ extend ActiveSupport::Concern
7
+
8
+ included do
9
+ class_option :processor, type: :string, default: nil, desc: "class_name of the command processor (defaults to NAME)"
10
+ class_option :skip_processor, type: :boolean, default: false, desc: "Skip command processor generation"
11
+ end
12
+
13
+ def initialize(args, *options)
14
+ super
15
+ assign_processor_names!(processor_name)
16
+ end
17
+
18
+ protected
19
+
20
+ attr_reader :processor_file_name
21
+ attr_reader :processor_class_path
22
+
23
+ def skip_processor?
24
+ options[:skip_processor]
25
+ end
26
+
27
+ def processor_name
28
+ options[:processor] || name
29
+ end
30
+
31
+ def processor_file_path
32
+ @processor_file_path ||= (processor_class_path + [processor_file_name]).join('/')
33
+ end
34
+
35
+ def processor_domain_class_path
36
+ @processor_domain_class_path ||= class_path_domain processor_class_path
37
+ end
38
+
39
+ private
40
+
41
+ def assign_processor_names!(processor_name)
42
+ @processor_class_path = processor_name.include?('/') ? processor_name.split('/') : processor_name.split('::')
43
+ @processor_class_path.map! &:underscore
44
+ @processor_file_name = @processor_class_path.pop
45
+ end
46
+ end
47
+ end
48
48
  end
@@ -4,7 +4,7 @@ module Drails
4
4
  module Generators
5
5
  class ProjectionGenerator < Rails::Generators::NamedBase
6
6
  source_root File.expand_path('../templates', __FILE__)
7
- argument :events, type: :array, default: [], banner: "event event"
7
+ argument :events, type: :array, default: [], banner: 'event event'
8
8
  include UseDomainOption
9
9
 
10
10
  def create_projection_file
@@ -12,8 +12,8 @@ module Drails
12
12
  end
13
13
 
14
14
  def create_test_files
15
- template use_domain('projection_test.rb'), File.join("test/projections", use_domain_class_path, "#{plural_file_name}_projection_test.rb")
15
+ template use_domain('projection_test.rb'), File.join('test/projections', use_domain_class_path, "#{plural_file_name}_projection_test.rb")
16
16
  end
17
17
  end
18
18
  end
19
- end
19
+ end
@@ -1,9 +1,9 @@
1
- module <%=if Rails::Generators.namespace.present? then Rails::Generators.namespace.name end%>Domain
2
- class <%= class_name %>Projection
3
- include ActiveDomain::Projection
4
- <% events.each do |event| %>
5
- def <%= event.underscore.split('/') * '__' %>(event)
6
- end
7
- <% end %>
8
- end
9
- end
1
+ module <%= Rails::Generators.namespace.name if Rails::Generators.namespace.present? %>Domain
2
+ class <%= class_name %>Projection
3
+ include ActiveDomain::Projection
4
+ <% events.each do |event| %>
5
+ def <%= event.underscore.split('/') * '__' %>(event)
6
+ end
7
+ <% end %>
8
+ end
9
+ end
@@ -1,6 +1,6 @@
1
- require 'test_helper'
2
-
3
- module <%=if Rails::Generators.namespace.present? then Rails::Generators.namespace.name end%>Domain
4
- class <%= plural_name.camelcase %>ProjectionTest < ActiveSupport::TestCase
5
- end
6
- end
1
+ require 'test_helper'
2
+
3
+ module <%= Rails::Generators.namespace.name if Rails::Generators.namespace.present? %>Domain
4
+ class <%= plural_name.camelcase %>ProjectionTest < ActiveSupport::TestCase
5
+ end
6
+ end
@@ -1,9 +1,9 @@
1
- <% module_namespacing do -%>
2
- class <%= class_name %>Projection
3
- include ActiveProjection::ProjectionType
4
- <% events.each do |event| %>
5
- def <%= event.underscore.split('/') * '__' %>(event)
6
- end
7
- <% end %>
8
- end
9
- <% end -%>
1
+ <% module_namespacing do -%>
2
+ class <%= class_name %>Projection
3
+ include ActiveProjection::ProjectionType
4
+ <% events.each do |event| %>
5
+ def <%= event.underscore.split('/') * '__' %>(event)
6
+ end
7
+ <% end %>
8
+ end
9
+ <% end -%>
@@ -1,6 +1,6 @@
1
- require 'test_helper'
2
-
3
- <% module_namespacing do -%>
4
- class <%= plural_name.camelcase %>ProjectionTest < ActiveSupport::TestCase
5
- end
6
- <% end -%>
1
+ require 'test_helper'
2
+
3
+ <% module_namespacing do -%>
4
+ class <%= plural_name.camelcase %>ProjectionTest < ActiveSupport::TestCase
5
+ end
6
+ <% end -%>
@@ -1,27 +1,27 @@
1
- Description:
2
- Scaffolds a complete resource with models, migration, projections, controller, views
3
- commands, events and command_processor.
4
-
5
- Example:
6
- rails generate drails:scaffold Thing [attr1:type, attr2:type]
7
-
8
- This will create:
9
- app/controllers/things_controller
10
- app/commands/create_thing_command.rb
11
- app/commands/update_thing_command.rb
12
- app/commands/delete_thing_command.rb
13
- domain/command_processors/thing_processor.rb
14
- app/events/created_thing_event.rb
15
- app/events/updated_thing_event.rb
16
- app/events/deleted_thing_event.rb
17
- app/projections/things_projection.rb
18
- db/migrate/create_things.rb
19
- app/models/thing.rb
20
- app/helpers/things_helper.rb
21
- app/views/things/_eventstream.js.erb
22
- app/views/things/_form.html.erb
23
- app/views/things/edit.html.erb
24
- app/views/things/index.html.erb
25
- app/views/things/new.html.erb
26
- app/views/things/show.html.erb
1
+ Description:
2
+ Scaffolds a complete resource with models, migration, projections, controller, views
3
+ commands, events and command_processor.
4
+
5
+ Example:
6
+ rails generate drails:scaffold Thing [attr1:type, attr2:type]
7
+
8
+ This will create:
9
+ app/controllers/things_controller
10
+ app/commands/create_thing_command.rb
11
+ app/commands/update_thing_command.rb
12
+ app/commands/delete_thing_command.rb
13
+ domain/command_processors/thing_processor.rb
14
+ app/events/created_thing_event.rb
15
+ app/events/updated_thing_event.rb
16
+ app/events/deleted_thing_event.rb
17
+ app/projections/things_projection.rb
18
+ db/migrate/create_things.rb
19
+ app/models/thing.rb
20
+ app/helpers/things_helper.rb
21
+ app/views/things/_eventstream.js.erb
22
+ app/views/things/_form.html.erb
23
+ app/views/things/edit.html.erb
24
+ app/views/things/index.html.erb
25
+ app/views/things/new.html.erb
26
+ app/views/things/show.html.erb
27
27
  a resource route
@@ -1,89 +1,91 @@
1
- require 'generators/drails/processor_name.rb'
2
- require 'generators/drails/domain.rb'
3
-
4
- module Drails
5
- module Generators
6
- class ScaffoldGenerator < Rails::Generators::NamedBase
7
- source_root File.expand_path('../templates', __FILE__)
8
- argument :attributes, type: :array, default: [], banner: "field[:type] field[:type]"
9
- include ProcessorName
10
- include Domain
11
-
12
- def create_models
13
- generate 'drails:model', name, attr_string
14
- end
15
-
16
- def create_commands
17
- %w(create update delete).each do |action|
18
- attr_arg = attributes_names.join(' ') unless action == 'delete'
19
- command = (class_path + ["#{action}_#{file_name}"]) * '/'
20
- event_arg = "--event=" + (class_path + ["#{action}d_#{file_name}"]) * '/'
21
- processor_arg = "--processor=#{processor_name}"
22
- processor_arg = "--skip-processor" if skip_processor?
23
- generate 'drails:command', command, attr_arg, processor_arg, event_arg
24
- add_to_projections(action)
25
- end
26
- end
27
-
28
- def add_to_command_processor
29
- content = "
30
- command.id = ActiveDomain::UniqueCommandIdRepository.new_for command.class.name"
31
- inject_into_file File.join('domain/command_processors', domain_class_path, "#{processor_file_name}_processor.rb"), content, after: /(\s)*process(\s)*(.)*CreateCommand(.)*/
32
- end
33
-
34
- def add_routes
35
- routing_code = ""
36
- class_path.each_with_index do |ns, i|
37
- add_line_with_indent routing_code, (i + 1), "namespace :#{ns} do"
38
- end
39
- add_line_with_indent routing_code, (class_path.length + 1), "resources :#{plural_name}"
40
- class_path.each_with_index do |ns, i|
41
- add_line_with_indent routing_code, (class_path.length - i), "end"
42
- end
43
- route routing_code[2..-1]
44
- end
45
-
46
- def create_controller
47
- generate 'drails:controller', name, attr_string
48
- end
49
-
50
- def copy_event_stream_client
51
- copy_file '_eventstream.js.erb', File.join('app', 'views', 'application', '_eventstream.js.erb')
52
- end
53
-
54
- def add_event_stream_client_to_views
55
- include_text = '<%= javascript_tag render partial: \'eventstream\', formats: [:js], locals: {event_id: @event_id} %>'
56
- prepend_to_file File.join('app/views', class_path, plural_file_name, 'index.html.erb'), include_text
57
- prepend_to_file File.join('app/views', class_path, plural_file_name, 'show.html.erb'), include_text
58
- end
59
-
60
- private
61
-
62
- def attr_string
63
- @attr_string ||= attributes.map { |x| "#{x.name}:#{x.type}" }.join(' ')
64
- end
65
-
66
- def add_to_projections(action)
67
- event_func = (class_path + ["#{action}d_#{file_name}_event"]) * '__'
68
- content = "
69
-
70
- def #{event_func}(event)
71
- #{method_bodies[action]}
72
- end"
73
- inject_into_file File.join('app/projections', class_path, "#{plural_file_name}_projection.rb"), content, after: /(\s)*include(\s)*ActiveProjection::ProjectionType/
74
- end
75
-
76
- def method_bodies
77
- {
78
- 'create' => "#{class_name}.create! event.values.merge(id: event.id)",
79
- 'update' => "#{class_name}.find(event.id).update! event.values",
80
- 'delete' => "#{class_name}.find(event.id).destroy!",
81
- }
82
- end
83
-
84
- def add_line_with_indent(target, indent, str)
85
- target << "#{" " * indent}#{str}\n"
86
- end
87
- end
88
- end
89
- end
1
+ require 'generators/drails/processor_name.rb'
2
+ require 'generators/drails/domain.rb'
3
+
4
+ module Drails
5
+ module Generators
6
+ class ScaffoldGenerator < Rails::Generators::NamedBase
7
+ source_root File.expand_path('../templates', __FILE__)
8
+ argument :attributes, type: :array, default: [], banner: "field[:type] field[:type]"
9
+ include ProcessorName
10
+ include Domain
11
+
12
+ hook_for :model, in: :drails, require: true
13
+
14
+ hook_for :command, in: :drails, require: true do |hook|
15
+ %w(create update delete).each do |action|
16
+ args = [(class_path + ["#{action}_#{file_name}"]) * '/']
17
+ args += attributes_names unless action == 'delete'
18
+ opts = ["--event=#{(class_path + ["#{action}d_#{file_name}"]) * '/'}"]
19
+ opts << "--processor=#{processor_name}" unless skip_processor?
20
+ opts << '--skip_model' if action == 'delete'
21
+ opts << "--model_name=#{class_name}"
22
+ opts << '--persisted' if action == 'update'
23
+ invoke hook, args, opts
24
+ add_to_projections(action)
25
+ end
26
+ add_to_command_processor
27
+ end
28
+
29
+ def add_routes
30
+ routing_code = ''
31
+ class_path.each_with_index do |ns, i|
32
+ add_line_with_indent routing_code, (i + 1), "namespace :#{ns} do"
33
+ end
34
+ add_line_with_indent routing_code, (class_path.length + 1), "resources :#{plural_name}"
35
+ class_path.each_with_index do |ns, i|
36
+ add_line_with_indent routing_code, (class_path.length - i), 'end'
37
+ end
38
+ route routing_code[2..-1]
39
+ end
40
+
41
+ hook_for :scaffold_controller, in: :drails, require: true do |hook|
42
+ invoke hook
43
+ add_event_stream_client_to_views
44
+ end
45
+
46
+ def copy_event_stream_client
47
+ # ensure if app was created before this was default
48
+ copy_file '_eventstream.js.erb', 'app/views/application/eventstream/_eventstream.js.erb', verbose: false, skip: true
49
+ end
50
+
51
+ protected
52
+
53
+ def add_event_stream_client_to_views
54
+ return if behavior == :revoke
55
+ include_text = '<%= javascript_tag render partial: \'application/eventstream/eventstream\', formats: [:js], locals: {event_id: @event_id} %>'
56
+ prepend_to_file File.join('app/views', class_path, plural_file_name, 'index.html.erb'), include_text
57
+ prepend_to_file File.join('app/views', class_path, plural_file_name, 'show.html.erb'), include_text
58
+ end
59
+
60
+ def add_to_command_processor
61
+ return if behavior == :revoke
62
+ content = "\n command.id = ActiveDomain::UniqueCommandIdRepository.new_for command.class.name"
63
+ insert_into_file File.join('domain/command_processors', domain_class_path, "#{processor_file_name}_processor.rb"), content, after: /(\s)*process(\s)*(.)*CreateCommand(.)*/
64
+ end
65
+
66
+ def add_to_projections(action)
67
+ return if behavior == :revoke
68
+ event_func = (class_path + ["#{action}d_#{file_name}_event"]) * '__'
69
+ content = "
70
+
71
+ def #{event_func}(event)
72
+ #{method_bodies[action]}
73
+ end"
74
+ indent(content) if namespaced?
75
+ inject_into_file File.join('app/projections', class_path, "#{plural_file_name}_projection.rb"), content, after: /(\s)*include(\s)*ActiveProjection::ProjectionType/
76
+ end
77
+
78
+ def method_bodies
79
+ {
80
+ 'create' => "#{class_name}.create! event.values.merge(id: event.id)",
81
+ 'update' => "#{class_name}.find(event.id).update! event.values",
82
+ 'delete' => "#{class_name}.find(event.id).destroy!",
83
+ }
84
+ end
85
+
86
+ def add_line_with_indent(target, indent, str)
87
+ target << "#{" " * indent}#{str}\n"
88
+ end
89
+ end
90
+ end
91
+ end
@@ -1,16 +1,16 @@
1
- <% if event_id.present? %>
2
- $(document).ready(function () {
3
- setTimeout(function () {
4
- var source = new EventSource('/event_stream');
5
- source.addEventListener('refresh', function (e) {
6
- var event = JSON.parse(e.data);
7
- if (<%= event_id %> == event.id){
8
- window.location.reload();
9
- }else if (<%= event_id %> < event.id){
10
- source.removeEventListener('refresh');
11
- source.close();
12
- }
13
- });
14
- }, 1);
15
- });
1
+ <% if event_id.present? %>
2
+ $(document).ready(function () {
3
+ setTimeout(function () {
4
+ var source = new EventSource('/event_stream');
5
+ source.addEventListener('refresh', function (e) {
6
+ var event = JSON.parse(e.data);
7
+ if (<%= event_id %> == event.id){
8
+ window.location.reload();
9
+ }else if (<%= event_id %> < event.id){
10
+ source.removeEventListener('refresh');
11
+ source.close();
12
+ }
13
+ });
14
+ }, 1);
15
+ });
16
16
  <% end %>
@@ -1 +1 @@
1
- Not intended for extern use!
1
+ Not intended for extern use!
@@ -1,26 +1,27 @@
1
- require 'rails/generators/rails/scaffold_controller/scaffold_controller_generator'
2
- module Drails
3
- module Generators
4
- class ControllerGenerator < Rails::Generators::ScaffoldControllerGenerator
5
- source_root File.expand_path('../templates', __FILE__)
6
- hide!
7
- remove_hook_for :test_framework
8
-
9
- def create_test_files
10
- template "controller_test.rb", File.join("test/controllers", controller_class_path, "#{controller_file_name}_controller_test.rb")
11
- end
12
-
13
- protected
14
-
15
- def command_class_name(command)
16
- (class_path + ["#{command}_#{file_name}"]).map(&:camelize) * '::'
17
- end
18
-
19
- private
20
-
21
- def params_string
22
- attributes.map { |x| "#{x.name}: params[:#{singular_table_name}][:#{x.name}]" }.join(', ')
23
- end
24
- end
25
- end
26
- end
1
+ require 'rails/generators/rails/scaffold_controller/scaffold_controller_generator'
2
+ module Drails
3
+ module Generators
4
+ class ScaffoldControllerGenerator < Rails::Generators::ScaffoldControllerGenerator
5
+ source_root File.expand_path('../templates', __FILE__)
6
+ hide!
7
+
8
+ # the normal test_framework will not cover our usecase
9
+ remove_hook_for :test_framework
10
+ def create_test_files
11
+ template 'controller_test.rb', File.join('test/controllers', controller_class_path, "#{controller_file_name}_controller_test.rb")
12
+ end
13
+
14
+ protected
15
+
16
+ def command_class_name(command)
17
+ (class_path + ["#{command}_#{file_name}"]).map(&:camelize) * '::'
18
+ end
19
+
20
+ private
21
+
22
+ def params_string
23
+ attributes.map { |x| "#{x.name}: params[:#{singular_table_name}][:#{x.name}]" }.join(', ')
24
+ end
25
+ end
26
+ end
27
+ end