ruboss_on_ruby 1.0.1

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.
Files changed (102) hide show
  1. data/History.txt +3 -0
  2. data/Manifest.txt +101 -0
  3. data/README.txt +37 -0
  4. data/Rakefile +4 -0
  5. data/config/hoe.rb +72 -0
  6. data/config/requirements.rb +15 -0
  7. data/gpl-3.0.txt +674 -0
  8. data/lib/ruboss_on_ruby.rb +64 -0
  9. data/lib/ruboss_on_ruby/active_foo.rb +127 -0
  10. data/lib/ruboss_on_ruby/active_record_tasks.rb +75 -0
  11. data/lib/ruboss_on_ruby/configuration.rb +38 -0
  12. data/lib/ruboss_on_ruby/tasks.rb +74 -0
  13. data/lib/ruboss_on_ruby/version.rb +11 -0
  14. data/merb_generators/ruboss_config/USAGE +18 -0
  15. data/merb_generators/ruboss_config/ruboss_config_generator.rb +135 -0
  16. data/merb_generators/ruboss_config/templates/actionscript.properties +16 -0
  17. data/merb_generators/ruboss_config/templates/actionscriptair.properties +16 -0
  18. data/merb_generators/ruboss_config/templates/expressInstall.swf +0 -0
  19. data/merb_generators/ruboss_config/templates/flex.properties +2 -0
  20. data/merb_generators/ruboss_config/templates/html-template/AC_OETags.js +276 -0
  21. data/merb_generators/ruboss_config/templates/html-template/history/history.css +6 -0
  22. data/merb_generators/ruboss_config/templates/html-template/history/history.js +645 -0
  23. data/merb_generators/ruboss_config/templates/html-template/history/historyFrame.html +29 -0
  24. data/merb_generators/ruboss_config/templates/html-template/index.template.html +121 -0
  25. data/merb_generators/ruboss_config/templates/html-template/playerProductInstall.swf +0 -0
  26. data/merb_generators/ruboss_config/templates/index.html.erb +19 -0
  27. data/merb_generators/ruboss_config/templates/mainair-app.xml +134 -0
  28. data/merb_generators/ruboss_config/templates/mainapp.mxml +34 -0
  29. data/merb_generators/ruboss_config/templates/project.properties +18 -0
  30. data/merb_generators/ruboss_config/templates/projectair.properties +24 -0
  31. data/merb_generators/ruboss_config/templates/swfobject.js +5 -0
  32. data/merb_generators/ruboss_controller/USAGE +11 -0
  33. data/merb_generators/ruboss_controller/ruboss_controller_generator.rb +32 -0
  34. data/merb_generators/ruboss_controller/templates/controller.as.erb +35 -0
  35. data/merb_generators/ruboss_resource_controller/USAGE +5 -0
  36. data/merb_generators/ruboss_resource_controller/ruboss_resource_controller_generator.rb +70 -0
  37. data/merb_generators/ruboss_resource_controller/templates/app/controllers/%controller_file_name%.rb +55 -0
  38. data/merb_generators/ruboss_resource_controller/templates/app/helpers/%controller_file_name%_helper.rb +16 -0
  39. data/merb_generators/ruboss_scaffold/USAGE +5 -0
  40. data/merb_generators/ruboss_scaffold/ruboss_scaffold_generator.rb +190 -0
  41. data/merb_generators/ruboss_scaffold/templates/component.mxml.erb +148 -0
  42. data/merb_generators/ruboss_scaffold/templates/fixtures.yml.erb +35 -0
  43. data/merb_generators/ruboss_scaffold/templates/migration.rb.erb +19 -0
  44. data/merb_generators/ruboss_scaffold/templates/model.as.erb +42 -0
  45. data/merb_generators/ruboss_scaffold/templates/model.rb.erb +11 -0
  46. data/merb_generators/ruboss_yaml_scaffold/USAGE +5 -0
  47. data/merb_generators/ruboss_yaml_scaffold/ruboss_yaml_scaffold_generator.rb +53 -0
  48. data/rails_generators/ruboss_config/USAGE +18 -0
  49. data/rails_generators/ruboss_config/ruboss_config_generator.rb +126 -0
  50. data/rails_generators/ruboss_config/templates/actionscript.properties +16 -0
  51. data/rails_generators/ruboss_config/templates/actionscriptair.properties +16 -0
  52. data/rails_generators/ruboss_config/templates/expressInstall.swf +0 -0
  53. data/rails_generators/ruboss_config/templates/flex.properties +2 -0
  54. data/rails_generators/ruboss_config/templates/html-template/AC_OETags.js +276 -0
  55. data/rails_generators/ruboss_config/templates/html-template/history/history.css +6 -0
  56. data/rails_generators/ruboss_config/templates/html-template/history/history.js +645 -0
  57. data/rails_generators/ruboss_config/templates/html-template/history/historyFrame.html +29 -0
  58. data/rails_generators/ruboss_config/templates/html-template/index.template.html +121 -0
  59. data/rails_generators/ruboss_config/templates/html-template/playerProductInstall.swf +0 -0
  60. data/rails_generators/ruboss_config/templates/index.html.erb +19 -0
  61. data/rails_generators/ruboss_config/templates/mainair-app.xml +134 -0
  62. data/rails_generators/ruboss_config/templates/mainapp.mxml +34 -0
  63. data/rails_generators/ruboss_config/templates/project.properties +18 -0
  64. data/rails_generators/ruboss_config/templates/projectair.properties +24 -0
  65. data/rails_generators/ruboss_config/templates/ruboss_tasks.rake +15 -0
  66. data/rails_generators/ruboss_config/templates/swfobject.js +5 -0
  67. data/rails_generators/ruboss_controller/USAGE +11 -0
  68. data/rails_generators/ruboss_controller/ruboss_controller_generator.rb +46 -0
  69. data/rails_generators/ruboss_controller/templates/controller.as.erb +35 -0
  70. data/rails_generators/ruboss_scaffold/USAGE +35 -0
  71. data/rails_generators/ruboss_scaffold/ruboss_scaffold_generator.rb +193 -0
  72. data/rails_generators/ruboss_scaffold/templates/component.mxml.erb +148 -0
  73. data/rails_generators/ruboss_scaffold/templates/controller.rb.erb +97 -0
  74. data/rails_generators/ruboss_scaffold/templates/fixtures.yml.erb +35 -0
  75. data/rails_generators/ruboss_scaffold/templates/migration.rb.erb +19 -0
  76. data/rails_generators/ruboss_scaffold/templates/model.as.erb +42 -0
  77. data/rails_generators/ruboss_scaffold/templates/model.rb.erb +11 -0
  78. data/rails_generators/ruboss_yaml_scaffold/USAGE +14 -0
  79. data/rails_generators/ruboss_yaml_scaffold/ruboss_yaml_scaffold_generator.rb +45 -0
  80. data/rcl-1.0.txt +0 -0
  81. data/script/console +10 -0
  82. data/script/destroy +14 -0
  83. data/script/generate +14 -0
  84. data/script/txt2html +82 -0
  85. data/setup.rb +1585 -0
  86. data/tasks/deployment.rake +34 -0
  87. data/tasks/environment.rake +7 -0
  88. data/tasks/website.rake +17 -0
  89. data/test/active_foo_test.rb +16 -0
  90. data/test/test_generator_helper.rb +29 -0
  91. data/test/test_helper.rb +2 -0
  92. data/test/test_ruboss_config_generator.rb +45 -0
  93. data/test/test_ruboss_controller_generator.rb +45 -0
  94. data/test/test_ruboss_on_ruby.rb +11 -0
  95. data/test/test_ruboss_scaffold_generator.rb +45 -0
  96. data/test/test_ruboss_yaml_scaffold_generator.rb +46 -0
  97. data/website/index.html +86 -0
  98. data/website/index.txt +83 -0
  99. data/website/javascripts/rounded_corners_lite.inc.js +285 -0
  100. data/website/stylesheets/screen.css +138 -0
  101. data/website/template.html.erb +48 -0
  102. metadata +166 -0
