ruboss_on_ruby 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. data/History.txt +3 -0
  2. data/Manifest.txt +101 -0
  3. data/README.txt +37 -0
  4. data/Rakefile +4 -0
  5. data/config/hoe.rb +72 -0
  6. data/config/requirements.rb +15 -0
  7. data/gpl-3.0.txt +674 -0
  8. data/lib/ruboss_on_ruby.rb +64 -0
  9. data/lib/ruboss_on_ruby/active_foo.rb +127 -0
  10. data/lib/ruboss_on_ruby/active_record_tasks.rb +75 -0
  11. data/lib/ruboss_on_ruby/configuration.rb +38 -0
  12. data/lib/ruboss_on_ruby/tasks.rb +74 -0
  13. data/lib/ruboss_on_ruby/version.rb +11 -0
  14. data/merb_generators/ruboss_config/USAGE +18 -0
  15. data/merb_generators/ruboss_config/ruboss_config_generator.rb +135 -0
  16. data/merb_generators/ruboss_config/templates/actionscript.properties +16 -0
  17. data/merb_generators/ruboss_config/templates/actionscriptair.properties +16 -0
  18. data/merb_generators/ruboss_config/templates/expressInstall.swf +0 -0
  19. data/merb_generators/ruboss_config/templates/flex.properties +2 -0
  20. data/merb_generators/ruboss_config/templates/html-template/AC_OETags.js +276 -0
  21. data/merb_generators/ruboss_config/templates/html-template/history/history.css +6 -0
  22. data/merb_generators/ruboss_config/templates/html-template/history/history.js +645 -0
  23. data/merb_generators/ruboss_config/templates/html-template/history/historyFrame.html +29 -0
  24. data/merb_generators/ruboss_config/templates/html-template/index.template.html +121 -0
  25. data/merb_generators/ruboss_config/templates/html-template/playerProductInstall.swf +0 -0
  26. data/merb_generators/ruboss_config/templates/index.html.erb +19 -0
  27. data/merb_generators/ruboss_config/templates/mainair-app.xml +134 -0
  28. data/merb_generators/ruboss_config/templates/mainapp.mxml +34 -0
  29. data/merb_generators/ruboss_config/templates/project.properties +18 -0
  30. data/merb_generators/ruboss_config/templates/projectair.properties +24 -0
  31. data/merb_generators/ruboss_config/templates/swfobject.js +5 -0
  32. data/merb_generators/ruboss_controller/USAGE +11 -0
  33. data/merb_generators/ruboss_controller/ruboss_controller_generator.rb +32 -0
  34. data/merb_generators/ruboss_controller/templates/controller.as.erb +35 -0
  35. data/merb_generators/ruboss_resource_controller/USAGE +5 -0
  36. data/merb_generators/ruboss_resource_controller/ruboss_resource_controller_generator.rb +70 -0
  37. data/merb_generators/ruboss_resource_controller/templates/app/controllers/%controller_file_name%.rb +55 -0
  38. data/merb_generators/ruboss_resource_controller/templates/app/helpers/%controller_file_name%_helper.rb +16 -0
  39. data/merb_generators/ruboss_scaffold/USAGE +5 -0
  40. data/merb_generators/ruboss_scaffold/ruboss_scaffold_generator.rb +190 -0
  41. data/merb_generators/ruboss_scaffold/templates/component.mxml.erb +148 -0
  42. data/merb_generators/ruboss_scaffold/templates/fixtures.yml.erb +35 -0
  43. data/merb_generators/ruboss_scaffold/templates/migration.rb.erb +19 -0
  44. data/merb_generators/ruboss_scaffold/templates/model.as.erb +42 -0
  45. data/merb_generators/ruboss_scaffold/templates/model.rb.erb +11 -0
  46. data/merb_generators/ruboss_yaml_scaffold/USAGE +5 -0
  47. data/merb_generators/ruboss_yaml_scaffold/ruboss_yaml_scaffold_generator.rb +53 -0
  48. data/rails_generators/ruboss_config/USAGE +18 -0
  49. data/rails_generators/ruboss_config/ruboss_config_generator.rb +126 -0
  50. data/rails_generators/ruboss_config/templates/actionscript.properties +16 -0
  51. data/rails_generators/ruboss_config/templates/actionscriptair.properties +16 -0
  52. data/rails_generators/ruboss_config/templates/expressInstall.swf +0 -0
  53. data/rails_generators/ruboss_config/templates/flex.properties +2 -0
  54. data/rails_generators/ruboss_config/templates/html-template/AC_OETags.js +276 -0
  55. data/rails_generators/ruboss_config/templates/html-template/history/history.css +6 -0
  56. data/rails_generators/ruboss_config/templates/html-template/history/history.js +645 -0
  57. data/rails_generators/ruboss_config/templates/html-template/history/historyFrame.html +29 -0
  58. data/rails_generators/ruboss_config/templates/html-template/index.template.html +121 -0
  59. data/rails_generators/ruboss_config/templates/html-template/playerProductInstall.swf +0 -0
  60. data/rails_generators/ruboss_config/templates/index.html.erb +19 -0
  61. data/rails_generators/ruboss_config/templates/mainair-app.xml +134 -0
  62. data/rails_generators/ruboss_config/templates/mainapp.mxml +34 -0
  63. data/rails_generators/ruboss_config/templates/project.properties +18 -0
  64. data/rails_generators/ruboss_config/templates/projectair.properties +24 -0
  65. data/rails_generators/ruboss_config/templates/ruboss_tasks.rake +15 -0
  66. data/rails_generators/ruboss_config/templates/swfobject.js +5 -0
  67. data/rails_generators/ruboss_controller/USAGE +11 -0
  68. data/rails_generators/ruboss_controller/ruboss_controller_generator.rb +46 -0
  69. data/rails_generators/ruboss_controller/templates/controller.as.erb +35 -0
  70. data/rails_generators/ruboss_scaffold/USAGE +35 -0
  71. data/rails_generators/ruboss_scaffold/ruboss_scaffold_generator.rb +193 -0
  72. data/rails_generators/ruboss_scaffold/templates/component.mxml.erb +148 -0
  73. data/rails_generators/ruboss_scaffold/templates/controller.rb.erb +97 -0
  74. data/rails_generators/ruboss_scaffold/templates/fixtures.yml.erb +35 -0
  75. data/rails_generators/ruboss_scaffold/templates/migration.rb.erb +19 -0
  76. data/rails_generators/ruboss_scaffold/templates/model.as.erb +42 -0
  77. data/rails_generators/ruboss_scaffold/templates/model.rb.erb +11 -0
  78. data/rails_generators/ruboss_yaml_scaffold/USAGE +14 -0
  79. data/rails_generators/ruboss_yaml_scaffold/ruboss_yaml_scaffold_generator.rb +45 -0
  80. data/rcl-1.0.txt +0 -0
  81. data/script/console +10 -0
  82. data/script/destroy +14 -0
  83. data/script/generate +14 -0
  84. data/script/txt2html +82 -0
  85. data/setup.rb +1585 -0
  86. data/tasks/deployment.rake +34 -0
  87. data/tasks/environment.rake +7 -0
  88. data/tasks/website.rake +17 -0
  89. data/test/active_foo_test.rb +16 -0
  90. data/test/test_generator_helper.rb +29 -0
  91. data/test/test_helper.rb +2 -0
  92. data/test/test_ruboss_config_generator.rb +45 -0
  93. data/test/test_ruboss_controller_generator.rb +45 -0
  94. data/test/test_ruboss_on_ruby.rb +11 -0
  95. data/test/test_ruboss_scaffold_generator.rb +45 -0
  96. data/test/test_ruboss_yaml_scaffold_generator.rb +46 -0
  97. data/website/index.html +86 -0
  98. data/website/index.txt +83 -0
  99. data/website/javascripts/rounded_corners_lite.inc.js +285 -0
  100. data/website/stylesheets/screen.css +138 -0
  101. data/website/template.html.erb +48 -0
  102. metadata +166 -0
