ruboss4ruby 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. data/History.txt +3 -0
  2. data/Manifest.txt +102 -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/ruboss4ruby/active_foo.rb +127 -0
  9. data/lib/ruboss4ruby/active_record_tasks.rb +75 -0
  10. data/lib/ruboss4ruby/configuration.rb +38 -0
  11. data/lib/ruboss4ruby/tasks.rb +81 -0
  12. data/lib/ruboss4ruby/version.rb +11 -0
  13. data/lib/ruboss4ruby.rb +61 -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 +189 -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 +127 -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.yml +16 -0
  66. data/rails_generators/ruboss_config/templates/ruboss_tasks.rake +15 -0
  67. data/rails_generators/ruboss_config/templates/swfobject.js +5 -0
  68. data/rails_generators/ruboss_controller/USAGE +11 -0
  69. data/rails_generators/ruboss_controller/ruboss_controller_generator.rb +46 -0
  70. data/rails_generators/ruboss_controller/templates/controller.as.erb +35 -0
  71. data/rails_generators/ruboss_scaffold/USAGE +35 -0
  72. data/rails_generators/ruboss_scaffold/ruboss_scaffold_generator.rb +192 -0
  73. data/rails_generators/ruboss_scaffold/templates/component.mxml.erb +148 -0
  74. data/rails_generators/ruboss_scaffold/templates/controller.rb.erb +97 -0
  75. data/rails_generators/ruboss_scaffold/templates/fixtures.yml.erb +35 -0
  76. data/rails_generators/ruboss_scaffold/templates/migration.rb.erb +19 -0
  77. data/rails_generators/ruboss_scaffold/templates/model.as.erb +42 -0
  78. data/rails_generators/ruboss_scaffold/templates/model.rb.erb +11 -0
  79. data/rails_generators/ruboss_yaml_scaffold/USAGE +14 -0
  80. data/rails_generators/ruboss_yaml_scaffold/ruboss_yaml_scaffold_generator.rb +45 -0
  81. data/rcl-1.0.txt +0 -0
  82. data/script/console +10 -0
  83. data/script/destroy +14 -0
  84. data/script/generate +14 -0
  85. data/script/txt2html +82 -0
  86. data/setup.rb +1585 -0
  87. data/tasks/deployment.rake +34 -0
  88. data/tasks/environment.rake +7 -0
  89. data/tasks/website.rake +17 -0
  90. data/test/active_foo_test.rb +16 -0
  91. data/test/test_generator_helper.rb +29 -0
  92. data/test/test_helper.rb +2 -0
  93. data/test/test_ruboss_config_generator.rb +45 -0
  94. data/test/test_ruboss_controller_generator.rb +45 -0
  95. data/test/test_ruboss_on_ruby.rb +11 -0
  96. data/test/test_ruboss_scaffold_generator.rb +45 -0
  97. data/test/test_ruboss_yaml_scaffold_generator.rb +46 -0
  98. data/website/index.html +63 -0
  99. data/website/index.txt +34 -0
  100. data/website/javascripts/rounded_corners_lite.inc.js +285 -0
  101. data/website/stylesheets/screen.css +138 -0
  102. data/website/template.html.erb +47 -0
  103. metadata +167 -0