@@ -0,0 +1,35 @@
1
+ package <%= base_package %>.controllers {
2
+ import <%= base_package %>.models.*;
3
+ import <%= base_package %>.commands.*;
4
+
5
+ import org.ruboss.Ruboss;
6
+ import org.ruboss.controllers.RubossCommandsController;
7
+ import org.ruboss.utils.RubossUtils;
8
+
9
+ public class <%= command_controller_name %> extends RubossCommandsController {
10
+ private static var controller:<%= command_controller_name %>;
11
+
12
+ public static var models:Array = [<%= model_names %>]; /* Models */
13
+
14
+ public function <%= command_controller_name %>(enforcer:SingletonEnforcer, extraServices:Array,
15
+ defaultServiceId:int = -1) {
16
+ super([<%= command_names %>] /* Commands */,
17
+ models, extraServices, defaultServiceId);
18
+ }
19
+
20
+ public static function get instance():<%= command_controller_name %> {
21
+ if (controller == null) initialize();
22
+ return controller;
23
+ }
24
+
25
+ public static function initialize(extraServices:Array = null, defaultServiceId:int = -1,
26
+ airDatabaseName:String = null):void {
27
+ if (!RubossUtils.isEmpty(airDatabaseName)) Ruboss.airDatabaseName = airDatabaseName;
28
+ controller = new <%= command_controller_name %>(new SingletonEnforcer, extraServices,
29
+ defaultServiceId);
30
+ Ruboss.commands = controller;
31
+ }
32
+ }
33
+ }
34
+
35
+ class SingletonEnforcer {}
@@ -0,0 +1,35 @@
1
+ Description:
2
+ Scaffolds an entire resource, from model and migration to controller and
3
+ views, along with a full test suite. The resource is ready to use as a
4
+ starting point for your restful, resource-oriented application.
5
+
6
+ ruboss_scaffold delegates the underlying rails code generation to "scaffold"
7
+ and extends it in a number of ways:
8
+ 1. Generates all required Flex code.
9
+ 2. You can pass special belongs_to, has_one and has_many attributes
10
+ to generate *all* appropriate relationships. No more manual code
11
+ editing.
12
+
13
+ Pass the name of the model, either CamelCased or under_scored, as the first
14
+ argument, and an optional list of attribute pairs.
15
+
16
+ Attribute pairs are column_name:sql_type arguments specifying the
17
+ model's attributes. Timestamps are added by default, so you don't have to
18
+ specify them by hand as 'created_at:datetime updated_at:datetime'.
19
+
20
+ The syntax for belongs_to, has_one and has_many attributes is as follows:
21
+ belongs_to:<relationship_name> or
22
+ belongs_to:<relationship_name>,<another_relationship>,<and_another>
23
+
24
+ You don't have to think up every attribute up front, but it helps to
25
+ sketch out a few so you can start working with the resource immediately.
26
+
27
+ For example, `scaffold post title:string body:text published:boolean`
28
+ gives you a model with those three attributes, a controller that handles
29
+ the create/show/update/destroy, forms to create and edit your posts, and
30
+ an index that lists them all, as well as a map.resources :posts
31
+ declaration in config/routes.rb.
32
+
33
+ Examples:
34
+ `./script/generate ruboss_scaffold project name:string has_many:tasks`
35
+ `./script/generate ruboss_scaffold task name:string belongs_to:project`
@@ -0,0 +1,193 @@
1
+ ################################################################################
2
+ # Copyright 2008, Ruboss Technology Corporation.
3
+ #
4
+ # This software is dual-licensed under both the terms of the Ruboss Commercial
5
+ # License v1 (RCL v1) as published by Ruboss Technology Corporation and under
6
+ # the terms of the GNU General Public License v3 (GPL v3) as published by the
7
+ # Free Software Foundation.
8
+ #
9
+ # Both the RCL v1 (rcl-1.0.txt) and the GPL v3 (gpl-3.0.txt) are included in
10
+ # the source code. If you have purchased a commercial license then only the
11
+ # RCL v1 applies; otherwise, only the GPL v3 applies. To learn more or to buy a
12
+ # commercial license, please go to http://ruboss.com.
13
+ ################################################################################
14
+ require 'ruboss_on_ruby/configuration'
15
+
16
+ module Rails
17
+ module Generator
18
+ class GeneratedAttribute
19
+ attr_accessor :name, :type, :column, :flex_name
20
+
21
+ def initialize(name, type)
22
+ @name, @type = name, type.to_sym
23
+ @flex_name = name.camelcase(:lower)
24
+ @column = ActiveRecord::ConnectionAdapters::Column.new(name, nil, @type)
25
+ end
26
+
27
+ def field_type
28
+ @field_type ||= case type
29
+ when :integer, :float, :decimal then :text_field
30
+ when :datetime, :timestamp, :time then :datetime_select
31
+ when :date then :date_select
32
+ when :string then :text_field
33
+ when :text then :text_area
34
+ when :boolean then :check_box
35
+ else
36
+ :text_field
37
+ end
38
+ end
39
+
40
+ def default(prefix = '')
41
+ @default = case type
42
+ when :integer then 1
43
+ when :float then 1.5
44
+ when :decimal then "9.99"
45
+ when :datetime, :timestamp, :time then Time.now.to_s(:db)
46
+ when :date then Date.today.to_s(:db)
47
+ when :string then prefix + name.camelize + "String"
48
+ when :text then prefix + name.camelize + "Text"
49
+ when :boolean then false
50
+ else
51
+ ""
52
+ end
53
+ end
54
+
55
+ def flex_type
56
+ @flex_type = case type
57
+ when :integer then 'int'
58
+ when :string, :text then 'String'
59
+ when :date, :datetime, :time then 'Date'
60
+ when :boolean then 'Boolean'
61
+ when :float, :decimal then 'Number'
62
+ else
63
+ '*'
64
+ end
65
+ end
66
+
67
+ def flex_default(prefix = '')
68
+ @flex_default = case type
69
+ when :integer, :float, :decimal then '0'
70
+ when :string, :text then '""'
71
+ when :boolean then 'false'
72
+ else
73
+ 'null'
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
79
+
80
+ class RubossScaffoldGenerator < Rails::Generator::NamedBase
81
+ include RubossOnRuby::Configuration
82
+
83
+ attr_reader :project_name,
84
+ :flex_project_name,
85
+ :base_package,
86
+ :base_folder,
87
+ :command_controller_name
88
+
89
+ attr_reader :belongs_tos,
90
+ :has_manies,
91
+ :has_ones
92
+
93
+ attr_reader :controller_name,
94
+ :controller_class_path,
95
+ :controller_file_path,
96
+ :controller_class_nesting,
97
+ :controller_class_nesting_depth,
98
+ :controller_class_name,
99
+ :controller_underscore_name,
100
+ :controller_singular_name,
101
+ :controller_plural_name
102
+
103
+ attr_accessor :constructor_args
104
+
105
+ alias_method :controller_file_name, :controller_underscore_name
106
+ alias_method :controller_table_name, :controller_plural_name
107
+
108
+ def initialize(runtime_args, runtime_options = {})
109
+ super
110
+ @project_name, @flex_project_name, @command_controller_name, @base_package, @base_folder = extract_names
111
+ @controller_name = @name.pluralize
112
+
113
+ base_name, @controller_class_path, @controller_file_path, @controller_class_nesting,
114
+ @controller_class_nesting_depth = extract_modules(@controller_name)
115
+ @controller_class_name_without_nesting, @controller_underscore_name, @controller_plural_name = inflect_names(base_name)
116
+
117
+ @controller_singular_name=base_name.singularize
118
+ if @controller_class_nesting.empty?
119
+ @controller_class_name = @controller_class_name_without_nesting
120
+ else
121
+ @controller_class_name = "#{@controller_class_nesting}::#{@controller_class_name_without_nesting}"
122
+ end
123
+
124
+ @belongs_tos = []
125
+ @has_ones = []
126
+ @has_manies = []
127
+ # Figure out has_one, has_many and belongs_to based on args
128
+ @args.each do |arg|
129
+ if arg =~ /^has_one:/
130
+ # arg = "has_one:arg1,arg2", so all the has_one are together
131
+ @has_ones = arg.split(':')[1].split(',')
132
+ elsif arg =~ /^has_many:/
133
+ # arg = "has_many:arg1,arg2", so all the has_many are together
134
+ @has_manies = arg.split(":")[1].split(",")
135
+ elsif arg =~ /^belongs_to:/ # belongs_to:arg1,arg2
136
+ @belongs_tos = arg.split(":")[1].split(',')
137
+ end
138
+ end
139
+
140
+ # Remove the has_one and has_many arguments since they are
141
+ # not for consumption by the scaffold generator, and since
142
+ # we have already used them to set the @belongs_tos, @has_ones and
143
+ # @has_manies.
144
+ @args.delete_if { |elt| elt =~ /^(has_one|has_many|belongs_to):/ }
145
+ end
146
+
147
+ def manifest
148
+ record do |m|
149
+ m.dependency 'scaffold', [name] + @args, :skip_migration => true, :collision => :skip unless options[:flex_only]
150
+
151
+ # Generate Flex AS model and MXML component based on the
152
+ # Ruboss templates.
153
+ m.template 'model.as.erb',
154
+ File.join("app", "flex", base_folder, "models", "#{@class_name}.as"),
155
+ :assigns => { :resource_controller_name => "#{file_name.pluralize}" }
156
+
157
+ m.template 'component.mxml.erb',
158
+ File.join("app", "flex", base_folder, "components", "generated", "#{@class_name}Box.mxml"),
159
+ :assigns => { :resource_controller_name => "#{file_name.pluralize}" }
160
+
161
+ m.template 'controller.rb.erb', File.join("app/controllers", controller_class_path,
162
+ "#{controller_file_name}_controller.rb"), :collision => :force unless options[:flex_only]
163
+
164
+ # Create a new generated ActiveRecord model based on the Ruboss templates.
165
+ m.template 'model.rb.erb', File.join("app", "models", "#{file_name}.rb"),
166
+ :collision => :force unless options[:flex_only]
167
+
168
+ unless options[:skip_fixture]
169
+ m.template 'fixtures.yml.erb', File.join("test", "fixtures", "#{table_name}.yml"),
170
+ :collision => :force unless options[:flex_only]
171
+ end
172
+
173
+ unless options[:skip_migration]
174
+ m.directory 'schema/migration'
175
+ m.migration_template 'migration.rb.erb', 'db/migrate', :assigns => {
176
+ :migration_name => "Create#{class_name.pluralize.gsub(/::/, '')}"
177
+ }, :migration_file_name => "create_#{file_path.gsub(/\//, '_').pluralize}" unless options[:flex_only]
178
+ end
179
+
180
+ # Run the rcontroller generator to clobber the
181
+ # RubossCommandController subclass to include the new models.
182
+ m.dependency 'ruboss_controller', [name] + @args, :collision => :force
183
+ end
184
+ end
185
+
186
+ protected
187
+ def add_options!(opt)
188
+ opt.separator ''
189
+ opt.separator 'Options:'
190
+ opt.on("-f", "--flex-only", "Scaffold Flex code only",
191
+ "Default: false") { |v| options[:flex_only] = v}
192
+ end
193
+ end
@@ -0,0 +1,148 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" label="<%= class_name %>"
3
+ xmlns:rcomponents="org.ruboss.components.*">
4
+ <mx:Script><![CDATA[
5
+ import org.ruboss.Ruboss;
6
+ import org.ruboss.utils.RubossUtils;
7
+ import <%= base_package %>.models.<%= class_name %>;
8
+ <% for model in belongs_tos -%>
9
+ import <%= base_package %>.models.<%= model.camelcase %>;
10
+ <% end -%>
11
+
12
+ [Bindable]
13
+ private var _<%= class_name.downcase_first_letter %>:<%= class_name %> = new <%= class_name %>();
14
+
15
+ private function new<%= class_name %>():void {
16
+ _<%= class_name.downcase_first_letter %> = new <%= class_name %>();
17
+ <%= class_name.downcase_first_letter.pluralize %>List.selectedIndex = -1;
18
+ }
19
+
20
+ private function save<%= class_name %>():void {
21
+ if (_<%= class_name.downcase_first_letter %>.id) {
22
+ update<%= class_name %>();
23
+ } else {
24
+ create<%= class_name %>();
25
+ }
26
+ }
27
+
28
+ private function create<%= class_name %>():void {
29
+ var <%= class_name.downcase_first_letter %>:<%= class_name %> = new <%= class_name %>();
30
+ <% for attribute in attributes -%>
31
+ <% if attribute.type == :boolean -%>
32
+ <%= class_name.downcase_first_letter %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>CheckBox.selected;
33
+ <% elsif attribute.type == :string -%>
34
+ <%= class_name.downcase_first_letter %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>TextInput.text;
35
+ <% elsif attribute.type == :text -%>
36
+ <%= class_name.downcase_first_letter %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>TextArea.text;
37
+ <% elsif attribute.type == :datetime || attribute.type == :time -%>
38
+ <%= class_name.downcase_first_letter %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>DateTimeTextInput.date;
39
+ <% elsif attribute.type == :date -%>
40
+ <%= class_name.downcase_first_letter %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>DateField.selectedDate;
41
+ <% else -%>
42
+ <%= class_name.downcase_first_letter %>.<%= attribute.flex_name %> = <%= attribute.flex_type %>(<%= attribute.flex_name %>TextInput.text);
43
+ <% end -%>
44
+ <% end -%>
45
+
46
+ <% for model in belongs_tos -%>
47
+ <%= class_name.downcase_first_letter %>.<%= model.camelcase(:lower) %> = <%= model.camelcase %>(<%= model.camelcase(:lower) %>ComboBox.selectedItem);
48
+ <% end -%>
49
+ <%= class_name.downcase_first_letter %>.create({afterCallback: on<%= class_name %>Create});
50
+ }
51
+
52
+ private function update<%= class_name %>():void {
53
+ <% for attribute in attributes -%>
54
+ <% if attribute.type == :boolean -%>
55
+ _<%= class_name.downcase_first_letter %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>CheckBox.selected;
56
+ <% elsif attribute.type == :string -%>
57
+ _<%= class_name.downcase_first_letter %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>TextInput.text;
58
+ <% elsif attribute.type == :text -%>
59
+ _<%= class_name.downcase_first_letter %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>TextArea.text;
60
+ <% elsif attribute.type == :datetime || attribute.type == :time -%>
61
+ _<%= class_name.downcase_first_letter %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>DateTimeTextInput.date;
62
+ <% elsif attribute.type == :date -%>
63
+ _<%= class_name.downcase_first_letter %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>DateField.selectedDate;
64
+ <% else -%>
65
+ _<%= class_name.downcase_first_letter %>.<%= attribute.flex_name %> = <%= attribute.flex_type %>(<%= attribute.flex_name %>TextInput.text);
66
+ <% end -%>
67
+ <% end -%>
68
+
69
+ <% for model in belongs_tos -%>
70
+ _<%= class_name.downcase_first_letter %>.<%= model.camelcase(:lower) %> = <%= model.camelcase %>(<%= model.camelcase(:lower) %>ComboBox.selectedItem);
71
+ <% end -%>
72
+ _<%= class_name.downcase_first_letter %>.update({afterCallback: on<%= class_name %>Update});
73
+ }
74
+
75
+ private function destroy<%= class_name %>():void {
76
+ _<%= class_name.downcase_first_letter %>.destroy({afterCallback: on<%= class_name %>Destroy});
77
+ }
78
+
79
+ private function on<%= class_name %>Select():void {
80
+ _<%= class_name.downcase_first_letter %> = RubossUtils.clone(<%= class_name.downcase_first_letter.pluralize %>List.selectedItem) as <%= class_name %>;
81
+ }
82
+
83
+ private function on<%= class_name %>Create(<%= class_name.downcase_first_letter %>:<%= class_name %>):void {
84
+ _<%= class_name.downcase_first_letter %> = new <%= class_name %>;
85
+ }
86
+
87
+ private function on<%= class_name %>Update(<%= class_name.downcase_first_letter %>:<%= class_name %>):void {
88
+ <%= class_name.downcase_first_letter.pluralize %>List.selectedItem = <%= class_name.downcase_first_letter %>;
89
+ _<%= class_name.downcase_first_letter %> = RubossUtils.clone(<%= class_name.downcase_first_letter %>) as <%= class_name %>;
90
+ }
91
+
92
+ private function on<%= class_name %>Destroy(<%= class_name.downcase_first_letter %>:<%= class_name %>):void {
93
+ on<%= class_name %>Create(<%= class_name.downcase_first_letter %>);
94
+ }
95
+
96
+ private function canDelete<%= class_name %>(<%= class_name.downcase_first_letter %>:<%= class_name %>):Boolean {
97
+ return <%= class_name.downcase_first_letter %> != null && <%= class_name.downcase_first_letter %>.id != 0;
98
+ }
99
+ ]]></mx:Script>
100
+ <mx:Panel id="<%= class_name.downcase_first_letter.pluralize %>Panel"
101
+ title="<%= class_name.pluralize %>"
102
+ width="25%" height="100%">
103
+ <mx:List id="<%= class_name.downcase_first_letter.pluralize %>List"
104
+ width="100%" height="100%"
105
+ dataProvider="{Ruboss.models.index(<%= class_name %>)}"
106
+ change="on<%= class_name %>Select()"/>
107
+ <mx:ControlBar width="100%">
108
+ <mx:Button label="New <%= class_name %>" width="100%" height="30"
109
+ click="new<%= class_name %>()"/>
110
+ </mx:ControlBar>
111
+ </mx:Panel>
112
+ <mx:Panel title="Edit <%= class_name %>" width="75%" height="100%">
113
+ <mx:Form width="100%" height="100%">
114
+ <% for attribute in attributes -%>
115
+ <mx:FormItem label="<%= attribute.flex_name.capitalize_without_downcasing %>" width="100%">
116
+ <% if attribute.type == :boolean -%>
117
+ <mx:CheckBox id="<%= attribute.flex_name %>CheckBox" selected="{_<%= class_name.downcase_first_letter %>.<%= attribute.flex_name %>}"/>
118
+ <% elsif attribute.type == :string -%>
119
+ <mx:TextInput id="<%= attribute.flex_name %>TextInput" width="100%" text="{_<%= class_name.downcase_first_letter %>.<%= attribute.flex_name %>}"/>
120
+ <% elsif attribute.type == :text -%>
121
+ <mx:TextArea id="<%= attribute.flex_name %>TextArea" width="100%" height="200" text="{_<%= class_name.downcase_first_letter %>.<%= attribute.flex_name %>}"/>
122
+ <% elsif attribute.type == :datetime || attribute.type == :time -%>
123
+ <rcomponents:DateTimeTextInput id="<%= attribute.flex_name %>DateTimeTextInput" width="200" date="{_<%= class_name.downcase_first_letter %>.<%= attribute.flex_name %>}"/>
124
+ <% elsif attribute.type == :date -%>
125
+ <mx:DateField id="<%= attribute.flex_name %>DateField" selectedDate="{_<%= class_name.downcase_first_letter %>.<%= attribute.flex_name %>}"/>
126
+ <% else -%>
127
+ <mx:TextInput id="<%= attribute.flex_name %>TextInput" width="100%" text="{_<%= class_name.downcase_first_letter %>.<%= attribute.flex_name %>}"/>
128
+ <% end -%>
129
+ </mx:FormItem>
130
+ <% end -%>
131
+ <% for model in belongs_tos -%>
132
+ <mx:FormItem label="<%= model.camelcase %>" width="100%">
133
+ <mx:ComboBox id="<%= model.camelcase(:lower) %>ComboBox" width="200"
134
+ labelField="{<%= model.camelcase %>.LABEL}"
135
+ dataProvider="{Ruboss.models.index(<%= model.camelcase %>)}" prompt="<%= model.camelcase %> ..."
136
+ selectedItem="{_<%= class_name.downcase_first_letter %>.<%= model.camelcase(:lower) %>}" />
137
+ </mx:FormItem>
138
+ <% end -%>
139
+ </mx:Form>
140
+ <mx:ControlBar width="100%">
141
+ <mx:Button label="Save <%= class_name %>" width="50%" height="30"
142
+ click="save<%= class_name %>()"/>
143
+ <mx:Button label="Delete <%= class_name %>" width="50%" height="30"
144
+ enabled="{canDelete<%= class_name %>(_<%= class_name.downcase_first_letter %>)}"
145
+ click="destroy<%= class_name %>()"/>
146
+ </mx:ControlBar>
147
+ </mx:Panel>
148
+ </mx:HBox>
@@ -0,0 +1,97 @@
1
+ class <%= controller_class_name %>Controller < ApplicationController
2
+ # GET /<%= table_name %>
3
+ # GET /<%= table_name %>.xml
4
+ # GET /<%= table_name %>.fxml
5
+ def index
6
+ @<%= table_name %> = <%= class_name %>.find(:all)
7
+
8
+ respond_to do |format|
9
+ format.html # index.html.erb
10
+ format.xml { render :xml => @<%= table_name %> }
11
+ format.fxml { render :fxml => @<%= table_name %> }
12
+ end
13
+ end
14
+
15
+ # GET /<%= table_name %>/1
16
+ # GET /<%= table_name %>/1.xml
17
+ # GET /<%= table_name %>/1.fxml
18
+ def show
19
+ @<%= file_name %> = <%= class_name %>.find(params[:id])
20
+
21
+ respond_to do |format|
22
+ format.html # show.html.erb
23
+ format.xml { render :xml => @<%= file_name %> }
24
+ format.fxml { render :fxml => @<%= file_name %> }
25
+ end
26
+ end
27
+
28
+ # GET /<%= table_name %>/new
29
+ # GET /<%= table_name %>/new.xml
30
+ def new
31
+ @<%= file_name %> = <%= class_name %>.new
32
+
33
+ respond_to do |format|
34
+ format.html # new.html.erb
35
+ format.xml { render :xml => @<%= file_name %> }
36
+ end
37
+ end
38
+
39
+ # GET /<%= table_name %>/1/edit
40
+ def edit
41
+ @<%= file_name %> = <%= class_name %>.find(params[:id])
42
+ end
43
+
44
+ # POST /<%= table_name %>
45
+ # POST /<%= table_name %>.xml
46
+ # POST /<%= table_name %>.fxml
47
+ def create
48
+ @<%= file_name %> = <%= class_name %>.new(params[:<%= file_name %>])
49
+
50
+ respond_to do |format|
51
+ if @<%= file_name %>.save
52
+ flash[:notice] = '<%= class_name %> was successfully created.'
53
+ format.html { redirect_to(@<%= file_name %>) }
54
+ format.xml { render :xml => @<%= file_name %>, :status => :created, :location => @<%= file_name %> }
55
+ format.fxml { render :fxml => @<%= file_name %> }
56
+ else
57
+ format.html { render :action => "new" }
58
+ format.xml { render :xml => @<%= file_name %>.errors, :status => :unprocessable_entity }
59
+ format.fxml { render :fxml => @<%= file_name %>.errors }
60
+ end
61
+ end
62
+ end
63
+
64
+ # PUT /<%= table_name %>/1
65
+ # PUT /<%= table_name %>/1.xml
66
+ # PUT /<%= table_name %>/1.fxml
67
+ def update
68
+ @<%= file_name %> = <%= class_name %>.find(params[:id])
69
+
70
+ respond_to do |format|
71
+ if @<%= file_name %>.update_attributes(params[:<%= file_name %>])
72
+ flash[:notice] = '<%= class_name %> was successfully updated.'
73
+ format.html { redirect_to(@<%= file_name %>) }
74
+ format.xml { head :ok }
75
+ format.fxml { render :fxml => @<%= file_name %> }
76
+ else
77
+ format.html { render :action => "edit" }
78
+ format.xml { render :xml => @<%= file_name %>.errors, :status => :unprocessable_entity }
79
+ format.fxml { render :fxml => @<%= file_name %>.errors }
80
+ end
81
+ end
82
+ end
83
+
84
+ # DELETE /<%= table_name %>/1
85
+ # DELETE /<%= table_name %>/1.xml
86
+ # DELETE /<%= table_name %>/1.fxml
87
+ def destroy
88
+ @<%= file_name %> = <%= class_name %>.find(params[:id])
89
+ @<%= file_name %>.destroy
90
+
91
+ respond_to do |format|
92
+ format.html { redirect_to(<%= table_name %>_url) }
93
+ format.xml { head :ok }
94
+ format.fxml { render :fxml => @<%= file_name %> }
95
+ end
96
+ end
97
+ end