ruboss4ruby 1.0.5 → 1.1.0

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 (155) hide show
  1. data/History.txt +2 -2
  2. data/Manifest.txt +86 -79
  3. data/README.rdoc +53 -0
  4. data/Rakefile +42 -5
  5. data/app_generators/ruboss_app/USAGE +22 -0
  6. data/app_generators/ruboss_app/ruboss_app_generator.rb +94 -0
  7. data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/actionscript.properties +1 -1
  8. data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/actionscriptair.properties +0 -0
  9. data/app_generators/ruboss_app/templates/app.yaml.erb +12 -0
  10. data/app_generators/ruboss_app/templates/default_tasks.rake +51 -0
  11. data/app_generators/ruboss_app/templates/empty.txt +0 -0
  12. data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/expressInstall.swf +0 -0
  13. data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/flex.properties +0 -0
  14. data/app_generators/ruboss_app/templates/generate.rb +17 -0
  15. data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/html-template/AC_OETags.js +0 -0
  16. data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/html-template/history/history.css +0 -0
  17. data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/html-template/history/history.js +0 -0
  18. data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/html-template/history/historyFrame.html +0 -0
  19. data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/html-template/index.template.html +0 -0
  20. data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/html-template/playerProductInstall.swf +0 -0
  21. data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/index.html.erb +2 -2
  22. data/app_generators/ruboss_app/templates/index.yaml +11 -0
  23. data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/mainair-app.xml +3 -3
  24. data/app_generators/ruboss_app/templates/mainapp-config.xml +21 -0
  25. data/{merb_generators/templates/ruboss_flex_app → app_generators/ruboss_app/templates}/mainapp.mxml +6 -9
  26. data/app_generators/ruboss_app/templates/project-textmate.erb +52 -0
  27. data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/project.properties +0 -0
  28. data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/projectair.properties +0 -0
  29. data/{merb_generators/templates/ruboss_config → app_generators/ruboss_app/templates}/swfobject.js +0 -0
  30. data/bin/ruboss-gen +31 -0
  31. data/generators/ruboss_config/USAGE +5 -0
  32. data/generators/ruboss_config/ruboss_config_generator.rb +19 -0
  33. data/generators/ruboss_controller/USAGE +10 -0
  34. data/generators/ruboss_controller/ruboss_controller_generator.rb +38 -0
  35. data/generators/ruboss_controller/templates/assist.py +65 -0
  36. data/{merb_generators/templates/ruboss_controller → generators/ruboss_controller/templates}/controller.as.erb +7 -6
  37. data/generators/ruboss_controller/templates/restful.py +136 -0
  38. data/generators/ruboss_main_app/USAGE +8 -0
  39. data/generators/ruboss_main_app/ruboss_main_app_generator.rb +60 -0
  40. data/generators/ruboss_main_app/templates/main.py.erb +29 -0
  41. data/generators/ruboss_main_app/templates/mainapp.mxml +35 -0
  42. data/generators/ruboss_scaffold/USAGE +29 -0
  43. data/generators/ruboss_scaffold/ruboss_scaffold_generator.rb +148 -0
  44. data/generators/ruboss_scaffold/templates/component.mxml.erb +149 -0
  45. data/generators/ruboss_scaffold/templates/controller.py.erb +27 -0
  46. data/generators/ruboss_scaffold/templates/model.as.erb +42 -0
  47. data/generators/ruboss_scaffold/templates/model.py.erb +14 -0
  48. data/generators/ruboss_yaml_scaffold/USAGE +45 -0
  49. data/generators/ruboss_yaml_scaffold/ruboss_yaml_scaffold_generator.rb +47 -0
  50. data/lib/ruboss4ruby/active_foo.rb +109 -86
  51. data/lib/ruboss4ruby/active_record_default_methods.rb +66 -0
  52. data/lib/ruboss4ruby/active_record_tasks.rb +10 -4
  53. data/lib/ruboss4ruby/configuration.rb +48 -34
  54. data/lib/ruboss4ruby/datamapper_foo.rb +31 -0
  55. data/lib/ruboss4ruby/{recipes.rb → rails/recipes.rb} +7 -9
  56. data/lib/ruboss4ruby/{ruboss_helper.rb → rails/swf_helper.rb} +14 -8
  57. data/lib/ruboss4ruby/tasks.rb +9 -4
  58. data/lib/ruboss4ruby.rb +72 -27
  59. data/rails_generators/ruboss_config/ruboss_config_generator.rb +3 -15
  60. data/rails_generators/ruboss_config/templates/mainair-app.xml +2 -2
  61. data/rails_generators/ruboss_config/templates/mainapp-config.xml +1 -1
  62. data/rails_generators/ruboss_config/templates/ruboss.yml +2 -4
  63. data/rails_generators/ruboss_config/templates/ruboss_tasks.rake +5 -15
  64. data/rails_generators/ruboss_controller/USAGE +1 -2
  65. data/rails_generators/ruboss_controller/ruboss_controller_generator.rb +3 -14
  66. data/rails_generators/ruboss_controller/templates/controller.as.erb +11 -6
  67. data/rails_generators/ruboss_scaffold/ruboss_scaffold_generator.rb +67 -76
  68. data/rails_generators/ruboss_scaffold/templates/component.mxml.erb +69 -69
  69. data/rails_generators/ruboss_scaffold/templates/model.as.erb +2 -2
  70. data/rails_generators/ruboss_yaml_scaffold/USAGE +38 -1
  71. data/rcl-1.0.txt +0 -0
  72. data/rdoc/generators/template/html/jamis.rb +588 -0
  73. data/ruboss4ruby.gemspec +43 -0
  74. data/spec/ruboss4ruby_spec.rb +7 -0
  75. data/spec/spec_helper.rb +16 -0
  76. data/tasks/ann.rake +80 -0
  77. data/tasks/bones.rake +20 -0
  78. data/tasks/gem.rake +201 -0
  79. data/tasks/git.rake +40 -0
  80. data/tasks/manifest.rake +48 -0
  81. data/tasks/notes.rake +27 -0
  82. data/tasks/post_load.rake +39 -0
  83. data/tasks/rdoc.rake +50 -0
  84. data/tasks/rubyforge.rake +55 -0
  85. data/tasks/setup.rb +279 -0
  86. data/tasks/spec.rake +54 -0
  87. data/tasks/svn.rake +47 -0
  88. data/tasks/test.rake +40 -0
  89. data/test/{controllers → rails/controllers}/application.rb +0 -0
  90. data/test/{controllers → rails/controllers}/locations_controller.rb +0 -0
  91. data/test/{controllers → rails/controllers}/notes_controller.rb +0 -0
  92. data/test/{controllers → rails/controllers}/projects_controller.rb +0 -0
  93. data/test/{controllers → rails/controllers}/tasks_controller.rb +0 -0
  94. data/test/{controllers → rails/controllers}/users_controller.rb +0 -0
  95. data/test/{database.yml → rails/database.yml} +0 -0
  96. data/test/{fixtures → rails/fixtures}/locations.yml +0 -0
  97. data/test/{fixtures → rails/fixtures}/notes.yml +0 -0
  98. data/test/{fixtures → rails/fixtures}/projects.yml +0 -0
  99. data/test/rails/fixtures/simple_properties.yml +19 -0
  100. data/test/{fixtures → rails/fixtures}/tasks.yml +0 -0
  101. data/test/{fixtures → rails/fixtures}/users.yml +0 -0
  102. data/test/{helpers → rails/helpers}/functional_test_helper.rb +0 -11
  103. data/test/rails/helpers/test_helper.rb +61 -0
  104. data/test/rails/helpers/unit_test_helper.rb +30 -0
  105. data/test/{model.yml → rails/model.yml} +0 -0
  106. data/test/{models → rails/models}/location.rb +0 -0
  107. data/test/{models → rails/models}/note.rb +0 -0
  108. data/test/{models → rails/models}/project.rb +1 -3
  109. data/test/rails/models/simple_property.rb +2 -0
  110. data/test/{models → rails/models}/task.rb +1 -1
  111. data/test/{models → rails/models}/user.rb +1 -2
  112. data/test/{playing_around_in_a_console.txt → rails/playing_around_in_a_console.txt} +0 -0
  113. data/test/{schema.rb → rails/schema.rb} +14 -0
  114. data/test/{test.swf → rails/test.swf} +0 -0
  115. data/test/rails/test_active_foo.rb +81 -0
  116. data/test/{test_ruboss_rails_integration_functional.rb → rails/test_ruboss_rails_integration_functional.rb} +4 -9
  117. data/test/{to_fxml_test.rb → rails/test_to_fxml.rb} +35 -37
  118. data/test/rails/test_to_json.rb +23 -0
  119. data/test/{views → rails/views}/notes/empty_params_action.html.erb +0 -0
  120. data/test/{views → rails/views}/notes/index.html.erb +0 -0
  121. metadata +138 -103
  122. data/Generators +0 -5
  123. data/README.txt +0 -37
  124. data/config/hoe.rb +0 -72
  125. data/config/requirements.rb +0 -15
  126. data/lib/ruboss4ruby/generated_attribute.rb +0 -61
  127. data/lib/ruboss4ruby/ruboss_test_helpers.rb +0 -31
  128. data/lib/ruboss4ruby/version.rb +0 -11
  129. data/merb_generators/ruboss_config.rb +0 -105
  130. data/merb_generators/ruboss_controller.rb +0 -61
  131. data/merb_generators/ruboss_flex_app.rb +0 -69
  132. data/merb_generators/ruboss_resource_controller.rb +0 -4
  133. data/merb_generators/ruboss_scaffold.rb +0 -158
  134. data/merb_generators/templates/ruboss_config/ruboss.yml +0 -16
  135. data/merb_generators/templates/ruboss_resource_controller/controller.rb.erb +0 -49
  136. data/script/console +0 -10
  137. data/script/destroy +0 -14
  138. data/script/generate +0 -14
  139. data/script/txt2html +0 -82
  140. data/setup.rb +0 -1585
  141. data/tasks/deployment.rake +0 -34
  142. data/tasks/environment.rake +0 -7
  143. data/tasks/website.rake +0 -17
  144. data/test/helpers/controllers.log +0 -8
  145. data/test/helpers/models.log +0 -170
  146. data/test/helpers/test_helper.rb +0 -25
  147. data/test/helpers/unit_test_helper.rb +0 -23
  148. data/test/test.sqlite3 +0 -0
  149. data/test/test_active_foo.rb +0 -79
  150. data/test/test_swfobject_helper.rb +0 -63
  151. data/website/index.html +0 -63
  152. data/website/index.txt +0 -34
  153. data/website/javascripts/rounded_corners_lite.inc.js +0 -285
  154. data/website/stylesheets/screen.css +0 -138
  155. data/website/template.html.erb +0 -47
