ruboss4ruby 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 +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,127 @@
|
|
|
1
|
+
#ActiveRecord+ActiveSupport specific patches
|
|
2
|
+
|
|
3
|
+
# Flex friendly date, datetime formats
|
|
4
|
+
ActiveSupport::CoreExtensions::Date::Conversions::DATE_FORMATS.merge!(:flex_date => "%Y/%m/%d")
|
|
5
|
+
ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.merge!(:flex_datetime => "%Y/%m/%d %H:%M:%S")
|
|
6
|
+
|
|
7
|
+
Hash::XML_FORMATTING['date'] = Proc.new { |date| date.to_s(:flex_date) }
|
|
8
|
+
Hash::XML_FORMATTING['datetime'] = Proc.new { |datetime| datetime.to_s(:flex_datetime) }
|
|
9
|
+
|
|
10
|
+
class ClassyEmptyArray < Array
|
|
11
|
+
def initialize(class_name)
|
|
12
|
+
@class_name = class_name
|
|
13
|
+
end
|
|
14
|
+
def to_fxml(*args) # You need the *args so that it doesn't fail if there are :include or :methods params
|
|
15
|
+
empty? ? "<#{@class_name} type=\"array\"/>" : super.to_fxml
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
module ActiveSupport
|
|
20
|
+
module CoreExtensions
|
|
21
|
+
module Hash
|
|
22
|
+
module Conversions
|
|
23
|
+
def to_fxml(options = {})
|
|
24
|
+
options.merge!(:dasherize => false)
|
|
25
|
+
to_xml(options)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
module Array
|
|
30
|
+
module Conversions
|
|
31
|
+
def to_fxml(options = {})
|
|
32
|
+
options.merge!(:dasherize => false)
|
|
33
|
+
to_xml(options)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
module ActiveRecord
|
|
41
|
+
# Flex friendly XML serialization patches
|
|
42
|
+
class Base
|
|
43
|
+
class << self
|
|
44
|
+
alias_method :old_find, :find
|
|
45
|
+
|
|
46
|
+
def find(*args)
|
|
47
|
+
result = old_find(*args)
|
|
48
|
+
if result.class == Array and result.empty?
|
|
49
|
+
result = ClassyEmptyArray.new(self.class_name.tableize)
|
|
50
|
+
end
|
|
51
|
+
result
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# TODO: this doesn't work with hash based to_fxml(:include) options, only array based
|
|
55
|
+
def default_fxml_methods(*args)
|
|
56
|
+
methods = *args.dup
|
|
57
|
+
module_eval <<-END
|
|
58
|
+
def self.default_fxml_methods_array
|
|
59
|
+
return [#{methods.inspect}].flatten
|
|
60
|
+
end
|
|
61
|
+
END
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def default_fxml_includes(*args)
|
|
65
|
+
includes = *args.dup
|
|
66
|
+
module_eval <<-END
|
|
67
|
+
def self.default_fxml_include_params
|
|
68
|
+
return [#{includes.inspect}].flatten
|
|
69
|
+
end
|
|
70
|
+
END
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
module Serialization
|
|
76
|
+
def to_fxml(options = {})
|
|
77
|
+
options.merge!(:dasherize => false)
|
|
78
|
+
default_except = [:crypted_password, :salt, :remember_token, :remember_token_expires_at]
|
|
79
|
+
options[:except] = (options[:except] ? options[:except] + default_except : default_except)
|
|
80
|
+
options[:methods] = [options[:methods] || []].flatten + self.class.default_fxml_methods_array if self.class.respond_to?(:default_fxml_methods_array)
|
|
81
|
+
options[:include] = [options[:include] || []].flatten + self.class.default_fxml_include_params if self.class.respond_to?(:default_fxml_include_params)
|
|
82
|
+
to_xml(options)
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# Change the xml serializer so that '?'s are stripped from attribute names.
|
|
87
|
+
# This makes it possible to serialize methods that end in a question mark, like 'valid?' or 'is_true?'
|
|
88
|
+
class XmlSerializer
|
|
89
|
+
def add_tag(attribute)
|
|
90
|
+
builder.tag!(
|
|
91
|
+
dasherize? ? attribute.display_name.dasherize : attribute.display_name,
|
|
92
|
+
attribute.value.to_s,
|
|
93
|
+
attribute.decorations(!options[:skip_types])
|
|
94
|
+
)
|
|
95
|
+
end
|
|
96
|
+
class Attribute
|
|
97
|
+
def display_name
|
|
98
|
+
@name.gsub('?','')
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
# Add more extensive reporting on errors including field name along with a message
|
|
104
|
+
# when errors are serialized to XML
|
|
105
|
+
class Errors
|
|
106
|
+
def to_fxml(options={})
|
|
107
|
+
options[:root] ||= "errors"
|
|
108
|
+
options[:indent] ||= 2
|
|
109
|
+
options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent])
|
|
110
|
+
options[:builder].instruct! unless options.delete(:skip_instruct)
|
|
111
|
+
options[:builder].errors do |e|
|
|
112
|
+
# The @errors instance variable is a Hash inside the Errors class
|
|
113
|
+
@errors.each_key do |attr|
|
|
114
|
+
@errors[attr].each do |msg|
|
|
115
|
+
next if msg.nil?
|
|
116
|
+
if attr == "base"
|
|
117
|
+
options[:builder].error("message" => msg)
|
|
118
|
+
else
|
|
119
|
+
fullmsg = @base.class.human_attribute_name(attr) + ' ' + msg
|
|
120
|
+
options[:builder].error("field" => attr.camelcase(:lower), "message" => fullmsg)
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
require 'ruboss4ruby/tasks'
|
|
2
|
+
|
|
3
|
+
# these tasks are active record specific
|
|
4
|
+
|
|
5
|
+
APP_ENV = defined?(ENV['RAILS_ENV']) ? ENV['RAILS_ENV'] : ENV['MERB_ENV']
|
|
6
|
+
|
|
7
|
+
namespace :db do
|
|
8
|
+
namespace :mysql do
|
|
9
|
+
namespace :stage do
|
|
10
|
+
desc "Stage production, test and development databases"
|
|
11
|
+
task :all do
|
|
12
|
+
db_names = %w(development test production)
|
|
13
|
+
admin_password = ENV["ADMINPASS"] || ""
|
|
14
|
+
db_user_name = ENV["USER"] || "root"
|
|
15
|
+
db_password = ENV["PASS"] || ""
|
|
16
|
+
stage_database(db_names, admin_password, db_user_name, db_password)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
desc "Stage the database environment for #{APP_ENV}"
|
|
21
|
+
task :stage do
|
|
22
|
+
db_names = [APP_ENV]
|
|
23
|
+
admin_password = ENV["ADMINPASS"] || ""
|
|
24
|
+
db_user_name = ENV["USER"] || "root"
|
|
25
|
+
db_password = ENV["PASS"] || ""
|
|
26
|
+
stage_database(db_names, admin_password, db_user_name, db_password)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def stage_database(db_names, admin_password, db_user_name, db_password)
|
|
31
|
+
sql_command = ""
|
|
32
|
+
|
|
33
|
+
db_names.each do |name|
|
|
34
|
+
db_name = ActiveRecord::Base.configurations[name]['database']
|
|
35
|
+
sql_command += "drop database if exists #{db_name}; " <<
|
|
36
|
+
"create database #{db_name}; grant all privileges on #{db_name}.* " <<
|
|
37
|
+
"to #{db_user_name}@localhost identified by \'#{db_password}\';"
|
|
38
|
+
ActiveRecord::Base.configurations[name]['username'] = db_user_name
|
|
39
|
+
ActiveRecord::Base.configurations[name]['password'] = db_password
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
if (!File.exist?("#{APP_ROOT}/tmp/stage.sql"))
|
|
43
|
+
File.open("#{APP_ROOT}/tmp/stage.sql", "w") do |file|
|
|
44
|
+
file.print sql_command
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# back up the original database.yml file just in case
|
|
49
|
+
File.copy("#{APP_ROOT}/config/database.yml",
|
|
50
|
+
"#{APP_ROOT}/config/database.yml.sample") if !File.exist?("#{APP_ROOT}/config/database.yml.sample")
|
|
51
|
+
|
|
52
|
+
dbconfig = File.read("#{APP_ROOT}/config/database.yml")
|
|
53
|
+
dbconfig.gsub!(/username:.*/, "username: #{db_user_name}")
|
|
54
|
+
dbconfig.gsub!(/password:.*/, "password: #{db_password}")
|
|
55
|
+
|
|
56
|
+
File.open("#{APP_ROOT}/config/database.yml", "w") do |file|
|
|
57
|
+
file.print dbconfig
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
if system %(mysql -h localhost -u root --password=#{admin_password} < tmp/stage.sql)
|
|
61
|
+
puts "Updated config/database.yml and staged the database based on your settings"
|
|
62
|
+
File.delete("tmp/stage.sql") if File.file?("tmp/stage.sql")
|
|
63
|
+
else
|
|
64
|
+
puts "Staging was not performed. Check console for errors. It is possible that 'mysql' executable was not found."
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
desc "Drop the database environment for #{APP_ENV} only if it exists"
|
|
69
|
+
task :drop_if_exists do
|
|
70
|
+
Rake::Task["db:drop"].invoke rescue nil
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
desc "Refresh the database environment for #{APP_ENV}"
|
|
74
|
+
task :refresh => ['db:drop_if_exists', 'db:create', 'db:migrate', 'db:fixtures:load']
|
|
75
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
class String
|
|
2
|
+
def capitalize_without_downcasing
|
|
3
|
+
self[0,1].capitalize + self[1..-1]
|
|
4
|
+
end
|
|
5
|
+
def downcase_first_letter
|
|
6
|
+
self[0,1].downcase + self[1..-1]
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
module Ruboss
|
|
11
|
+
module Configuration
|
|
12
|
+
APP_ROOT = defined?(RAILS_ROOT) ? RAILS_ROOT : Merb.root
|
|
13
|
+
|
|
14
|
+
def extract_names
|
|
15
|
+
project_name = APP_ROOT.split("/").last.camelcase
|
|
16
|
+
project_name_downcase = project_name.downcase
|
|
17
|
+
|
|
18
|
+
begin
|
|
19
|
+
config = YAML.load(File.open("#{APP_ROOT}/config/ruboss.yml"))
|
|
20
|
+
base_package = config['base-package'] || project_name_downcase
|
|
21
|
+
base_folder = base_package.gsub('.', '/')
|
|
22
|
+
controller_name = config['controller-name'] || "#{project_name}Controller"
|
|
23
|
+
rescue
|
|
24
|
+
base_folder = base_package = project_name_downcase
|
|
25
|
+
controller_name = "#{project_name}Controller"
|
|
26
|
+
end
|
|
27
|
+
[project_name, project_name_downcase, controller_name, base_package, base_folder]
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def list_as_files(dir_name)
|
|
31
|
+
Dir.entries(dir_name).grep(/\.as$/).map { |name| name.sub(/\.as$/, "") }.join(", ")
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def list_mxml_files(dir_name)
|
|
35
|
+
Dir.entries(dir_name).grep(/\.mxml$/).map { |name| name.sub(/\.mxml$/, "") }
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
require 'rake'
|
|
2
|
+
require 'ftools'
|
|
3
|
+
require 'rexml/document'
|
|
4
|
+
require 'ruboss4ruby/version'
|
|
5
|
+
require 'ruboss4ruby/configuration'
|
|
6
|
+
|
|
7
|
+
APP_ROOT = Ruboss::Configuration::APP_ROOT
|
|
8
|
+
|
|
9
|
+
namespace :ruboss do
|
|
10
|
+
def compile_app(executable, destination)
|
|
11
|
+
app_properties = REXML::Document.new(File.open(File.join(APP_ROOT, ".actionScriptProperties")))
|
|
12
|
+
app_properties.elements.each("*/applications/application") do |elm|
|
|
13
|
+
app_path = elm.attributes['path']
|
|
14
|
+
project_path = File.join(APP_ROOT, "app/flex", app_path)
|
|
15
|
+
target_project_path = project_path.sub(/.mxml$/, '.swf')
|
|
16
|
+
target_project_air_descriptor = project_path.sub(/.mxml$/, '-app.xml')
|
|
17
|
+
|
|
18
|
+
libs = Dir.glob(File.join(APP_ROOT, 'lib', '*.swc'))
|
|
19
|
+
|
|
20
|
+
cmd = "#{executable} -library-path+=#{libs.join(',')} " <<
|
|
21
|
+
"-keep-as3-metadata+=Resource,HasOne,HasMany,BelongsTo,DateTime,Lazy,Ignored #{project_path}"
|
|
22
|
+
puts "Compiling #{project_path}"
|
|
23
|
+
if system(cmd)
|
|
24
|
+
FileUtils.makedirs File.join(APP_ROOT, destination)
|
|
25
|
+
puts "Moving #{target_project_path} to " + File.join(APP_ROOT, destination)
|
|
26
|
+
FileUtils.mv target_project_path, File.join(APP_ROOT, destination), :force => true
|
|
27
|
+
if File.exist?(target_project_air_descriptor)
|
|
28
|
+
descriptor = File.read(target_project_air_descriptor)
|
|
29
|
+
descriptor_name = target_project_air_descriptor.split("/").last
|
|
30
|
+
app_swf = target_project_path.split("/").last
|
|
31
|
+
descriptor.gsub!("[This value will be overwritten by Flex Builder in the output app.xml]",
|
|
32
|
+
app_swf)
|
|
33
|
+
|
|
34
|
+
File.open("#{APP_ROOT}/#{destination}/#{descriptor_name}", "w") do |file|
|
|
35
|
+
file.print descriptor
|
|
36
|
+
end
|
|
37
|
+
puts "Created #{APP_ROOT}/#{destination}/#{descriptor_name} descriptor."
|
|
38
|
+
end
|
|
39
|
+
puts 'Done!'
|
|
40
|
+
else
|
|
41
|
+
puts "The application was not compiled. Check console for errors. " <<
|
|
42
|
+
"It is possible that '(a)mxmlc' executable was not found or there are compilation errors."
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def get_main_application
|
|
48
|
+
app_properties = REXML::Document.new(File.open(File.join(APP_ROOT, ".actionScriptProperties")))
|
|
49
|
+
app_properties.root.attributes['mainApplicationPath'].split("/").last
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def get_executable(executable)
|
|
53
|
+
if RUBY_PLATFORM =~ /mswin32/
|
|
54
|
+
executable << '.exe'
|
|
55
|
+
end
|
|
56
|
+
executable
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
namespace :flex do
|
|
60
|
+
desc "Build project swf file and move it into public/bin folder"
|
|
61
|
+
task :build do
|
|
62
|
+
compile_app(get_executable('mxmlc'), 'public/bin')
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
namespace :air do
|
|
67
|
+
desc "Build project swf file as an AIR application and move it into bin-debug folder"
|
|
68
|
+
task :build do
|
|
69
|
+
compile_app(get_executable('amxmlc'), 'bin-debug')
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
desc "Run the AIR application (if this project is configured as an AIR project)"
|
|
73
|
+
task :run do
|
|
74
|
+
target = get_main_application.gsub(/.mxml$/, '-app.xml')
|
|
75
|
+
puts "Running AIR application with descriptor: #{target}"
|
|
76
|
+
if !system("#{get_executable('adl')} bin-debug/#{target}")
|
|
77
|
+
puts "Could not run the application with descriptor: #{target}. Check console for errors."
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
data/lib/ruboss4ruby.rb
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Merb specific handling
|
|
2
|
+
# make sure we're running inside Merb
|
|
3
|
+
if defined?(Merb::Plugins)
|
|
4
|
+
Merb::BootLoader.before_app_loads do
|
|
5
|
+
Merb.add_mime_type(:fxml, :to_fxml, %w[application/xml text/xml application/x-xml], :charset => "utf-8")
|
|
6
|
+
|
|
7
|
+
require 'ruboss4ruby/version'
|
|
8
|
+
require 'ruboss4ruby/configuration'
|
|
9
|
+
require 'ruboss4ruby/active_foo' if defined?(ActiveRecord::Base)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# TODO: can we find out if use_orm :activerecord is on and only then load active record specific tasks?
|
|
13
|
+
Merb::Plugins.add_rakefiles "ruboss4ruby/tasks", "ruboss4ruby/active_record_tasks"
|
|
14
|
+
elsif defined?(ActionController::Base)
|
|
15
|
+
# if we are not running in Merb, we've got to be running in Rails
|
|
16
|
+
Mime::Type.register_alias "application/xml", :fxml
|
|
17
|
+
|
|
18
|
+
require 'ruboss4ruby/version'
|
|
19
|
+
require 'ruboss4ruby/configuration'
|
|
20
|
+
require 'ruboss4ruby/active_foo'
|
|
21
|
+
|
|
22
|
+
module ActionController
|
|
23
|
+
class Base
|
|
24
|
+
alias_method :old_render, :render unless method_defined?(:old_render)
|
|
25
|
+
|
|
26
|
+
# so that we can have handling for :fxml option and write code like
|
|
27
|
+
# format.fxml { render :fxml => @projects }
|
|
28
|
+
def render(options = nil, extra_options = {}, &block)
|
|
29
|
+
if options && options[:fxml]
|
|
30
|
+
xml = options[:fxml]
|
|
31
|
+
response.content_type ||= Mime::XML
|
|
32
|
+
render_for_text(xml.respond_to?(:to_fxml) ? xml.to_fxml : xml, options[:status])
|
|
33
|
+
else
|
|
34
|
+
old_render(options, extra_options, &block)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
module RubossController
|
|
41
|
+
private
|
|
42
|
+
|
|
43
|
+
# Extract any keys named _metadata from the models in the params hash
|
|
44
|
+
# and put them in the root of the params hash.
|
|
45
|
+
def extract_metadata_from_params
|
|
46
|
+
metadata = {}
|
|
47
|
+
metadata.merge!(params.delete('_metadata')) if params.has_key?('_metadata')
|
|
48
|
+
params.each do |k, v|
|
|
49
|
+
next unless v.respond_to?(:has_key?) and v.has_key?('_metadata')
|
|
50
|
+
metadata.merge!(v.delete('_metadata'))
|
|
51
|
+
end
|
|
52
|
+
params.merge!(metadata) unless metadata.empty?
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# temporarily disable forgery protection site-wise
|
|
57
|
+
ActionController::Base.allow_forgery_protection = false
|
|
58
|
+
|
|
59
|
+
ActionController::Base.send :include, RubossController
|
|
60
|
+
ActionController::Base.send :prepend_before_filter, :extract_metadata_from_params
|
|
61
|
+
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
|
+
`merb-gen ruboss_config` # generates project structure and a
|
|
12
|
+
# default Flex app configuration. Fetches
|
|
13
|
+
# latest ruboss framework SWC to "lib"
|
|
14
|
+
# folder
|
|
15
|
+
`merb-gen ruboss_config -a` # as above but generates an AIR app
|
|
16
|
+
# and configuration
|
|
17
|
+
`merb-gen ruboss_config -s` # generates Flex app but does not fetch
|
|
18
|
+
# the ruboss framework SWC.
|
|
@@ -0,0 +1,135 @@
|
|
|
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 'fileutils'
|
|
16
|
+
require 'ruboss4ruby/version'
|
|
17
|
+
require 'ruboss4ruby/configuration'
|
|
18
|
+
|
|
19
|
+
class RubossConfigGenerator < Merb::GeneratorBase
|
|
20
|
+
include Ruboss::Configuration
|
|
21
|
+
|
|
22
|
+
default_options :main_only => false, :air_config => false, :skip_framework => false
|
|
23
|
+
|
|
24
|
+
attr_reader :project_name,
|
|
25
|
+
:flex_project_name,
|
|
26
|
+
:base_package,
|
|
27
|
+
:base_folder,
|
|
28
|
+
:command_controller_name,
|
|
29
|
+
:component_names,
|
|
30
|
+
:application_tag,
|
|
31
|
+
:use_air
|
|
32
|
+
|
|
33
|
+
def initialize(runtime_args, runtime_options = {})
|
|
34
|
+
runtime_args.push ""
|
|
35
|
+
super
|
|
36
|
+
|
|
37
|
+
@project_name, @flex_project_name, @command_controller_name, @base_package, @base_folder = extract_names
|
|
38
|
+
|
|
39
|
+
# if we updating main file only we probably want to maintain the type of project it is
|
|
40
|
+
if options[:main_only]
|
|
41
|
+
project_file_name = APP_ROOT + '/.project'
|
|
42
|
+
if File.exist?(project_file_name)
|
|
43
|
+
puts "Cannot combine -m (--main-app) and -a (--air) flags at the same time for an existing application.\n" <<
|
|
44
|
+
'If you want to convert to AIR, remove -m flag.' if options[:air_config]
|
|
45
|
+
@use_air = true if File.read(project_file_name) =~/com.adobe.flexbuilder.apollo.apollobuilder/m
|
|
46
|
+
else
|
|
47
|
+
puts "Flex Builder project file doesn't exist. You should run 'ruboss_config' with -a (--air) option or " <<
|
|
48
|
+
"no arguments first to generate primary project structure."
|
|
49
|
+
exit 0;
|
|
50
|
+
end
|
|
51
|
+
else
|
|
52
|
+
@use_air = options[:air_config]
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
if @use_air
|
|
56
|
+
@application_tag = 'WindowedApplication'
|
|
57
|
+
else
|
|
58
|
+
@application_tag = 'Application'
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
@component_names = []
|
|
62
|
+
if File.exists?("app/flex/#{base_folder}/components/generated")
|
|
63
|
+
@component_names = list_mxml_files("app/flex/#{base_folder}/components/generated")
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def manifest
|
|
68
|
+
record do |m|
|
|
69
|
+
if !options[:main_only]
|
|
70
|
+
m.directory 'public/bin'
|
|
71
|
+
m.directory 'public/javascripts'
|
|
72
|
+
m.directory 'schema'
|
|
73
|
+
|
|
74
|
+
m.file 'flex.properties', '.flexProperties'
|
|
75
|
+
if @use_air
|
|
76
|
+
m.template 'actionscriptair.properties', '.actionScriptProperties'
|
|
77
|
+
m.template 'projectair.properties', '.project'
|
|
78
|
+
else
|
|
79
|
+
m.template 'actionscript.properties', '.actionScriptProperties'
|
|
80
|
+
m.template 'project.properties', '.project'
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
m.directory 'html-template/history'
|
|
84
|
+
%w(index.template.html AC_OETags.js playerProductInstall.swf).each do |file|
|
|
85
|
+
m.file "html-template/#{file}", "html-template/#{file}"
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
%w(history.css history.js historyFrame.html).each do |file|
|
|
89
|
+
m.file "html-template/history/#{file}", "html-template/history/#{file}"
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
%w(components controllers commands models events).each do |dir|
|
|
93
|
+
m.directory "app/flex/#{base_folder}/#{dir}"
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
m.directory "app/flex/#{base_folder}/components/generated"
|
|
97
|
+
|
|
98
|
+
framework_release = Ruboss::RUBOSS_FRAMEWORK_VERSION
|
|
99
|
+
framework_distribution_url = "http://ruboss.com/releases/ruboss-#{framework_release}.swc"
|
|
100
|
+
framework_destination_file = "lib/ruboss-#{framework_release}.swc"
|
|
101
|
+
|
|
102
|
+
if !options[:skip_framework] && !File.exist?(framework_destination_file)
|
|
103
|
+
FileUtils.mkdir('lib') unless File.directory?('lib')
|
|
104
|
+
puts "fetching #{framework_release} framework binary from: #{framework_distribution_url} ..."
|
|
105
|
+
open(framework_destination_file, "wb").write(open(framework_distribution_url).read)
|
|
106
|
+
puts "done. saved to #{framework_destination_file}"
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
m.file 'swfobject.js', 'public/javascripts/swfobject.js'
|
|
110
|
+
m.file 'expressInstall.swf', 'public/expressInstall.swf'
|
|
111
|
+
m.template 'index.html.erb', 'app/views/layout/application.html.erb'
|
|
112
|
+
|
|
113
|
+
m.dependency 'ruboss_controller', @args
|
|
114
|
+
end
|
|
115
|
+
m.template 'mainapp.mxml', File.join('app/flex', "#{project_name}.mxml")
|
|
116
|
+
m.template 'mainair-app.xml', File.join('app/flex', "#{project_name}-app.xml") if @use_air
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
protected
|
|
121
|
+
def add_options!(opt)
|
|
122
|
+
opt.separator ''
|
|
123
|
+
opt.separator 'Options:'
|
|
124
|
+
opt.on("-m", "--main-only", "Only generate the main Flex/AIR application file.",
|
|
125
|
+
"Default: false") { |v| options[:main_only] = v }
|
|
126
|
+
opt.on("-a", "--air", "Configure AIR project instead of Flex. Flex is default.",
|
|
127
|
+
"Default: false") { |v| options[:air_config] = v }
|
|
128
|
+
opt.on("-s", "--skip-framework", "Don't fetch the latest framework binary. You'll have to link/build the framework yourself.",
|
|
129
|
+
"Default: false") { |v| options[:skip_framework] = v }
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def banner
|
|
133
|
+
"Usage: #{$0} #{spec.name}"
|
|
134
|
+
end
|
|
135
|
+
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:4000/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>
|
|
@@ -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="false" htmlHistoryManagement="false" htmlPlayerVersion="9.0.28" htmlPlayerVersionCheck="true" outputFolderPath="bin-debug" sourceFolderPath="app/flex" strict="true" useApolloConfig="true" 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>
|
|
Binary file
|