ruboss_on_ruby 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +3 -0
- data/Manifest.txt +101 -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/ruboss_on_ruby.rb +64 -0
- data/lib/ruboss_on_ruby/active_foo.rb +127 -0
- data/lib/ruboss_on_ruby/active_record_tasks.rb +75 -0
- data/lib/ruboss_on_ruby/configuration.rb +38 -0
- data/lib/ruboss_on_ruby/tasks.rb +74 -0
- data/lib/ruboss_on_ruby/version.rb +11 -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 +190 -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 +126 -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_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 +193 -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 +86 -0
- data/website/index.txt +83 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +138 -0
- data/website/template.html.erb +48 -0
- metadata +166 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
class RubossResourceControllerGenerator < Merb::GeneratorBase
|
|
2
|
+
|
|
3
|
+
attr_reader :controller_class_name,
|
|
4
|
+
:controller_file_name,
|
|
5
|
+
:controller_base_path,
|
|
6
|
+
:controller_modules,
|
|
7
|
+
:model_class_name,
|
|
8
|
+
:full_controller_const,
|
|
9
|
+
:singular_model,
|
|
10
|
+
:plural_model
|
|
11
|
+
|
|
12
|
+
def initialize(args, runtime_args = {})
|
|
13
|
+
@base = File.dirname(__FILE__)
|
|
14
|
+
|
|
15
|
+
super
|
|
16
|
+
name = args.shift
|
|
17
|
+
nfp = name.snake_case.gsub("::", "/")
|
|
18
|
+
nfp = nfp.split("/")
|
|
19
|
+
@model_class_name = nfp.pop.singularize.to_const_string
|
|
20
|
+
@model_class_name = runtime_args[:model_class_name] if runtime_args[:model_class_name]
|
|
21
|
+
@singular_model = @model_class_name.snake_case
|
|
22
|
+
@plural_model = @singular_model.pluralize
|
|
23
|
+
|
|
24
|
+
nfp << @plural_model
|
|
25
|
+
|
|
26
|
+
@controller_file_name = nfp.join("/")
|
|
27
|
+
|
|
28
|
+
# Need to setup the directories
|
|
29
|
+
unless @controller_file_name == File.basename(@controller_file_name)
|
|
30
|
+
@controller_base_path = controller_file_name.split("/")[0..-2].join("/")
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
@controller_modules = @controller_file_name.to_const_string.split("::")[0..-2]
|
|
34
|
+
@controller_class_name = @controller_file_name.to_const_string.split("::").last
|
|
35
|
+
|
|
36
|
+
@full_controller_const = ((@controller_modules.dup || []) << @controller_class_name).join("::")
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def manifest
|
|
40
|
+
record do |m|
|
|
41
|
+
@m = m
|
|
42
|
+
|
|
43
|
+
# Create the controller directory
|
|
44
|
+
m.directory File.join("app/controllers", controller_base_path) if controller_base_path
|
|
45
|
+
|
|
46
|
+
# Create the helpers directory
|
|
47
|
+
m.directory File.join("app/helpers", controller_base_path) if controller_base_path
|
|
48
|
+
|
|
49
|
+
@assigns = {
|
|
50
|
+
:controller_modules => controller_modules,
|
|
51
|
+
:controller_class_name => controller_class_name,
|
|
52
|
+
:controller_file_name => controller_file_name,
|
|
53
|
+
:controller_base_path => controller_base_path,
|
|
54
|
+
:full_controller_const => full_controller_const,
|
|
55
|
+
:model_class_name => model_class_name,
|
|
56
|
+
:singular_model => singular_model,
|
|
57
|
+
:plural_model => plural_model
|
|
58
|
+
}
|
|
59
|
+
copy_dirs
|
|
60
|
+
copy_files
|
|
61
|
+
|
|
62
|
+
m.dependency "merb_resource_controller_test", [@controller_class_name], @assigns
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
protected
|
|
67
|
+
def banner
|
|
68
|
+
"Usage: #{$0} #{spec.name}"
|
|
69
|
+
end
|
|
70
|
+
end
|
data/merb_generators/ruboss_resource_controller/templates/app/controllers/%controller_file_name%.rb
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<% counter = 0 -%>
|
|
2
|
+
<% controller_modules.each_with_index do |mod, i| -%>
|
|
3
|
+
<%= " " * i %>module <%= mod %>
|
|
4
|
+
<% counter = i -%>
|
|
5
|
+
<% end -%>
|
|
6
|
+
<% counter = counter == 0 ? 0 : (counter + 1) -%>
|
|
7
|
+
<%= " " * counter %>class <%= controller_class_name %> < Application
|
|
8
|
+
<%= " " * counter %> provides :xml, :fxml
|
|
9
|
+
|
|
10
|
+
<%= " " * counter %> def index
|
|
11
|
+
<%= " " * counter %> @<%= plural_model %> = <%= model_class_name %>.find(:all)
|
|
12
|
+
<%= " " * counter %> display @<%= plural_model %>
|
|
13
|
+
<%= " " * counter %> end
|
|
14
|
+
|
|
15
|
+
<%= " " * counter %> def show
|
|
16
|
+
<%= " " * counter %> @<%= singular_model %> = <%= model_class_name %>.find_by_id(params[:id])
|
|
17
|
+
<%= " " * counter %> raise NotFound unless @<%= singular_model %>
|
|
18
|
+
<%= " " * counter %> display @<%= singular_model %>
|
|
19
|
+
<%= " " * counter %> end
|
|
20
|
+
|
|
21
|
+
<%= " " * counter %> def create
|
|
22
|
+
<%= " " * counter %> @<%= singular_model %> = <%= model_class_name %>.new(params[:<%= singular_model %>])
|
|
23
|
+
<%= " " * counter %> if @<%= singular_model %>.save
|
|
24
|
+
<%= " " * counter %> display @<%= singular_model %>
|
|
25
|
+
<%= " " * counter %> else
|
|
26
|
+
<%= " " * counter %> display @<%= singular_model %>.errors
|
|
27
|
+
<%= " " * counter %> end
|
|
28
|
+
<%= " " * counter %> end
|
|
29
|
+
|
|
30
|
+
<%= " " * counter %> def update
|
|
31
|
+
<%= " " * counter %> @<%= singular_model %> = <%= model_class_name %>.find_by_id(params[:id])
|
|
32
|
+
<%= " " * counter %> raise NotFound unless @<%= singular_model %>
|
|
33
|
+
<%= " " * counter %> if @<%= singular_model %>.update_attributes(params[:<%= singular_model %>])
|
|
34
|
+
<%= " " * counter %> display @<%= singular_model %>
|
|
35
|
+
<%= " " * counter %> else
|
|
36
|
+
<%= " " * counter %> display @<%= singular_model %>.errors
|
|
37
|
+
<%= " " * counter %> end
|
|
38
|
+
<%= " " * counter %> end
|
|
39
|
+
|
|
40
|
+
<%= " " * counter %> def destroy
|
|
41
|
+
<%= " " * counter %> @<%= singular_model %> = <%= model_class_name %>.find_by_id(params[:id])
|
|
42
|
+
<%= " " * counter %> raise NotFound unless @<%= singular_model %>
|
|
43
|
+
<%= " " * counter %> if @<%= singular_model %>.destroy
|
|
44
|
+
<%= " " * counter %> display @<%= singular_model %>
|
|
45
|
+
<%= " " * counter %> else
|
|
46
|
+
<%= " " * counter %> display @<%= singular_model %>.errors
|
|
47
|
+
<%= " " * counter %> end
|
|
48
|
+
<%= " " * counter %> end
|
|
49
|
+
|
|
50
|
+
<%= " " * counter %>end
|
|
51
|
+
<% counter = counter == 0 ? 0 : (counter - 1) -%>
|
|
52
|
+
<% controller_modules.reverse.each_with_index do |mod, i| -%>
|
|
53
|
+
<%= " " * counter %>end # <%= mod %>
|
|
54
|
+
<% counter = counter - 1 -%>
|
|
55
|
+
<% end -%>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<% counter = 1 -%>
|
|
2
|
+
module Merb
|
|
3
|
+
<% controller_modules.each_with_index do |mod, i| -%>
|
|
4
|
+
<%= " " * i %>module <%= mod %>
|
|
5
|
+
<% counter = i -%>
|
|
6
|
+
<% end -%>
|
|
7
|
+
<% counter = counter == 0 ? 0 : (counter + 1) -%>
|
|
8
|
+
<%= " " * counter %>module <%= controller_class_name %>Helper
|
|
9
|
+
|
|
10
|
+
<%= " " * counter %>end
|
|
11
|
+
<% counter = counter == 0 ? 0 : (counter - 1) -%>
|
|
12
|
+
<% controller_modules.reverse.each_with_index do |mod, i| -%>
|
|
13
|
+
<%= " " * counter %>end # <%= mod %>
|
|
14
|
+
<% counter = counter - 1 -%>
|
|
15
|
+
<% end -%>
|
|
16
|
+
end
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
require 'ruboss_on_ruby/configuration'
|
|
2
|
+
|
|
3
|
+
module RubossOnRuby
|
|
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 :string, :text then 'String'
|
|
45
|
+
when :date, :datetime, :time then 'Date'
|
|
46
|
+
when :boolean then 'Boolean'
|
|
47
|
+
when :float, :decimal then 'Number'
|
|
48
|
+
else
|
|
49
|
+
'*'
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def flex_default(prefix = '')
|
|
54
|
+
@flex_default = case type
|
|
55
|
+
when :integer, :float, :decimal then '0'
|
|
56
|
+
when :string, :text then '""'
|
|
57
|
+
when :boolean then 'false'
|
|
58
|
+
else
|
|
59
|
+
'null'
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
class RubossScaffoldGenerator < Merb::GeneratorBase
|
|
67
|
+
include RubossOnRuby::Configuration
|
|
68
|
+
|
|
69
|
+
attr_reader :class_name,
|
|
70
|
+
:file_name,
|
|
71
|
+
:table_name,
|
|
72
|
+
:provided_args,
|
|
73
|
+
:actual_args
|
|
74
|
+
|
|
75
|
+
attr_reader :project_name,
|
|
76
|
+
:flex_project_name,
|
|
77
|
+
:base_package,
|
|
78
|
+
:base_folder,
|
|
79
|
+
:command_controller_name
|
|
80
|
+
|
|
81
|
+
attr_reader :belongs_tos,
|
|
82
|
+
:has_manies,
|
|
83
|
+
:has_ones
|
|
84
|
+
|
|
85
|
+
def initialize(runtime_args, runtime_options = {})
|
|
86
|
+
@base = File.dirname(__FILE__)
|
|
87
|
+
super
|
|
88
|
+
@project_name, @flex_project_name, @command_controller_name, @base_package, @base_folder = extract_names
|
|
89
|
+
|
|
90
|
+
@actual_args = runtime_args
|
|
91
|
+
@provided_args = runtime_args.dup
|
|
92
|
+
@file_name = actual_args.shift.snake_case
|
|
93
|
+
@table_name = @file_name.pluralize
|
|
94
|
+
@class_name = @file_name.to_const_string
|
|
95
|
+
|
|
96
|
+
@belongs_tos = []
|
|
97
|
+
@has_ones = []
|
|
98
|
+
@has_manies = []
|
|
99
|
+
# Figure out has_one, has_many and belongs_to based on args
|
|
100
|
+
@args.each do |arg|
|
|
101
|
+
if arg =~ /^has_one:/
|
|
102
|
+
# arg = "has_one:arg1,arg2", so all the has_one are together
|
|
103
|
+
@has_ones = arg.split(':')[1].split(',')
|
|
104
|
+
elsif arg =~ /^has_many:/
|
|
105
|
+
# arg = "has_many:arg1,arg2", so all the has_many are together
|
|
106
|
+
@has_manies = arg.split(":")[1].split(",")
|
|
107
|
+
elsif arg =~ /^belongs_to:/ # belongs_to:arg1,arg2
|
|
108
|
+
@belongs_tos = arg.split(":")[1].split(',')
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# Remove the has_one and has_many arguments since they are
|
|
113
|
+
# not for consumption by the scaffold generator, and since
|
|
114
|
+
# we have already used them to set the @belongs_tos, @has_ones and
|
|
115
|
+
# @has_manies.
|
|
116
|
+
@actual_args.delete_if { |elt| elt =~ /^(has_one|has_many|belongs_to):/ }
|
|
117
|
+
@provided_args.delete_if { |elt| elt =~ /^(has_one|has_many|belongs_to):/ }
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def manifest
|
|
121
|
+
record do |m|
|
|
122
|
+
@m = m
|
|
123
|
+
|
|
124
|
+
#singularize the model & pluralize the name of the controller
|
|
125
|
+
model_args = provided_args.dup
|
|
126
|
+
controller_args = provided_args.dup
|
|
127
|
+
|
|
128
|
+
# normalize the model_args
|
|
129
|
+
model_args[0] = model_args.first.snake_case.gsub("::", "/").split("/").last.singularize
|
|
130
|
+
|
|
131
|
+
controller_args[0] = controller_args.first.pluralize
|
|
132
|
+
|
|
133
|
+
m.dependency "ruboss_resource_controller", controller_args, options.dup
|
|
134
|
+
|
|
135
|
+
# # Create a new generated ActiveRecord model based on the Ruboss templates.
|
|
136
|
+
m.directory 'app/models'
|
|
137
|
+
m.template 'model.rb.erb', File.join("app", "models", "#{@file_name}.rb"),
|
|
138
|
+
:collision => :force unless options[:flex_only]
|
|
139
|
+
|
|
140
|
+
unless options[:skip_fixture]
|
|
141
|
+
m.directory 'spec/fixtures'
|
|
142
|
+
m.template 'fixtures.yml.erb', File.join("spec", "fixtures", "#{@table_name}.yml"),
|
|
143
|
+
:collision => :force unless options[:flex_only]
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
unless options[:skip_migration]
|
|
147
|
+
m.directory 'schema/migrations'
|
|
148
|
+
current_migration_number = Dir[Dir.pwd+'/schema/migrations/*'].map{|f| File.basename(f) =~ /^(\d+)/; $1}.max
|
|
149
|
+
migration_file_name = format("%03d_%s", (current_migration_number.to_i+1), file_name) + "_migration"
|
|
150
|
+
m.template 'migration.rb.erb', "schema/migrations/#{migration_file_name}.rb", :assigns => {
|
|
151
|
+
:migration_name => "#{@class_name}Migration"
|
|
152
|
+
} unless options[:flex_only]
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
m.dependency "merb_model_test", [@file_name], { :model_file_name => @file_name, :model_class_name => @class_name }
|
|
156
|
+
|
|
157
|
+
# Generate Flex AS model and MXML component based on the
|
|
158
|
+
# Ruboss templates.
|
|
159
|
+
m.template 'model.as.erb',
|
|
160
|
+
File.join("app", "flex", base_folder, "models", "#{@class_name}.as"),
|
|
161
|
+
:assigns => { :resource_controller_name => "#{@table_name}" }
|
|
162
|
+
|
|
163
|
+
m.template 'component.mxml.erb',
|
|
164
|
+
File.join("app", "flex", base_folder, "components", "generated", "#{@class_name}Box.mxml"),
|
|
165
|
+
:assigns => { :resource_controller_name => "#{@table_name}" }
|
|
166
|
+
|
|
167
|
+
# Run the rcontroller generator to clobber the
|
|
168
|
+
# RubossCommandController subclass to include the new models.
|
|
169
|
+
m.dependency 'ruboss_controller', [], :collision => :force
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
protected
|
|
174
|
+
def attributes
|
|
175
|
+
@attributes ||= @args.collect do |attribute|
|
|
176
|
+
RubossOnRuby::Generator::GeneratedAttribute.new(*attribute.split(":"))
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
def add_options!(opt)
|
|
181
|
+
opt.separator ''
|
|
182
|
+
opt.separator 'Options:'
|
|
183
|
+
opt.on("-f", "--flex-only", "Scaffold Flex code only",
|
|
184
|
+
"Default: false") { |v| options[:flex_only] = v}
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
def banner
|
|
188
|
+
"Usage: #{$0} #{spec.name}"
|
|
189
|
+
end
|
|
190
|
+
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>
|