@@ -0,0 +1,148 @@
1
+ module Ruboss4Ruby
2
+ module Generator
3
+ class GeneratedAttribute
4
+ attr_accessor :name, :type, :flex_name
5
+
6
+ def initialize(name, type)
7
+ @name, @type = name, type.to_sym
8
+ @flex_name = name.camelcase(:lower)
9
+ end
10
+
11
+ def flex_type
12
+ @flex_type = case type
13
+ when :integer then 'int'
14
+ when :date, :datetime, :time then 'Date'
15
+ when :boolean then 'Boolean'
16
+ when :float, :decimal then 'Number'
17
+ else
18
+ 'String'
19
+ end
20
+ end
21
+
22
+ def flex_default
23
+ @flex_default = case type
24
+ when :integer then '0'
25
+ when :date, :datetime, :time then 'new Date'
26
+ when :boolean then 'false'
27
+ when :float, :decimal then 'new Number'
28
+ else
29
+ "\"\""
30
+ end
31
+ end
32
+
33
+ def gae_type
34
+ @gae_type = case type
35
+ when :integer then 'IntegerProperty'
36
+ when :date then 'DateProperty'
37
+ when :time then 'TimeProperty'
38
+ when :datetime then 'DateTimeProperty'
39
+ when :boolean then 'BooleanProperty'
40
+ when :text then 'TextProperty'
41
+ when :float, :decimal then 'FloatProperty'
42
+ else
43
+ 'StringProperty'
44
+ end
45
+ end
46
+
47
+ def gae_default
48
+ @gae_default = case type
49
+ when :integer then 'default = 0'
50
+ when :date, :time, :datetime then 'auto_now_add = True'
51
+ when :boolean then 'default = False'
52
+ when :float, :decimal then 'default = 0.0'
53
+ else
54
+ ""
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+
61
+ class RubossScaffoldGenerator < RubiGen::Base
62
+ include Ruboss4Ruby::Configuration
63
+
64
+ attr_reader :project_name,
65
+ :flex_project_name,
66
+ :base_package,
67
+ :base_folder,
68
+ :command_controller_name
69
+
70
+ attr_reader :belongs_tos,
71
+ :has_manies,
72
+ :has_ones
73
+
74
+ attr_reader :name,
75
+ :class_name,
76
+ :file_name
77
+
78
+ def initialize(runtime_args, runtime_options = {})
79
+ super
80
+
81
+ # Name argument is required.
82
+ usage if runtime_args.empty?
83
+
84
+ @args = runtime_args.dup
85
+ @name = @args.shift
86
+ @file_name = @name.underscore
87
+ @class_name = @name.camelize
88
+
89
+ @project_name, @flex_project_name, @command_controller_name,
90
+ @base_package, @base_folder = extract_names
91
+ extract_relationships
92
+ end
93
+
94
+ def manifest
95
+ record do |m|
96
+ m.template 'model.as.erb',
97
+ File.join("app", 'flex', base_folder, "models", "#{@class_name}.as"),
98
+ :assigns => { :resource_controller_name => "#{file_name.pluralize}" }
99
+
100
+ m.template 'component.mxml.erb',
101
+ File.join("app", 'flex', base_folder, "components", "generated", "#{@class_name}Box.mxml"),
102
+ :assigns => { :resource_controller_name => "#{file_name.pluralize}" }
103
+
104
+ if options[:gae]
105
+ m.template 'controller.py.erb', "app/controllers/#{file_name.pluralize}.py"
106
+ m.template 'model.py.erb', "app/models/#{file_name}.py"
107
+ end
108
+
109
+ # Run the rcontroller generator to clobber the
110
+ # RubossCommandController subclass to include the new models.
111
+ m.dependency 'ruboss_controller', [name] + @args, :collision => :force, :gae => options[:gae]
112
+ end
113
+ end
114
+
115
+ protected
116
+ def extract_relationships
117
+ @belongs_tos = []
118
+ @has_ones = []
119
+ @has_manies = []
120
+ # Figure out has_one, has_many and belongs_to based on args
121
+ @args.each do |arg|
122
+ if arg =~ /^has_one:/
123
+ # arg = "has_one:arg1,arg2", so all the has_one are together
124
+ @has_ones = arg.split(':')[1].split(',')
125
+ elsif arg =~ /^has_many:/
126
+ # arg = "has_many:arg1,arg2", so all the has_many are together
127
+ @has_manies = arg.split(":")[1].split(",")
128
+ elsif arg =~ /^belongs_to:/ # belongs_to:arg1,arg2
129
+ @belongs_tos = arg.split(":")[1].split(',')
130
+ end
131
+ end
132
+
133
+ @args.delete_if { |elt| elt =~ /^(has_one|has_many|belongs_to):/ }
134
+ end
135
+
136
+ def attributes
137
+ @attributes ||= @args.collect do |attribute|
138
+ Ruboss4Ruby::Generator::GeneratedAttribute.new(*attribute.split(":"))
139
+ end
140
+ end
141
+
142
+ def add_options!(opt)
143
+ opt.separator ''
144
+ opt.separator 'Options:'
145
+ opt.on("--gae", "Generate Google App Engine Python classes in addition to Ruboss Flex resources.",
146
+ "Default: false") { |v| options[:gae] = v }
147
+ end
148
+ end
@@ -0,0 +1,149 @@
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.dcfirst %>:<%= class_name %> = new <%= class_name %>();
14
+
15
+ private function new<%= class_name %>():void {
16
+ _<%= class_name.dcfirst %> = new <%= class_name %>();
17
+ <%= class_name.dcfirst.pluralize %>List.selectedIndex = -1;
18
+ }
19
+
20
+ private function save<%= class_name %>():void {
21
+ if (_<%= class_name.dcfirst %>.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.dcfirst %>:<%= class_name %> = new <%= class_name %>();
30
+ <% for attribute in attributes -%>
31
+ <% if attribute.type == :boolean -%>
32
+ <%= class_name.dcfirst %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>CheckBox.selected;
33
+ <% elsif attribute.type == :string -%>
34
+ <%= class_name.dcfirst %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>TextInput.text;
35
+ <% elsif attribute.type == :text -%>
36
+ <%= class_name.dcfirst %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>TextArea.text;
37
+ <% elsif attribute.type == :datetime || attribute.type == :time -%>
38
+ <%= class_name.dcfirst %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>DateTimeTextInput.date;
39
+ <% elsif attribute.type == :date -%>
40
+ <%= class_name.dcfirst %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>DateField.selectedDate;
41
+ <% else -%>
42
+ <%= class_name.dcfirst %>.<%= 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.dcfirst %>.<%= model.camelcase(:lower) %> = <%= model.camelcase %>(<%= model.camelcase(:lower) %>ComboBox.selectedItem);
48
+ <% end -%>
49
+ <%= class_name.dcfirst %>.create({onSuccess: 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.dcfirst %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>CheckBox.selected;
56
+ <% elsif attribute.type == :string -%>
57
+ _<%= class_name.dcfirst %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>TextInput.text;
58
+ <% elsif attribute.type == :text -%>
59
+ _<%= class_name.dcfirst %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>TextArea.text;
60
+ <% elsif attribute.type == :datetime || attribute.type == :time -%>
61
+ _<%= class_name.dcfirst %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>DateTimeTextInput.date;
62
+ <% elsif attribute.type == :date -%>
63
+ _<%= class_name.dcfirst %>.<%= attribute.flex_name %> = <%= attribute.flex_name %>DateField.selectedDate;
64
+ <% else -%>
65
+ _<%= class_name.dcfirst %>.<%= 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.dcfirst %>.<%= model.camelcase(:lower) %> = <%= model.camelcase %>(<%= model.camelcase(:lower) %>ComboBox.selectedItem);
71
+ <% end -%>
72
+ _<%= class_name.dcfirst %>.update({onSuccess: on<%= class_name %>Update});
73
+ }
74
+
75
+ private function destroy<%= class_name %>():void {
76
+ _<%= class_name.dcfirst %>.destroy({onSuccess: on<%= class_name %>Destroy});
77
+ }
78
+
79
+ private function on<%= class_name %>Select():void {
80
+ _<%= class_name.dcfirst %> = RubossUtils.clone(<%= class_name.dcfirst.pluralize %>List.selectedItem) as <%= class_name %>;
81
+ }
82
+
83
+ private function on<%= class_name %>Create(<%= class_name.dcfirst %>:<%= class_name %>):void {
84
+ _<%= class_name.dcfirst %> = new <%= class_name %>;
85
+ }
86
+
87
+ private function on<%= class_name %>Update(<%= class_name.dcfirst %>:<%= class_name %>):void {
88
+ <%= class_name.dcfirst.pluralize %>List.selectedItem = <%= class_name.dcfirst %>;
89
+ _<%= class_name.dcfirst %> = RubossUtils.clone(<%= class_name.dcfirst %>) as <%= class_name %>;
90
+ }
91
+
92
+ private function on<%= class_name %>Destroy(<%= class_name.dcfirst %>:<%= class_name %>):void {
93
+ on<%= class_name %>Create(<%= class_name.dcfirst %>);
94
+ }
95
+
96
+ private function canDelete<%= class_name %>(<%= class_name.dcfirst %>:<%= class_name %>):Boolean {
97
+ return <%= class_name.dcfirst %> != null && !RubossUtils.isEmpty(<%= class_name.dcfirst %>.id);
98
+ }
99
+ ]]></mx:Script>
100
+ <mx:Panel id="<%= class_name.dcfirst.pluralize %>Panel"
101
+ title="<%= class_name.pluralize %>" cornerRadius="0" dropShadowEnabled="false" borderStyle="solid"
102
+ borderThickness="1" backgroundColor="#EEEEEE" width="25%" height="100%">
103
+ <mx:List id="<%= class_name.dcfirst.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 %>" cornerRadius="0" dropShadowEnabled="false" borderStyle="solid"
113
+ borderThickness="1" backgroundColor="#EEEEEE" width="75%" height="100%">
114
+ <mx:Form width="100%" height="100%">
115
+ <% for attribute in attributes -%>
116
+ <mx:FormItem label="<%= attribute.flex_name.ucfirst %>" width="100%">
117
+ <% if attribute.type == :boolean -%>
118
+ <mx:CheckBox id="<%= attribute.flex_name %>CheckBox" selected="{_<%= class_name.dcfirst %>.<%= attribute.flex_name %>}"/>
119
+ <% elsif attribute.type == :string -%>
120
+ <mx:TextInput id="<%= attribute.flex_name %>TextInput" width="100%" text="{_<%= class_name.dcfirst %>.<%= attribute.flex_name %>}"/>
121
+ <% elsif attribute.type == :text -%>
122
+ <mx:TextArea id="<%= attribute.flex_name %>TextArea" width="100%" height="200" text="{_<%= class_name.dcfirst %>.<%= attribute.flex_name %>}"/>
123
+ <% elsif attribute.type == :datetime || attribute.type == :time -%>
124
+ <rcomponents:DateTimeTextInput id="<%= attribute.flex_name %>DateTimeTextInput" width="200" date="{_<%= class_name.dcfirst %>.<%= attribute.flex_name %>}"/>
125
+ <% elsif attribute.type == :date -%>
126
+ <mx:DateField id="<%= attribute.flex_name %>DateField" selectedDate="{_<%= class_name.dcfirst %>.<%= attribute.flex_name %>}"/>
127
+ <% else -%>
128
+ <mx:TextInput id="<%= attribute.flex_name %>TextInput" width="100%" text="{_<%= class_name.dcfirst %>.<%= attribute.flex_name %>}"/>
129
+ <% end -%>
130
+ </mx:FormItem>
131
+ <% end -%>
132
+ <% for model in belongs_tos -%>
133
+ <mx:FormItem label="<%= model.camelcase %>" width="100%">
134
+ <mx:ComboBox id="<%= model.camelcase(:lower) %>ComboBox" width="200"
135
+ labelField="{<%= model.camelcase %>.LABEL}"
136
+ dataProvider="{Ruboss.models.index(<%= model.camelcase %>)}" prompt="<%= model.camelcase %> ..."
137
+ selectedItem="{_<%= class_name.dcfirst %>.<%= model.camelcase(:lower) %>}" />
138
+ </mx:FormItem>
139
+ <% end -%>
140
+ </mx:Form>
141
+ <mx:ControlBar width="100%">
142
+ <mx:Button label="Save <%= class_name %>" width="50%" height="30"
143
+ click="save<%= class_name %>()"/>
144
+ <mx:Button label="Delete <%= class_name %>" width="50%" height="30"
145
+ enabled="{canDelete<%= class_name %>(_<%= class_name.dcfirst %>)}"
146
+ click="destroy<%= class_name %>()"/>
147
+ </mx:ControlBar>
148
+ </mx:Panel>
149
+ </mx:HBox>
@@ -0,0 +1,27 @@
1
+ import restful
2
+ import logging
3
+
4
+ from google.appengine.ext import webapp
5
+ from google.appengine.api import users
6
+ from google.appengine.ext import db
7
+ from app.models import assist, <%= file_name %>
8
+
9
+ class Controller(restful.Controller):
10
+ def get(self):
11
+ restful.send_successful_response(self, assist.all(<%= file_name %>.<%= class_name %>))
12
+
13
+ @restful.methods_via_query_allowed
14
+ def post(self):
15
+ model = <%= file_name %>.<%= class_name %>()
16
+ assist.update_model_from_params(model, self.request.params)
17
+ restful.send_successful_response(self, model.to_xml())
18
+
19
+ def put(self):
20
+ model = <%= file_name %>.<%= class_name %>.get(db.Key(restful.get_model_key(self)))
21
+ assist.update_model_from_params(model, self.request.params)
22
+ restful.send_successful_response(self, model.to_xml())
23
+
24
+ def delete(self):
25
+ model = <%= file_name %>.<%= class_name %>.get(db.Key(restful.get_model_key(self)))
26
+ db.delete(model)
27
+ restful.send_successful_response(self, model.to_xml())
@@ -0,0 +1,42 @@
1
+ package <%= base_package %>.models {
2
+ <% if has_manies.length > 0 -%>
3
+ import org.ruboss.collections.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 %> = <%= attribute.flex_default %>;
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,14 @@
1
+ from google.appengine.ext import db
2
+ <% if belongs_tos.length > 0 -%>
3
+ import <%= belongs_tos.join(", ") %>
4
+ <% end -%>
5
+
6
+ class <%= class_name %>(db.Model):
7
+ <% for attribute in attributes -%>
8
+ <%= attribute.name %> = db.<%= attribute.gae_type %>(<%= attribute.gae_default %>)
9
+ <% end -%>
10
+ <% for model in belongs_tos -%>
11
+ <%= model %> = db.ReferenceProperty(<%= model %>.<%= model.camelcase %>)
12
+ <% end -%>
13
+
14
+
@@ -0,0 +1,45 @@
1
+ Description:
2
+ Scaffolds an entire application based on db/model.yml file.
3
+
4
+ This generator transforms entries in db/model.yml into
5
+ command line calls to "ruboss_scaffold".
6
+
7
+ Examples:
8
+ `./script/generate ruboss_yaml_scaffold`
9
+
10
+ Sample Model File:
11
+ project:
12
+ - name: string
13
+ - notes: text
14
+ - start_date: date
15
+ - end_date: date
16
+ - completed: boolean
17
+ - belongs_to: [user]
18
+ - has_many: [tasks]
19
+
20
+ location:
21
+ - name: string
22
+ - notes: text
23
+ - belongs_to: [user]
24
+ - has_many: [tasks]
25
+
26
+ task:
27
+ - name: string
28
+ - notes: text
29
+ - start_time: datetime
30
+ - end_time: datetime
31
+ - completed: boolean
32
+ - next_action: boolean
33
+ - belongs_to: [project, location, user]
34
+
35
+ note:
36
+ - content: text
37
+ - belongs_to: [user]
38
+
39
+ user:
40
+ - login: string
41
+ - first_name: string
42
+ - last_name: string
43
+ - email: string
44
+ - has_many: [tasks, projects, locations]
45
+ - has_one: [note]
@@ -0,0 +1,47 @@
1
+ require 'yaml'
2
+
3
+ class RubossYamlScaffoldGenerator < RubiGen::Base
4
+ include Ruboss4Ruby::Configuration
5
+
6
+ def extract_attrs(line, attrs)
7
+ attrs.each do |key,value|
8
+ if value.class == Array
9
+ line << " #{key}:#{value.join(',')}"
10
+ else
11
+ line << " #{key}:#{value}"
12
+ end
13
+ end
14
+ line
15
+ end
16
+
17
+ def manifest
18
+ record do |m|
19
+ models = YAML.load(File.open(File.join(APP_ROOT, 'db/model.yml'), 'r'))
20
+ models.each do |model|
21
+ line = ""
22
+ attrs = model[1]
23
+ if attrs.class == Array
24
+ attrs.each do |elm|
25
+ line = extract_attrs(line, elm)
26
+ end
27
+ else
28
+ line = extract_attrs(line, attrs)
29
+ end
30
+ line = model[0].camelcase + " " + line
31
+ puts 'running: ruboss_scaffold ' + line
32
+ RubiGen::Scripts::Generate.new.run(line.split, :generator => 'ruboss_scaffold',
33
+ :gae => options[:gae])
34
+ puts 'done ...'
35
+ end
36
+ RubiGen::Scripts::Generate.new.run([], :generator => 'ruboss_main_app', :gae => options[:gae])
37
+ end
38
+ end
39
+
40
+ protected
41
+ def add_options!(opt)
42
+ opt.separator ''
43
+ opt.separator 'Options:'
44
+ opt.on("--gae", "Generate Google App Engine Python classes in addition to Ruboss Flex resources.",
45
+ "Default: false") { |v| options[:gae] = v }
46
+ end
47
+ end