@@ -0,0 +1,189 @@
1
+ require 'ruboss4ruby/configuration'
2
+
3
+ module Ruboss
4
+ module Generator
5
+ class GeneratedAttribute
6
+ attr_accessor :name, :type, :flex_name
7
+
8
+ def initialize(name, type)
9
+ @name, @type = name, type.to_sym
10
+ @flex_name = name.camelcase(:lower)
11
+ end
12
+
13
+ def field_type
14
+ @field_type ||= case type
15
+ when :integer, :float, :decimal then :text_field
16
+ when :datetime, :timestamp, :time then :datetime_select
17
+ when :date then :date_select
18
+ when :string then :text_field
19
+ when :text then :text_area
20
+ when :boolean then :check_box
21
+ else
22
+ :text_field
23
+ end
24
+ end
25
+
26
+ def default(prefix = '')
27
+ @default = case type
28
+ when :integer then 1
29
+ when :float then 1.5
30
+ when :decimal then "9.99"
31
+ when :datetime, :timestamp, :time then Time.now.to_s(:db)
32
+ when :date then Date.today.to_s(:db)
33
+ when :string then prefix + name.camelize + "String"
34
+ when :text then prefix + name.camelize + "Text"
35
+ when :boolean then false
36
+ else
37
+ ""
38
+ end
39
+ end
40
+
41
+ def flex_type
42
+ @flex_type = case type
43
+ when :integer then 'int'
44
+ when :date, :datetime, :time then 'Date'
45
+ when :boolean then 'Boolean'
46
+ when :float, :decimal then 'Number'
47
+ else
48
+ 'String'
49
+ end
50
+ end
51
+
52
+ def flex_default(prefix = '')
53
+ @flex_default = case type
54
+ when :integer, :float, :decimal then '0'
55
+ when :string, :text then '""'
56
+ when :boolean then 'false'
57
+ else
58
+ 'null'
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+
65
+ class RubossScaffoldGenerator < Merb::GeneratorBase
66
+ include Ruboss::Configuration
67
+
68
+ attr_reader :class_name,
69
+ :file_name,
70
+ :table_name,
71
+ :provided_args,
72
+ :actual_args
73
+
74
+ attr_reader :project_name,
75
+ :flex_project_name,
76
+ :base_package,
77
+ :base_folder,
78
+ :command_controller_name
79
+
80
+ attr_reader :belongs_tos,
81
+ :has_manies,
82
+ :has_ones
83
+
84
+ def initialize(runtime_args, runtime_options = {})
85
+ @base = File.dirname(__FILE__)
86
+ super
87
+ @project_name, @flex_project_name, @command_controller_name, @base_package, @base_folder = extract_names
88
+
89
+ @actual_args = runtime_args
90
+ @provided_args = runtime_args.dup
91
+ @file_name = actual_args.shift.snake_case
92
+ @table_name = @file_name.pluralize
93
+ @class_name = @file_name.to_const_string
94
+
95
+ @belongs_tos = []
96
+ @has_ones = []
97
+ @has_manies = []
98
+ # Figure out has_one, has_many and belongs_to based on args
99
+ @args.each do |arg|
100
+ if arg =~ /^has_one:/
101
+ # arg = "has_one:arg1,arg2", so all the has_one are together
102
+ @has_ones = arg.split(':')[1].split(',')
103
+ elsif arg =~ /^has_many:/
104
+ # arg = "has_many:arg1,arg2", so all the has_many are together
105
+ @has_manies = arg.split(":")[1].split(",")
106
+ elsif arg =~ /^belongs_to:/ # belongs_to:arg1,arg2
107
+ @belongs_tos = arg.split(":")[1].split(',')
108
+ end
109
+ end
110
+
111
+ # Remove the has_one and has_many arguments since they are
112
+ # not for consumption by the scaffold generator, and since
113
+ # we have already used them to set the @belongs_tos, @has_ones and
114
+ # @has_manies.
115
+ @actual_args.delete_if { |elt| elt =~ /^(has_one|has_many|belongs_to):/ }
116
+ @provided_args.delete_if { |elt| elt =~ /^(has_one|has_many|belongs_to):/ }
117
+ end
118
+
119
+ def manifest
120
+ record do |m|
121
+ @m = m
122
+
123
+ #singularize the model & pluralize the name of the controller
124
+ model_args = provided_args.dup
125
+ controller_args = provided_args.dup
126
+
127
+ # normalize the model_args
128
+ model_args[0] = model_args.first.snake_case.gsub("::", "/").split("/").last.singularize
129
+
130
+ controller_args[0] = controller_args.first.pluralize
131
+
132
+ m.dependency "ruboss_resource_controller", controller_args, options.dup
133
+
134
+ # # Create a new generated ActiveRecord model based on the Ruboss templates.
135
+ m.directory 'app/models'
136
+ m.template 'model.rb.erb', File.join("app", "models", "#{@file_name}.rb"),
137
+ :collision => :force unless options[:flex_only]
138
+
139
+ unless options[:skip_fixture]
140
+ m.directory 'spec/fixtures'
141
+ m.template 'fixtures.yml.erb', File.join("spec", "fixtures", "#{@table_name}.yml"),
142
+ :collision => :force unless options[:flex_only]
143
+ end
144
+
145
+ unless options[:skip_migration]
146
+ m.directory 'schema/migrations'
147
+ current_migration_number = Dir[Dir.pwd+'/schema/migrations/*'].map{|f| File.basename(f) =~ /^(\d+)/; $1}.max
148
+ migration_file_name = format("%03d_%s", (current_migration_number.to_i+1), file_name) + "_migration"
149
+ m.template 'migration.rb.erb', "schema/migrations/#{migration_file_name}.rb", :assigns => {
150
+ :migration_name => "#{@class_name}Migration"
151
+ } unless options[:flex_only]
152
+ end
153
+
154
+ m.dependency "merb_model_test", [@file_name], { :model_file_name => @file_name, :model_class_name => @class_name }
155
+
156
+ # Generate Flex AS model and MXML component based on the
157
+ # Ruboss templates.
158
+ m.template 'model.as.erb',
159
+ File.join("app", "flex", base_folder, "models", "#{@class_name}.as"),
160
+ :assigns => { :resource_controller_name => "#{@table_name}" }
161
+
162
+ m.template 'component.mxml.erb',
163
+ File.join("app", "flex", base_folder, "components", "generated", "#{@class_name}Box.mxml"),
164
+ :assigns => { :resource_controller_name => "#{@table_name}" }
165
+
166
+ # Run the rcontroller generator to clobber the
167
+ # RubossCommandController subclass to include the new models.
168
+ m.dependency 'ruboss_controller', [], :collision => :force
169
+ end
170
+ end
171
+
172
+ protected
173
+ def attributes
174
+ @attributes ||= @args.collect do |attribute|
175
+ Ruboss::Generator::GeneratedAttribute.new(*attribute.split(":"))
176
+ end
177
+ end
178
+
179
+ def add_options!(opt)
180
+ opt.separator ''
181
+ opt.separator 'Options:'
182
+ opt.on("-f", "--flex-only", "Scaffold Flex code only",
183
+ "Default: false") { |v| options[:flex_only] = v}
184
+ end
185
+
186
+ def banner
187
+ "Usage: #{$0} #{spec.name}"
188
+ end
189
+ 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,35 @@
1
+ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
+
3
+ <% unless attributes.empty? && belongs_tos.empty? -%>
4
+ <%= class_name.underscore -%>_one:
5
+ <% for attribute in attributes -%>
6
+ <%= attribute.name %>: <%= attribute.default("#{class_name}1") %>
7
+ <% end -%>
8
+ <% for model in belongs_tos -%>
9
+ <%= model %>: <%= model %>_one
10
+ <% end -%>
11
+
12
+ <%= class_name.underscore -%>_two:
13
+ <% for attribute in attributes -%>
14
+ <%= attribute.name %>: <%= attribute.default("#{class_name}2") %>
15
+ <% end -%>
16
+ <% for model in belongs_tos -%>
17
+ <%= model %>: <%= model %>_two
18
+ <% end -%>
19
+
20
+ <%= class_name.underscore -%>_three:
21
+ <% for attribute in attributes -%>
22
+ <%= attribute.name %>: <%= attribute.default("#{class_name}3") %>
23
+ <% end -%>
24
+ <% for model in belongs_tos -%>
25
+ <%= model %>: <%= model %>_three
26
+ <% end -%>
27
+
28
+ <%= class_name.underscore -%>_four:
29
+ <% for attribute in attributes -%>
30
+ <%= attribute.name %>: <%= attribute.default("#{class_name}4") %>
31
+ <% end -%>
32
+ <% for model in belongs_tos -%>
33
+ <%= model %>: <%= model %>_four
34
+ <% end -%>
35
+ <% end -%>
@@ -0,0 +1,19 @@
1
+ class <%= migration_name %> < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :<%= table_name %> do |t|
4
+ <% for attribute in attributes -%>
5
+ t.<%= attribute.type %> :<%= attribute.name %>
6
+ <% end -%>
7
+ <% for model in belongs_tos -%>
8
+ t.references :<%= model %>
9
+ <% end -%>
10
+ <% unless options[:skip_timestamps] %>
11
+ t.timestamps
12
+ <% end -%>
13
+ end
14
+ end
15
+
16
+ def self.down
17
+ drop_table :<%= table_name %>
18
+ end
19
+ end
@@ -0,0 +1,42 @@
1
+ package <%= base_package %>.models {
2
+ <% if has_manies.length > 0 -%>
3
+ import org.ruboss.models.ModelsCollection;
4
+ <% end -%>
5
+ import org.ruboss.models.RubossModel;
6
+
7
+ [Resource(name="<%= resource_controller_name %>")]
8
+ [Bindable]
9
+ public class <%= class_name %> extends RubossModel {
10
+ <% if attributes && !attributes.empty? && attributes[0].flex_type != "Boolean" -%>
11
+ public static const LABEL:String = "<%= attributes[0].flex_name %>";
12
+ <% else -%>
13
+ public static const LABEL:String = "id";
14
+ <% end -%>
15
+
16
+ <% for attribute in attributes -%>
17
+ <% if attribute.type == :datetime || attribute.type == :time -%>
18
+ [DateTime]
19
+ <% end -%>
20
+ public var <%= attribute.flex_name %>:<%= attribute.flex_type %>;
21
+
22
+ <% end -%>
23
+ <% for model in belongs_tos -%>
24
+ [BelongsTo]
25
+ public var <%= model.camelcase(:lower) %>:<%= model.camelcase %>;
26
+
27
+ <% end -%>
28
+ <% for model in has_ones -%>
29
+ [HasOne]
30
+ public var <%= model.camelcase(:lower) %>:<%= model.camelcase %>;
31
+
32
+ <% end -%>
33
+ <% for model in has_manies -%>
34
+ [HasMany]
35
+ public var <%= model.camelcase(:lower) %>:ModelsCollection;
36
+
37
+ <% end -%>
38
+ public function <%= class_name %>() {
39
+ super(LABEL);
40
+ }
41
+ }
42
+ }
@@ -0,0 +1,11 @@
1
+ class <%= class_name %> < ActiveRecord::Base
2
+ <% for model in belongs_tos -%>
3
+ belongs_to :<%= model %>
4
+ <% end -%>
5
+ <% for model in has_ones -%>
6
+ has_one :<%= model %>
7
+ <% end -%>
8
+ <% for model in has_manies -%>
9
+ has_many :<%= model %>
10
+ <% end -%>
11
+ end
@@ -0,0 +1,5 @@
1
+ Description:
2
+
3
+
4
+ Usage:
5
+
@@ -0,0 +1,53 @@
1
+ require 'yaml'
2
+ require 'ruboss4ruby/configuration'
3
+
4
+ class RubossYamlScaffoldGenerator < Merb::GeneratorBase
5
+ include Ruboss::Configuration
6
+
7
+ def initialize(runtime_args, runtime_options = {})
8
+ runtime_args.push ""
9
+ super
10
+ end
11
+
12
+ def extract_attrs(line, attrs)
13
+ attrs.each do |key,value|
14
+ if value.class == Array
15
+ line << " #{key}:#{value.join(',')}"
16
+ else
17
+ line << " #{key}:#{value}"
18
+ end
19
+ end
20
+ line
21
+ end
22
+
23
+ def manifest
24
+ record do |m|
25
+ models = YAML.load(File.open(File.join(APP_ROOT, 'schema/model.yml'), 'r'))
26
+ models.each do |model|
27
+ line = ""
28
+ attrs = model[1]
29
+ if attrs.class == Array
30
+ attrs.each do |elm|
31
+ line = extract_attrs(line, elm)
32
+ end
33
+ else
34
+ line = extract_attrs(line, attrs)
35
+ end
36
+ line = model[0].camelcase + " " + line
37
+ line = '--flex-only ' + line if ARGV.include?('flexonly')
38
+ puts 'running: ruboss_scaffold ' + line
39
+ Merb::ComponentGenerator.run "ruboss_scaffold", line.split(" "), "ruboss_scaffold", "generate"
40
+ puts 'done ...'
41
+ sleep 1
42
+ end
43
+ config_args = ['--main-only']
44
+ config_args << '--skip-framework' if ARGV.include?('skipframework')
45
+ Merb::ComponentGenerator.run "ruboss_config", config_args, "ruboss_config", "generate"
46
+ end
47
+ end
48
+
49
+ protected
50
+ def banner
51
+ "Usage: #{$0} #{spec.name}"
52
+ end
53
+ end
@@ -0,0 +1,18 @@
1
+ Description:
2
+ Generates the primary Ruboss directory structure, sets up Flex Builder
3
+ specific descriptor files and options fetches the latest published
4
+ Ruboss Framework SWC file.
5
+
6
+ You can generate Flex Builder configuration for either *pure* Flex
7
+ project or an AIR project. To generate AIR configuration pass the -a
8
+ (--air) option to the generator.
9
+
10
+ Examples:
11
+ `./script/generate ruboss_config` # generates project structure and a
12
+ # default Flex app configuration. Fetches
13
+ # latest ruboss framework SWC to "lib"
14
+ # folder
15
+ `./script/generate ruboss_config -a` # as above but generates an AIR app
16
+ # and configuration
17
+ `./script/generate ruboss_config -s` # generates Flex app but does not fetch
18
+ # the ruboss framework SWC.
@@ -0,0 +1,127 @@
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 'open-uri'
15
+ require 'ruboss4ruby/version'
16
+ require 'ruboss4ruby/configuration'
17
+
18
+ class RubossConfigGenerator < Rails::Generator::Base
19
+ include Ruboss::Configuration
20
+
21
+ attr_reader :project_name,
22
+ :flex_project_name,
23
+ :base_package,
24
+ :base_folder,
25
+ :command_controller_name,
26
+ :component_names,
27
+ :application_tag,
28
+ :use_air
29
+
30
+ def initialize(runtime_args, runtime_options = {})
31
+ super
32
+ @project_name, @flex_project_name, @command_controller_name, @base_package, @base_folder = extract_names
33
+
34
+ # if we are updating main file only we probably want to maintain the type of project it is
35
+ if options[:main_only]
36
+ project_file_name = APP_ROOT + '/.project'
37
+ if File.exist?(project_file_name)
38
+ puts "Cannot combine -m (--main-app) and -a (--air) flags at the same time for an existing application.\n" <<
39
+ 'If you want to convert to AIR, remove -m flag.' if options[:air_config]
40
+ @use_air = true if File.read(project_file_name) =~/com.adobe.flexbuilder.apollo.apollobuilder/m
41
+ else
42
+ puts "Flex Builder project file doesn't exist. You should run 'ruboss_config' with -a (--air) option " <<
43
+ "or no arguments first to generate primary project structure."
44
+ exit 0;
45
+ end
46
+ else
47
+ @use_air = options[:air_config]
48
+ end
49
+
50
+ if @use_air
51
+ @application_tag = 'WindowedApplication'
52
+ else
53
+ @application_tag = 'Application'
54
+ end
55
+
56
+ @component_names = []
57
+ if File.exists?("app/flex/#{base_folder}/components/generated")
58
+ @component_names = list_mxml_files("app/flex/#{base_folder}/components/generated")
59
+ end
60
+ end
61
+
62
+ def manifest
63
+ record do |m|
64
+ if !options[:main_only]
65
+ m.file 'ruboss_tasks.rake', 'lib/tasks/ruboss_tasks.rake'
66
+ m.file 'flex.properties', '.flexProperties'
67
+ m.file 'ruboss.yml', 'config/ruboss.yml'
68
+ if @use_air
69
+ m.template 'actionscriptair.properties', '.actionScriptProperties'
70
+ m.template 'projectair.properties', '.project'
71
+ else
72
+ m.template 'actionscript.properties', '.actionScriptProperties'
73
+ m.template 'project.properties', '.project'
74
+ end
75
+
76
+ m.directory 'html-template/history'
77
+ %w(index.template.html AC_OETags.js playerProductInstall.swf).each do |file|
78
+ m.file "html-template/#{file}", "html-template/#{file}"
79
+ end
80
+
81
+ %w(history.css history.js historyFrame.html).each do |file|
82
+ m.file "html-template/history/#{file}", "html-template/history/#{file}"
83
+ end
84
+
85
+ %w(components controllers commands models events).each do |dir|
86
+ m.directory "app/flex/#{base_folder}/#{dir}"
87
+ end
88
+
89
+ m.directory "app/flex/#{base_folder}/components/generated"
90
+
91
+ framework_release = Ruboss::RUBOSS_FRAMEWORK_VERSION
92
+ framework_distribution_url = "http://ruboss.com/releases/ruboss-#{framework_release}.swc"
93
+ framework_destination_file = "lib/ruboss-#{framework_release}.swc"
94
+
95
+ if !options[:skip_framework] && !File.exist?(framework_destination_file)
96
+ puts "fetching #{framework_release} framework binary from: #{framework_distribution_url} ..."
97
+ open(framework_destination_file, "wb").write(open(framework_distribution_url).read)
98
+ puts "done. saved to #{framework_destination_file}"
99
+ end
100
+
101
+ m.file 'swfobject.js', 'public/javascripts/swfobject.js'
102
+ m.file 'expressInstall.swf', 'public/expressInstall.swf'
103
+ m.template 'index.html.erb', 'public/index.html'
104
+
105
+ m.dependency 'ruboss_controller', @args
106
+ end
107
+ m.template 'mainapp.mxml', File.join('app/flex', "#{project_name}.mxml")
108
+ m.template 'mainair-app.xml', File.join('app/flex', "#{project_name}-app.xml") if @use_air
109
+ end
110
+ end
111
+
112
+ protected
113
+ def add_options!(opt)
114
+ opt.separator ''
115
+ opt.separator 'Options:'
116
+ opt.on("-m", "--main-only", "Only generate the main Flex/AIR application file.",
117
+ "Default: false") { |v| options[:main_only] = v }
118
+ opt.on("-a", "--air", "Configure AIR project instead of Flex. Flex is default.",
119
+ "Default: false") { |v| options[:air_config] = v }
120
+ opt.on("-s", "--skip-framework", "Don't fetch the latest framework binary. You'll have to link/build the framework yourself.",
121
+ "Default: false") { |v| options[:skip_framework] = v }
122
+ end
123
+
124
+ def banner
125
+ "Usage: #{$0} #{spec.name}"
126
+ end
127
+ end
@@ -0,0 +1,16 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <actionScriptProperties mainApplicationPath="<%= project_name %>.mxml" version="3">
3
+ <compiler additionalCompilerArguments="-locale en_US -keep-as3-metadata+=Resource,HasOne,HasMany,BelongsTo,DateTime,Lazy,Ignored" copyDependentFiles="true" enableModuleDebug="true" generateAccessible="false" htmlExpressInstall="true" htmlGenerate="true" htmlHistoryManagement="true" htmlPlayerVersion="9.0.28" htmlPlayerVersionCheck="true" outputFolderPath="public/bin" rootURL="http://localhost:3000/bin" sourceFolderPath="app/flex" strict="true" useApolloConfig="false" verifyDigests="true" warn="true">
4
+ <compilerSourcePath/>
5
+ <libraryPath defaultLinkType="1">
6
+ <libraryPathEntry kind="4" path=""/>
7
+ <libraryPathEntry kind="1" linkType="1" path="lib"/>
8
+ </libraryPath>
9
+ <sourceAttachmentPath/>
10
+ </compiler>
11
+ <applications>
12
+ <application path="<%= project_name %>.mxml"/>
13
+ </applications>
14
+ <modules/>
15
+ <buildCSSFiles/>
16
+ </actionScriptProperties>