ruboss4ruby 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +3 -0
- data/Manifest.txt +102 -0
- data/README.txt +37 -0
- data/Rakefile +4 -0
- data/config/hoe.rb +72 -0
- data/config/requirements.rb +15 -0
- data/gpl-3.0.txt +674 -0
- data/lib/ruboss4ruby/active_foo.rb +127 -0
- data/lib/ruboss4ruby/active_record_tasks.rb +75 -0
- data/lib/ruboss4ruby/configuration.rb +38 -0
- data/lib/ruboss4ruby/tasks.rb +81 -0
- data/lib/ruboss4ruby/version.rb +11 -0
- data/lib/ruboss4ruby.rb +61 -0
- data/merb_generators/ruboss_config/USAGE +18 -0
- data/merb_generators/ruboss_config/ruboss_config_generator.rb +135 -0
- data/merb_generators/ruboss_config/templates/actionscript.properties +16 -0
- data/merb_generators/ruboss_config/templates/actionscriptair.properties +16 -0
- data/merb_generators/ruboss_config/templates/expressInstall.swf +0 -0
- data/merb_generators/ruboss_config/templates/flex.properties +2 -0
- data/merb_generators/ruboss_config/templates/html-template/AC_OETags.js +276 -0
- data/merb_generators/ruboss_config/templates/html-template/history/history.css +6 -0
- data/merb_generators/ruboss_config/templates/html-template/history/history.js +645 -0
- data/merb_generators/ruboss_config/templates/html-template/history/historyFrame.html +29 -0
- data/merb_generators/ruboss_config/templates/html-template/index.template.html +121 -0
- data/merb_generators/ruboss_config/templates/html-template/playerProductInstall.swf +0 -0
- data/merb_generators/ruboss_config/templates/index.html.erb +19 -0
- data/merb_generators/ruboss_config/templates/mainair-app.xml +134 -0
- data/merb_generators/ruboss_config/templates/mainapp.mxml +34 -0
- data/merb_generators/ruboss_config/templates/project.properties +18 -0
- data/merb_generators/ruboss_config/templates/projectair.properties +24 -0
- data/merb_generators/ruboss_config/templates/swfobject.js +5 -0
- data/merb_generators/ruboss_controller/USAGE +11 -0
- data/merb_generators/ruboss_controller/ruboss_controller_generator.rb +32 -0
- data/merb_generators/ruboss_controller/templates/controller.as.erb +35 -0
- data/merb_generators/ruboss_resource_controller/USAGE +5 -0
- data/merb_generators/ruboss_resource_controller/ruboss_resource_controller_generator.rb +70 -0
- data/merb_generators/ruboss_resource_controller/templates/app/controllers/%controller_file_name%.rb +55 -0
- data/merb_generators/ruboss_resource_controller/templates/app/helpers/%controller_file_name%_helper.rb +16 -0
- data/merb_generators/ruboss_scaffold/USAGE +5 -0
- data/merb_generators/ruboss_scaffold/ruboss_scaffold_generator.rb +189 -0
- data/merb_generators/ruboss_scaffold/templates/component.mxml.erb +148 -0
- data/merb_generators/ruboss_scaffold/templates/fixtures.yml.erb +35 -0
- data/merb_generators/ruboss_scaffold/templates/migration.rb.erb +19 -0
- data/merb_generators/ruboss_scaffold/templates/model.as.erb +42 -0
- data/merb_generators/ruboss_scaffold/templates/model.rb.erb +11 -0
- data/merb_generators/ruboss_yaml_scaffold/USAGE +5 -0
- data/merb_generators/ruboss_yaml_scaffold/ruboss_yaml_scaffold_generator.rb +53 -0
- data/rails_generators/ruboss_config/USAGE +18 -0
- data/rails_generators/ruboss_config/ruboss_config_generator.rb +127 -0
- data/rails_generators/ruboss_config/templates/actionscript.properties +16 -0
- data/rails_generators/ruboss_config/templates/actionscriptair.properties +16 -0
- data/rails_generators/ruboss_config/templates/expressInstall.swf +0 -0
- data/rails_generators/ruboss_config/templates/flex.properties +2 -0
- data/rails_generators/ruboss_config/templates/html-template/AC_OETags.js +276 -0
- data/rails_generators/ruboss_config/templates/html-template/history/history.css +6 -0
- data/rails_generators/ruboss_config/templates/html-template/history/history.js +645 -0
- data/rails_generators/ruboss_config/templates/html-template/history/historyFrame.html +29 -0
- data/rails_generators/ruboss_config/templates/html-template/index.template.html +121 -0
- data/rails_generators/ruboss_config/templates/html-template/playerProductInstall.swf +0 -0
- data/rails_generators/ruboss_config/templates/index.html.erb +19 -0
- data/rails_generators/ruboss_config/templates/mainair-app.xml +134 -0
- data/rails_generators/ruboss_config/templates/mainapp.mxml +34 -0
- data/rails_generators/ruboss_config/templates/project.properties +18 -0
- data/rails_generators/ruboss_config/templates/projectair.properties +24 -0
- data/rails_generators/ruboss_config/templates/ruboss.yml +16 -0
- data/rails_generators/ruboss_config/templates/ruboss_tasks.rake +15 -0
- data/rails_generators/ruboss_config/templates/swfobject.js +5 -0
- data/rails_generators/ruboss_controller/USAGE +11 -0
- data/rails_generators/ruboss_controller/ruboss_controller_generator.rb +46 -0
- data/rails_generators/ruboss_controller/templates/controller.as.erb +35 -0
- data/rails_generators/ruboss_scaffold/USAGE +35 -0
- data/rails_generators/ruboss_scaffold/ruboss_scaffold_generator.rb +192 -0
- data/rails_generators/ruboss_scaffold/templates/component.mxml.erb +148 -0
- data/rails_generators/ruboss_scaffold/templates/controller.rb.erb +97 -0
- data/rails_generators/ruboss_scaffold/templates/fixtures.yml.erb +35 -0
- data/rails_generators/ruboss_scaffold/templates/migration.rb.erb +19 -0
- data/rails_generators/ruboss_scaffold/templates/model.as.erb +42 -0
- data/rails_generators/ruboss_scaffold/templates/model.rb.erb +11 -0
- data/rails_generators/ruboss_yaml_scaffold/USAGE +14 -0
- data/rails_generators/ruboss_yaml_scaffold/ruboss_yaml_scaffold_generator.rb +45 -0
- data/rcl-1.0.txt +0 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +82 -0
- data/setup.rb +1585 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/website.rake +17 -0
- data/test/active_foo_test.rb +16 -0
- data/test/test_generator_helper.rb +29 -0
- data/test/test_helper.rb +2 -0
- data/test/test_ruboss_config_generator.rb +45 -0
- data/test/test_ruboss_controller_generator.rb +45 -0
- data/test/test_ruboss_on_ruby.rb +11 -0
- data/test/test_ruboss_scaffold_generator.rb +45 -0
- data/test/test_ruboss_yaml_scaffold_generator.rb +46 -0
- data/website/index.html +63 -0
- data/website/index.txt +34 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +138 -0
- data/website/template.html.erb +47 -0
- metadata +167 -0
@@ -0,0 +1,192 @@
|
|
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 'ruboss4ruby/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 :date, :datetime, :time then 'Date'
|
59
|
+
when :boolean then 'Boolean'
|
60
|
+
when :float, :decimal then 'Number'
|
61
|
+
else
|
62
|
+
'String'
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def flex_default(prefix = '')
|
67
|
+
@flex_default = case type
|
68
|
+
when :integer, :float, :decimal then '0'
|
69
|
+
when :string, :text then '""'
|
70
|
+
when :boolean then 'false'
|
71
|
+
else
|
72
|
+
'null'
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
class RubossScaffoldGenerator < Rails::Generator::NamedBase
|
80
|
+
include Ruboss::Configuration
|
81
|
+
|
82
|
+
attr_reader :project_name,
|
83
|
+
:flex_project_name,
|
84
|
+
:base_package,
|
85
|
+
:base_folder,
|
86
|
+
:command_controller_name
|
87
|
+
|
88
|
+
attr_reader :belongs_tos,
|
89
|
+
:has_manies,
|
90
|
+
:has_ones
|
91
|
+
|
92
|
+
attr_reader :controller_name,
|
93
|
+
:controller_class_path,
|
94
|
+
:controller_file_path,
|
95
|
+
:controller_class_nesting,
|
96
|
+
:controller_class_nesting_depth,
|
97
|
+
:controller_class_name,
|
98
|
+
:controller_underscore_name,
|
99
|
+
:controller_singular_name,
|
100
|
+
:controller_plural_name
|
101
|
+
|
102
|
+
attr_accessor :constructor_args
|
103
|
+
|
104
|
+
alias_method :controller_file_name, :controller_underscore_name
|
105
|
+
alias_method :controller_table_name, :controller_plural_name
|
106
|
+
|
107
|
+
def initialize(runtime_args, runtime_options = {})
|
108
|
+
super
|
109
|
+
@project_name, @flex_project_name, @command_controller_name, @base_package, @base_folder = extract_names
|
110
|
+
@controller_name = @name.pluralize
|
111
|
+
|
112
|
+
base_name, @controller_class_path, @controller_file_path, @controller_class_nesting,
|
113
|
+
@controller_class_nesting_depth = extract_modules(@controller_name)
|
114
|
+
@controller_class_name_without_nesting, @controller_underscore_name, @controller_plural_name = inflect_names(base_name)
|
115
|
+
|
116
|
+
@controller_singular_name=base_name.singularize
|
117
|
+
if @controller_class_nesting.empty?
|
118
|
+
@controller_class_name = @controller_class_name_without_nesting
|
119
|
+
else
|
120
|
+
@controller_class_name = "#{@controller_class_nesting}::#{@controller_class_name_without_nesting}"
|
121
|
+
end
|
122
|
+
|
123
|
+
@belongs_tos = []
|
124
|
+
@has_ones = []
|
125
|
+
@has_manies = []
|
126
|
+
# Figure out has_one, has_many and belongs_to based on args
|
127
|
+
@args.each do |arg|
|
128
|
+
if arg =~ /^has_one:/
|
129
|
+
# arg = "has_one:arg1,arg2", so all the has_one are together
|
130
|
+
@has_ones = arg.split(':')[1].split(',')
|
131
|
+
elsif arg =~ /^has_many:/
|
132
|
+
# arg = "has_many:arg1,arg2", so all the has_many are together
|
133
|
+
@has_manies = arg.split(":")[1].split(",")
|
134
|
+
elsif arg =~ /^belongs_to:/ # belongs_to:arg1,arg2
|
135
|
+
@belongs_tos = arg.split(":")[1].split(',')
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
# Remove the has_one and has_many arguments since they are
|
140
|
+
# not for consumption by the scaffold generator, and since
|
141
|
+
# we have already used them to set the @belongs_tos, @has_ones and
|
142
|
+
# @has_manies.
|
143
|
+
@args.delete_if { |elt| elt =~ /^(has_one|has_many|belongs_to):/ }
|
144
|
+
end
|
145
|
+
|
146
|
+
def manifest
|
147
|
+
record do |m|
|
148
|
+
m.dependency 'scaffold', [name] + @args, :skip_migration => true, :collision => :skip unless options[:flex_only]
|
149
|
+
|
150
|
+
# Generate Flex AS model and MXML component based on the
|
151
|
+
# Ruboss templates.
|
152
|
+
m.template 'model.as.erb',
|
153
|
+
File.join("app", "flex", base_folder, "models", "#{@class_name}.as"),
|
154
|
+
:assigns => { :resource_controller_name => "#{file_name.pluralize}" }
|
155
|
+
|
156
|
+
m.template 'component.mxml.erb',
|
157
|
+
File.join("app", "flex", base_folder, "components", "generated", "#{@class_name}Box.mxml"),
|
158
|
+
:assigns => { :resource_controller_name => "#{file_name.pluralize}" }
|
159
|
+
|
160
|
+
m.template 'controller.rb.erb', File.join("app/controllers", controller_class_path,
|
161
|
+
"#{controller_file_name}_controller.rb"), :collision => :force unless options[:flex_only]
|
162
|
+
|
163
|
+
# Create a new generated ActiveRecord model based on the Ruboss templates.
|
164
|
+
m.template 'model.rb.erb', File.join("app", "models", "#{file_name}.rb"),
|
165
|
+
:collision => :force unless options[:flex_only]
|
166
|
+
|
167
|
+
unless options[:skip_fixture]
|
168
|
+
m.template 'fixtures.yml.erb', File.join("test", "fixtures", "#{table_name}.yml"),
|
169
|
+
:collision => :force unless options[:flex_only]
|
170
|
+
end
|
171
|
+
|
172
|
+
unless options[:skip_migration]
|
173
|
+
m.directory 'schema/migration'
|
174
|
+
m.migration_template 'migration.rb.erb', 'db/migrate', :assigns => {
|
175
|
+
:migration_name => "Create#{class_name.pluralize.gsub(/::/, '')}"
|
176
|
+
}, :migration_file_name => "create_#{file_path.gsub(/\//, '_').pluralize}" unless options[:flex_only]
|
177
|
+
end
|
178
|
+
|
179
|
+
# Run the rcontroller generator to clobber the
|
180
|
+
# RubossCommandController subclass to include the new models.
|
181
|
+
m.dependency 'ruboss_controller', [name] + @args, :collision => :force
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
protected
|
186
|
+
def add_options!(opt)
|
187
|
+
opt.separator ''
|
188
|
+
opt.separator 'Options:'
|
189
|
+
opt.on("-f", "--flex-only", "Scaffold Flex code only",
|
190
|
+
"Default: false") { |v| options[:flex_only] = v}
|
191
|
+
end
|
192
|
+
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
|
@@ -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,14 @@
|
|
1
|
+
Description:
|
2
|
+
Scaffolds an entire application based on db/model.yml file. This generator
|
3
|
+
transforms entries in db/model.yml into command line calls to
|
4
|
+
"ruboss_scaffold".
|
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
|
+
Examples:
|
14
|
+
`./script/generate ruboss_yaml_scaffold`
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'ruboss4ruby/configuration'
|
3
|
+
|
4
|
+
class RubossYamlScaffoldGenerator < Rails::Generator::Base
|
5
|
+
def extract_attrs(line, attrs)
|
6
|
+
attrs.each do |key,value|
|
7
|
+
if value.class == Array
|
8
|
+
line << " #{key}:#{value.join(',')}"
|
9
|
+
else
|
10
|
+
line << " #{key}:#{value}"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
line
|
14
|
+
end
|
15
|
+
|
16
|
+
def manifest
|
17
|
+
record do |m|
|
18
|
+
models = YAML.load(File.open(File.join(RAILS_ROOT, 'db/model.yml'), 'r'))
|
19
|
+
models.each do |model|
|
20
|
+
line = ""
|
21
|
+
attrs = model[1]
|
22
|
+
if attrs.class == Array
|
23
|
+
attrs.each do |elm|
|
24
|
+
line = extract_attrs(line, elm)
|
25
|
+
end
|
26
|
+
else
|
27
|
+
line = extract_attrs(line, attrs)
|
28
|
+
end
|
29
|
+
line = model[0].camelcase + " " + line
|
30
|
+
puts 'running: ruboss_scaffold ' + line
|
31
|
+
Rails::Generator::Scripts::Generate.new.run(["ruboss_scaffold"] + line.split,
|
32
|
+
:flex_only => ARGV.include?('flexonly'))
|
33
|
+
puts 'done ...'
|
34
|
+
sleep 1
|
35
|
+
end
|
36
|
+
Rails::Generator::Scripts::Generate.new.run(["ruboss_config"], :main_only => true,
|
37
|
+
:skip_framework => ARGV.include?('skipframework'))
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
protected
|
42
|
+
def banner
|
43
|
+
"Usage: #{$0} #{spec.name}"
|
44
|
+
end
|
45
|
+
end
|
data/rcl-1.0.txt
ADDED
Binary file
|
data/script/console
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# File: script/console
|
3
|
+
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
4
|
+
|
5
|
+
libs = " -r irb/completion"
|
6
|
+
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
|
7
|
+
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
|
8
|
+
libs << " -r #{File.dirname(__FILE__) + '/../lib/ruboss4ruby.rb'}"
|
9
|
+
puts "Loading ruboss4ruby gem"
|
10
|
+
exec "#{irb} #{libs} --simple-prompt"
|
data/script/destroy
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/destroy'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/generate'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Generate.new.run(ARGV)
|