@@ -0,0 +1,64 @@
1
+ #$:.unshift(File.dirname(__FILE__)) unless
2
+ # $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
4
+ # Merb specific handling
5
+ # make sure we're running inside Merb
6
+ if defined?(Merb::Plugins)
7
+ Merb::BootLoader.before_app_loads do
8
+ Merb.add_mime_type(:fxml, :to_fxml, %w[application/xml text/xml application/x-xml], :charset => "utf-8")
9
+
10
+ require 'ruboss_on_ruby/version'
11
+ require 'ruboss_on_ruby/configuration'
12
+ require 'ruboss_on_ruby/active_foo' if defined?(ActiveRecord::Base)
13
+ end
14
+
15
+ # TODO: can we find out if use_orm :activerecord is on and only then load active record specific tasks?
16
+ Merb::Plugins.add_rakefiles "ruboss_on_ruby/tasks", "ruboss_on_ruby/active_record_tasks"
17
+ elsif defined?(ActionController::Base)
18
+ # if we are not running in Merb, we've got to be running in Rails
19
+ Mime::Type.register_alias "application/xml", :fxml
20
+
21
+ require 'ruboss_on_ruby/version'
22
+ require 'ruboss_on_ruby/configuration'
23
+ require 'ruboss_on_ruby/active_foo'
24
+
25
+ module ActionController
26
+ class Base
27
+ alias_method :old_render, :render
28
+
29
+ # so that we can have handling for :fxml option and write code like
30
+ # format.fxml { render :fxml => @projects }
31
+ def render(options = nil, extra_options = {}, &block)
32
+ if options and options[:fxml]
33
+ xml = options[:fxml]
34
+ response.content_type ||= Mime::XML
35
+ render_for_text(xml.respond_to?(:to_fxml) ? xml.to_fxml : xml, options[:status])
36
+ else
37
+ old_render(options, extra_options, &block)
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ module RubossOnRubyController
44
+ private
45
+
46
+ # Extract any keys named _metadata from the models in the params hash
47
+ # and put them in the root of the params hash.
48
+ def extract_metadata_from_params
49
+ metadata = {}
50
+ metadata.merge!(params.delete('_metadata')) if params.has_key?('_metadata')
51
+ params.each do |k, v|
52
+ next unless v.respond_to?(:has_key?) and v.has_key?('_metadata')
53
+ metadata.merge!(v.delete('_metadata'))
54
+ end
55
+ params.merge!(metadata) unless metadata.empty?
56
+ end
57
+ end
58
+
59
+ # temporarily disable forgery protection site-wise
60
+ ActionController::Base.allow_forgery_protection = false
61
+
62
+ ActionController::Base.send :include, RubossOnRubyController
63
+ ActionController::Base.send :prepend_before_filter, :extract_metadata_from_params
64
+ end
@@ -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 'ruboss_on_ruby/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 RubossOnRuby
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,74 @@
1
+ require 'rake'
2
+ require 'ftools'
3
+ require 'rexml/document'
4
+ require 'ruboss_on_ruby/version'
5
+ require 'ruboss_on_ruby/configuration'
6
+
7
+ APP_ROOT = RubossOnRuby::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
+ namespace :flex do
53
+ desc "Build project swf file and move it into public/bin folder"
54
+ task :build do
55
+ compile_app('mxmlc', 'public/bin')
56
+ end
57
+ end
58
+
59
+ namespace :air do
60
+ desc "Build project swf file as an AIR application and move it into bin-debug folder"
61
+ task :build do
62
+ compile_app('amxmlc', 'bin-debug')
63
+ end
64
+
65
+ desc "Run the AIR application (if this project is configured as an AIR project)"
66
+ task :run do
67
+ target = get_main_application.gsub(/.mxml$/, '-app.xml')
68
+ puts "Running AIR application with descriptor: #{target}"
69
+ if !system("adl bin-debug/#{target}")
70
+ puts "Could not run the application with descriptor: #{target}. Check console for errors."
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,11 @@
1
+ module RubossOnRuby #:nodoc:
2
+ RUBOSS_FRAMEWORK_VERSION = 'latest-dima'
3
+
4
+ module VERSION #:nodoc:
5
+ MAJOR = 1
6
+ MINOR = 0
7
+ TINY = 1
8
+
9
+ STRING = [MAJOR, MINOR, TINY].join('.')
10
+ end
11
+ 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 'ruboss_on_ruby/version'
17
+ require 'ruboss_on_ruby/configuration'
18
+
19
+ class RubossConfigGenerator < Merb::GeneratorBase
20
+ include RubossOnRuby::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 = RubossOnRuby::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