captproton-restfulx 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +50 -0
- data/Rakefile +79 -0
- data/VERSION.yml +4 -0
- data/app_generators/rx_app/USAGE +22 -0
- data/app_generators/rx_app/rx_app_generator.rb +110 -0
- data/app_generators/rx_app/templates/actionscript.properties +16 -0
- data/app_generators/rx_app/templates/actionscriptair.properties +16 -0
- data/app_generators/rx_app/templates/app.yaml.erb +12 -0
- data/app_generators/rx_app/templates/default_tasks.rake +38 -0
- data/app_generators/rx_app/templates/empty.txt +0 -0
- data/app_generators/rx_app/templates/expressInstall.swf +0 -0
- data/app_generators/rx_app/templates/flex.properties +2 -0
- data/app_generators/rx_app/templates/generate.rb +17 -0
- data/app_generators/rx_app/templates/html-template/AC_OETags.js +276 -0
- data/app_generators/rx_app/templates/html-template/history/history.css +6 -0
- data/app_generators/rx_app/templates/html-template/history/history.js +645 -0
- data/app_generators/rx_app/templates/html-template/history/historyFrame.html +29 -0
- data/app_generators/rx_app/templates/html-template/index.template.html +121 -0
- data/app_generators/rx_app/templates/html-template/playerProductInstall.swf +0 -0
- data/app_generators/rx_app/templates/index.html.erb +18 -0
- data/app_generators/rx_app/templates/index.yaml +11 -0
- data/app_generators/rx_app/templates/mainair-app.xml +134 -0
- data/app_generators/rx_app/templates/mainapp-config.xml +22 -0
- data/app_generators/rx_app/templates/mainapp.mxml +152 -0
- data/app_generators/rx_app/templates/project-textmate.erb +72 -0
- data/app_generators/rx_app/templates/project.properties +18 -0
- data/app_generators/rx_app/templates/projectair.properties +24 -0
- data/app_generators/rx_app/templates/restfulx.yml +46 -0
- data/app_generators/rx_app/templates/swfobject.js +5 -0
- data/bin/rx-gen +31 -0
- data/lib/restfulx.rb +90 -0
- data/lib/restfulx/active_foo.rb +181 -0
- data/lib/restfulx/active_record_tasks.rb +90 -0
- data/lib/restfulx/active_record_uuid_helper.rb +17 -0
- data/lib/restfulx/configuration.rb +75 -0
- data/lib/restfulx/datamapper_foo.rb +81 -0
- data/lib/restfulx/rails/recipes.rb +60 -0
- data/lib/restfulx/rails/schema_to_yaml.rb +112 -0
- data/lib/restfulx/rails/schema_to_yaml/extensions/enumerable.rb +8 -0
- data/lib/restfulx/rails/schema_to_yaml/settings/config.rb +17 -0
- data/lib/restfulx/rails/schema_to_yaml/settings/core.rb +73 -0
- data/lib/restfulx/rails/swf_helper.rb +59 -0
- data/lib/restfulx/tasks.rb +110 -0
- data/rails_generators/rx_config/USAGE +19 -0
- data/rails_generators/rx_config/rx_config_generator.rb +151 -0
- data/rails_generators/rx_config/templates/actionscript.properties +16 -0
- data/rails_generators/rx_config/templates/actionscriptair.properties +16 -0
- data/rails_generators/rx_config/templates/expressInstall.swf +0 -0
- data/rails_generators/rx_config/templates/flex.properties +2 -0
- data/rails_generators/rx_config/templates/flex_controller.erb +4 -0
- data/rails_generators/rx_config/templates/html-template/AC_OETags.js +276 -0
- data/rails_generators/rx_config/templates/html-template/history/history.css +6 -0
- data/rails_generators/rx_config/templates/html-template/history/history.js +645 -0
- data/rails_generators/rx_config/templates/html-template/history/historyFrame.html +29 -0
- data/rails_generators/rx_config/templates/html-template/index.template.html +121 -0
- data/rails_generators/rx_config/templates/html-template/playerProductInstall.swf +0 -0
- data/rails_generators/rx_config/templates/index.erb +16 -0
- data/rails_generators/rx_config/templates/mainair-app.xml +134 -0
- data/rails_generators/rx_config/templates/mainapp-config.xml +22 -0
- data/rails_generators/rx_config/templates/mainapp.mxml +129 -0
- data/rails_generators/rx_config/templates/project-textmate.erb +72 -0
- data/rails_generators/rx_config/templates/project.properties +18 -0
- data/rails_generators/rx_config/templates/projectair.properties +24 -0
- data/rails_generators/rx_config/templates/restfulx.erb +75 -0
- data/rails_generators/rx_config/templates/restfulx.yml +65 -0
- data/rails_generators/rx_config/templates/restfulx_tasks.rake +9 -0
- data/rails_generators/rx_config/templates/routes.erb +47 -0
- data/rails_generators/rx_config/templates/session_store_flash.erb +1 -0
- data/rails_generators/rx_config/templates/swfobject.js +5 -0
- data/rails_generators/rx_controller/USAGE +10 -0
- data/rails_generators/rx_controller/rx_controller_generator.rb +31 -0
- data/rails_generators/rx_controller/templates/controller.as.erb +38 -0
- data/rails_generators/rx_main_app/USAGE +8 -0
- data/rails_generators/rx_main_app/rx_main_app_generator.rb +60 -0
- data/rails_generators/rx_main_app/templates/mainapp.mxml +129 -0
- data/rails_generators/rx_scaffold/USAGE +35 -0
- data/rails_generators/rx_scaffold/rx_scaffold_generator.rb +242 -0
- data/rails_generators/rx_scaffold/templates/controllers/default.rb.erb +125 -0
- data/rails_generators/rx_scaffold/templates/controllers/resource_controller.rb.erb +23 -0
- data/rails_generators/rx_scaffold/templates/fixtures.yml.erb +39 -0
- data/rails_generators/rx_scaffold/templates/functional_test.rb +45 -0
- data/rails_generators/rx_scaffold/templates/helper_test.rb +4 -0
- data/rails_generators/rx_scaffold/templates/layouts/default.erb +167 -0
- data/rails_generators/rx_scaffold/templates/migration.rb.erb +46 -0
- data/rails_generators/rx_scaffold/templates/model.as.erb +73 -0
- data/rails_generators/rx_scaffold/templates/model.rb.erb +46 -0
- data/rails_generators/rx_yaml_scaffold/USAGE +51 -0
- data/rails_generators/rx_yaml_scaffold/rx_yaml_scaffold_generator.rb +68 -0
- data/rxgen_generators/rx_config/USAGE +5 -0
- data/rxgen_generators/rx_config/rx_config_generator.rb +21 -0
- data/rxgen_generators/rx_controller/USAGE +10 -0
- data/rxgen_generators/rx_controller/rx_controller_generator.rb +41 -0
- data/rxgen_generators/rx_controller/templates/assist.py +65 -0
- data/rxgen_generators/rx_controller/templates/controller.as.erb +38 -0
- data/rxgen_generators/rx_controller/templates/iso8601.py +92 -0
- data/rxgen_generators/rx_controller/templates/restful.py +136 -0
- data/rxgen_generators/rx_main_app/USAGE +8 -0
- data/rxgen_generators/rx_main_app/rx_main_app_generator.rb +65 -0
- data/rxgen_generators/rx_main_app/templates/main.py.erb +29 -0
- data/rxgen_generators/rx_main_app/templates/mainapp.mxml +152 -0
- data/rxgen_generators/rx_scaffold/USAGE +29 -0
- data/rxgen_generators/rx_scaffold/rx_scaffold_generator.rb +194 -0
- data/rxgen_generators/rx_scaffold/templates/controller.py.erb +27 -0
- data/rxgen_generators/rx_scaffold/templates/layouts/default.erb +167 -0
- data/rxgen_generators/rx_scaffold/templates/model.as.erb +73 -0
- data/rxgen_generators/rx_scaffold/templates/model.py.erb +14 -0
- data/rxgen_generators/rx_yaml_scaffold/USAGE +45 -0
- data/rxgen_generators/rx_yaml_scaffold/rx_yaml_scaffold_generator.rb +47 -0
- data/spec/restfulx_spec.rb +4 -0
- data/spec/spec_helper.rb +13 -0
- data/tasks/restfulx.rake +2 -0
- data/test/rails/controllers/application_controller.rb +15 -0
- data/test/rails/controllers/locations_controller.rb +93 -0
- data/test/rails/controllers/notes_controller.rb +96 -0
- data/test/rails/controllers/projects_controller.rb +93 -0
- data/test/rails/controllers/tasks_controller.rb +93 -0
- data/test/rails/controllers/users_controller.rb +93 -0
- data/test/rails/database.yml +4 -0
- data/test/rails/fixtures/locations.yml +8 -0
- data/test/rails/fixtures/notes.yml +17 -0
- data/test/rails/fixtures/projects.yml +25 -0
- data/test/rails/fixtures/simple_properties.yml +19 -0
- data/test/rails/fixtures/tasks.yml +46 -0
- data/test/rails/fixtures/users.yml +13 -0
- data/test/rails/helpers/functional_test_helper.rb +21 -0
- data/test/rails/helpers/test_helper.rb +54 -0
- data/test/rails/helpers/unit_test_helper.rb +29 -0
- data/test/rails/model.yml +35 -0
- data/test/rails/models/location.rb +4 -0
- data/test/rails/models/note.rb +3 -0
- data/test/rails/models/project.rb +4 -0
- data/test/rails/models/simple_property.rb +2 -0
- data/test/rails/models/task.rb +18 -0
- data/test/rails/models/user.rb +20 -0
- data/test/rails/schema.rb +77 -0
- data/test/rails/test.swf +1 -0
- data/test/rails/test_active_foo.rb +36 -0
- data/test/rails/test_rails_integration_functional.rb +22 -0
- data/test/rails/test_to_fxml.rb +35 -0
- data/test/rails/test_to_json.rb +23 -0
- data/test/rails/views/notes/empty_params_action.html.erb +1 -0
- data/test/rails/views/notes/index.html.erb +1 -0
- metadata +234 -0
@@ -0,0 +1,17 @@
|
|
1
|
+
# SchemaToYaml settings
|
2
|
+
module SchemaToYaml
|
3
|
+
module Settings
|
4
|
+
class Config
|
5
|
+
class << self
|
6
|
+
def configure
|
7
|
+
yield self
|
8
|
+
end
|
9
|
+
|
10
|
+
def settings_file
|
11
|
+
@settings_file ||= :restfulx
|
12
|
+
end
|
13
|
+
attr_writer :settings_file
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# Inspired from http://settingslogic.rubyforge.org/
|
2
|
+
# Used to read in settings from restfulx.yml for use in code generation
|
3
|
+
module SchemaToYaml
|
4
|
+
module Settings
|
5
|
+
# We try to figure out the application root using a number of possible options
|
6
|
+
APP_ROOT = defined?(RAILS_ROOT) ? RAILS_ROOT : defined?(Merb) ? Merb.root : File.expand_path(".")
|
7
|
+
|
8
|
+
class Core
|
9
|
+
class << self
|
10
|
+
def name
|
11
|
+
instance._settings.key?("name") ? instance.name : super
|
12
|
+
end
|
13
|
+
|
14
|
+
def reset!
|
15
|
+
@instance = nil
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
def instance
|
20
|
+
@instance ||= new
|
21
|
+
end
|
22
|
+
|
23
|
+
def method_missing(name, *args, &block)
|
24
|
+
instance.send(name, *args, &block)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
attr_accessor :_settings
|
29
|
+
|
30
|
+
def initialize(name_or_hash = Config.settings_file)
|
31
|
+
case name_or_hash
|
32
|
+
when Hash
|
33
|
+
self._settings = name_or_hash
|
34
|
+
when String, Symbol
|
35
|
+
root_path = defined?(APP_ROOT) ? "#{APP_ROOT}/config/" : ""
|
36
|
+
file_path = name_or_hash.is_a?(Symbol) ? "#{root_path}#{name_or_hash}.yml" : name_or_hash
|
37
|
+
self._settings = YAML.load(ERB.new(File.read(file_path)).result)
|
38
|
+
self._settings = _settings[RAILS_ENV] if defined?(RAILS_ENV)
|
39
|
+
else
|
40
|
+
raise ArgumentError.new("Your settings must be a hash,
|
41
|
+
a symbol representing the name of the .yml file in your config directory,
|
42
|
+
or a string representing the abosolute path to your settings file.")
|
43
|
+
end
|
44
|
+
define_settings!
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
def method_missing(name, *args, &block)
|
49
|
+
raise NoMethodError.new("no configuration was specified for #{name}")
|
50
|
+
end
|
51
|
+
|
52
|
+
def define_settings!
|
53
|
+
return if _settings.nil?
|
54
|
+
_settings.each do |key, value|
|
55
|
+
case value
|
56
|
+
when Hash
|
57
|
+
instance_eval <<-"end_eval", __FILE__, __LINE__
|
58
|
+
def #{key}
|
59
|
+
@#{key} ||= self.class.new(_settings["#{key}"])
|
60
|
+
end
|
61
|
+
end_eval
|
62
|
+
else
|
63
|
+
instance_eval <<-"end_eval", __FILE__, __LINE__
|
64
|
+
def #{key}
|
65
|
+
@#{key} ||= _settings["#{key}"]
|
66
|
+
end
|
67
|
+
end_eval
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# Adds a little helper to make it easier empbedding SWFs in ERB templates.
|
2
|
+
module SWFHelper
|
3
|
+
# Creates a swfObject Javascript call. You must include swfobject.js to use this.
|
4
|
+
# See http://code.google.com/p/swfobject/wiki/documentation for full details and documentation
|
5
|
+
# of the swfobject js library.
|
6
|
+
def swfobject(swf_url, params = {})
|
7
|
+
params.reverse_merge!({:width => '100%',
|
8
|
+
:height => '100%',
|
9
|
+
:id => 'flashContent',
|
10
|
+
:version => '9.0.0',
|
11
|
+
:express_install_swf => '/expressInstall.swf',
|
12
|
+
:flash_vars => nil,
|
13
|
+
:params => { },
|
14
|
+
:attributes => { },
|
15
|
+
:create_div => false,
|
16
|
+
:include_authenticity_token => true,
|
17
|
+
:include_session_token => true
|
18
|
+
})
|
19
|
+
arg_order = [:id, :width, :height, :version, :express_install_swf]
|
20
|
+
js_params = ["'#{swf_url}'"]
|
21
|
+
js_params += arg_order.collect {|arg| "'#{params[arg]}'" }
|
22
|
+
|
23
|
+
# Add authenticity_token and the session key to flashVars. This will only work if flashVars is a Hash or nil
|
24
|
+
# If it's a string representing the name of a Javascript variable, then you need to add them yourself
|
25
|
+
# like this:
|
26
|
+
# <script>
|
27
|
+
# ... other code that defines flashVars and sets some of its parameters
|
28
|
+
# flashVars['authenticity_token'] = <%= form_authenticity_token -%>
|
29
|
+
# flashVars['session_token'] = <%= session.session_id -%>
|
30
|
+
# </script>
|
31
|
+
params[:flash_vars] ||= {}
|
32
|
+
if params[:flash_vars].is_a?(Hash)
|
33
|
+
if params[:include_authenticity_token] && ActionController::Base.allow_forgery_protection
|
34
|
+
params[:flash_vars].reverse_merge!(:authenticity_token => form_authenticity_token)
|
35
|
+
end
|
36
|
+
if params[:include_session_token]
|
37
|
+
if RAILS_GEM_VERSION =~ /^2.3/
|
38
|
+
params[:flash_vars].reverse_merge!(:session_token => request.session_options[:id])
|
39
|
+
else
|
40
|
+
params[:flash_vars].reverse_merge!(:session_token => session.session_id)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
js_params += [params[:flash_vars], params[:params], params[:attributes]].collect do |hash_or_string|
|
46
|
+
if hash_or_string.is_a?(Hash)
|
47
|
+
hash_or_string.to_json
|
48
|
+
else # If it's not a hash, then it should be a string giving the name of the Javascript variable to use
|
49
|
+
hash_or_string
|
50
|
+
end
|
51
|
+
end.compact
|
52
|
+
|
53
|
+
swf_tag = javascript_tag do
|
54
|
+
"swfobject.embedSWF(#{js_params.join(',')})"
|
55
|
+
end
|
56
|
+
swf_tag += content_tag(:div, nil, :id => params[:id]) if params[:create_div]
|
57
|
+
swf_tag
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
# Rake tasks for building RestfulX-based Flex and AIR applications
|
2
|
+
require 'rake'
|
3
|
+
require 'rexml/document'
|
4
|
+
require 'activesupport'
|
5
|
+
require File.join(File.dirname(__FILE__), 'configuration')
|
6
|
+
|
7
|
+
include RestfulX::Configuration
|
8
|
+
|
9
|
+
namespace :rx do
|
10
|
+
# Compile the given Flex/AIR application
|
11
|
+
# The following options are supported:
|
12
|
+
# :executable => 'mxmlc'
|
13
|
+
# :application => nil
|
14
|
+
# :destination => 'public/bin'
|
15
|
+
# :opts => nil
|
16
|
+
# :flex_root => 'app/flex'
|
17
|
+
def compile_application(params = {})
|
18
|
+
project_name, flex_project_name, command_controller_name, base_package, base_folder,
|
19
|
+
flex_root = extract_names()
|
20
|
+
|
21
|
+
executable = params[:executable] || 'mxmlc'
|
22
|
+
application = params[:application] || get_main_application
|
23
|
+
destination = params[:destination] || 'public/bin'
|
24
|
+
opts = params[:opts] || ''
|
25
|
+
flex_root = params[:flex_root] || flex_root
|
26
|
+
|
27
|
+
compiler = get_executable(executable)
|
28
|
+
|
29
|
+
application = get_main_application unless application
|
30
|
+
project_path = File.join(APP_ROOT, flex_root, application)
|
31
|
+
target_project_path = project_path.sub(/.mxml$/, '.swf')
|
32
|
+
target_project_air_descriptor = project_path.sub(/.mxml$/, '-app.xml')
|
33
|
+
|
34
|
+
libs = Dir.glob(File.join(APP_ROOT, 'lib', '*.swc')).map {|lib| lib.gsub(' ', '\ ')}
|
35
|
+
|
36
|
+
additional_compiler_args = get_app_properties().elements["actionScriptProperties"].elements["compiler"].attributes["additionalCompilerArguments"]
|
37
|
+
additional_compiler_args.gsub!("../locale/", "#{APP_ROOT}/app/locale/")
|
38
|
+
|
39
|
+
cmd = "#{executable} #{opts} -library-path+=#{libs.join(',')} " << additional_compiler_args << " #{project_path.gsub(' ', '\ ')}"
|
40
|
+
puts "Compiling #{project_path}"
|
41
|
+
if system(cmd)
|
42
|
+
FileUtils.makedirs File.join(APP_ROOT, destination)
|
43
|
+
puts "Moving #{target_project_path} to " + File.join(APP_ROOT, destination)
|
44
|
+
FileUtils.mv target_project_path, File.join(APP_ROOT, destination), :force => true
|
45
|
+
if File.exist?(target_project_air_descriptor)
|
46
|
+
descriptor = File.read(target_project_air_descriptor)
|
47
|
+
descriptor_name = target_project_air_descriptor.split("/").last
|
48
|
+
app_swf = target_project_path.split("/").last
|
49
|
+
descriptor.gsub!("[This value will be overwritten by Flex Builder in the output app.xml]",
|
50
|
+
app_swf)
|
51
|
+
|
52
|
+
File.open("#{APP_ROOT}/#{destination}/#{descriptor_name}", "w") do |file|
|
53
|
+
file.print descriptor
|
54
|
+
end
|
55
|
+
puts "Created #{APP_ROOT}/#{destination}/#{descriptor_name} descriptor."
|
56
|
+
end
|
57
|
+
puts 'Done!'
|
58
|
+
else
|
59
|
+
puts "The application was not compiled. Check console for errors. " <<
|
60
|
+
"It is possible that '(a)mxmlc' executable was not found or there are compilation errors."
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def run_air_application(params = {})
|
65
|
+
application = params[:application] || get_main_application
|
66
|
+
descriptor = params[:descriptor] || application.sub(/.mxml$/, '-app.xml')
|
67
|
+
destination = params[:destination] || 'bin-debug'
|
68
|
+
|
69
|
+
puts "Running AIR application with descriptor: #{descriptor}"
|
70
|
+
if !system("#{get_executable('adl')} #{destination}/#{descriptor}")
|
71
|
+
puts "Could not run the application with descriptor: #{destination}/#{descriptor}. Check console for errors."
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# Find what the main application is based on .actionScriptProperties file
|
76
|
+
def get_main_application
|
77
|
+
get_app_properties().root.attributes['mainApplicationPath'].split("/").last
|
78
|
+
end
|
79
|
+
|
80
|
+
def get_app_properties
|
81
|
+
REXML::Document.new(File.open(File.join(APP_ROOT, ".actionScriptProperties")))
|
82
|
+
end
|
83
|
+
|
84
|
+
# Get appropriate executable based on platform
|
85
|
+
def get_executable(executable)
|
86
|
+
if RUBY_PLATFORM =~ /mswin32/
|
87
|
+
executable << '.exe'
|
88
|
+
end
|
89
|
+
executable
|
90
|
+
end
|
91
|
+
|
92
|
+
namespace :flex do
|
93
|
+
desc "Build project swf file and move it into public/bin folder"
|
94
|
+
task :build do
|
95
|
+
compile_application()
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
namespace :air do
|
100
|
+
desc "Build project swf file as an AIR application and move it into bin-debug folder"
|
101
|
+
task :build do
|
102
|
+
compile_application(:destination => 'bin-debug', :opts => '+configname=air')
|
103
|
+
end
|
104
|
+
|
105
|
+
desc "Run the AIR application (if this project is configured as an AIR project)"
|
106
|
+
task :run do
|
107
|
+
run_air_application
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Description:
|
2
|
+
Generates the primary RestfulX directory structure, sets up Flex Builder
|
3
|
+
specific descriptor files and options fetches the latest published
|
4
|
+
RestfulX 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
|
+
`./script/generate rx_config` # generates project structure and a
|
12
|
+
# default Flex app configuration. Fetches
|
13
|
+
# latest RestfulX framework SWC to "lib"
|
14
|
+
# folder
|
15
|
+
`./script/generate rx_config -a` # as above but generates an AIR app
|
16
|
+
# and configuration
|
17
|
+
`./script/generate rx_config --skip-framework` # generates Flex app
|
18
|
+
# but does not fetch
|
19
|
+
# the RestfulX framework SWC.
|
@@ -0,0 +1,151 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'restfulx') if !defined?(RestfulX)
|
3
|
+
|
4
|
+
class RxConfigGenerator < Rails::Generator::Base
|
5
|
+
include RestfulX::Configuration
|
6
|
+
|
7
|
+
attr_reader :project_name,
|
8
|
+
:flex_project_name,
|
9
|
+
:base_package,
|
10
|
+
:base_folder,
|
11
|
+
:command_controller_name,
|
12
|
+
:component_names,
|
13
|
+
:application_tag,
|
14
|
+
:use_air,
|
15
|
+
:flex_root,
|
16
|
+
:base_flex_package,
|
17
|
+
:distributed
|
18
|
+
|
19
|
+
def initialize(runtime_args, runtime_options = {})
|
20
|
+
super
|
21
|
+
@project_name, @flex_project_name, @command_controller_name, @base_package, @base_folder,
|
22
|
+
@flex_root = extract_names
|
23
|
+
|
24
|
+
@base_package = options[:base_flex_package] if options[:base_flex_package]
|
25
|
+
@base_folder = options[:base_flex_package].gsub('.', '/') if options[:base_flex_package]
|
26
|
+
@flex_root = options[:flex_root] if options[:flex_root]
|
27
|
+
@distributed = options[:distributed]
|
28
|
+
|
29
|
+
# if we are updating main file only we probably want to maintain the type of project it is
|
30
|
+
if options[:main_only]
|
31
|
+
project_file_name = APP_ROOT + '/.project'
|
32
|
+
if File.exist?(project_file_name)
|
33
|
+
puts "Cannot combine -m (--main-app) and -a (--air) flags at the same time for an existing application.\n" <<
|
34
|
+
'If you want to convert to AIR, remove -m flag.' if options[:air_config]
|
35
|
+
@use_air = true if File.read(project_file_name) =~/com.adobe.flexbuilder.apollo.apollobuilder/m
|
36
|
+
else
|
37
|
+
puts "Flex Builder project file doesn't exist. You should run 'rx_config' with -a (--air) option " <<
|
38
|
+
"or no arguments first to generate primary project structure."
|
39
|
+
exit 0;
|
40
|
+
end
|
41
|
+
else
|
42
|
+
@use_air = options[:air_config]
|
43
|
+
end
|
44
|
+
|
45
|
+
if @use_air
|
46
|
+
@application_tag = 'WindowedApplication'
|
47
|
+
else
|
48
|
+
@application_tag = 'Application'
|
49
|
+
end
|
50
|
+
|
51
|
+
@component_names = []
|
52
|
+
if File.exists?("#{flex_root}/#{base_folder}/views/generated")
|
53
|
+
@component_names = list_mxml_files("#{flex_root}/#{base_folder}/views/generated")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def manifest
|
58
|
+
record do |m|
|
59
|
+
m.file 'restfulx_tasks.rake', 'lib/tasks/restfulx_tasks.rake' if !options[:skip_tasks]
|
60
|
+
m.file 'flex.properties', '.flexProperties'
|
61
|
+
m.template 'restfulx.yml', 'config/restfulx.yml'
|
62
|
+
m.template 'restfulx.erb', 'config/initializers/restfulx.rb'
|
63
|
+
|
64
|
+
m.template 'session_store_flash.erb', 'config/initializers/session_store_flash.rb' if RAILS_GEM_VERSION =~ /2.3/
|
65
|
+
|
66
|
+
m.directory "#{flex_root}"
|
67
|
+
|
68
|
+
if @use_air
|
69
|
+
m.template 'actionscriptair.properties', '.actionScriptProperties'
|
70
|
+
m.template 'projectair.properties', '.project'
|
71
|
+
else
|
72
|
+
m.template 'actionscript.properties', '.actionScriptProperties'
|
73
|
+
m.template 'project.properties', '.project'
|
74
|
+
end
|
75
|
+
|
76
|
+
m.template 'project-textmate.erb', "#{project_name}.tmproj"
|
77
|
+
m.template 'mainapp.mxml', File.join("#{flex_root}", "#{flex_project_name}.mxml")
|
78
|
+
m.template 'mainapp-config.xml', File.join("#{flex_root}", "#{flex_project_name}-config.xml")
|
79
|
+
m.template 'mainair-app.xml', File.join("#{flex_root}", "#{flex_project_name}-app.xml") if @use_air
|
80
|
+
|
81
|
+
m.directory 'html-template/history'
|
82
|
+
%w(index.template.html AC_OETags.js playerProductInstall.swf).each do |file|
|
83
|
+
m.file "html-template/#{file}", "html-template/#{file}"
|
84
|
+
end
|
85
|
+
|
86
|
+
%w(history.css history.js historyFrame.html).each do |file|
|
87
|
+
m.file "html-template/history/#{file}", "html-template/history/#{file}"
|
88
|
+
end
|
89
|
+
|
90
|
+
%w(views controllers commands models events helpers).each do |dir|
|
91
|
+
m.directory "#{flex_root}/#{base_folder}/#{dir}"
|
92
|
+
end
|
93
|
+
|
94
|
+
m.directory "#{flex_root}/#{base_folder}/views/generated"
|
95
|
+
|
96
|
+
framework_release = RestfulX::FRAMEWORK_VERSION
|
97
|
+
framework_distribution_url = "http://restfulx.github.com/releases/restfulx-#{framework_release}.swc"
|
98
|
+
framework_destination_file = "lib/restfulx-#{framework_release}.swc"
|
99
|
+
|
100
|
+
if !options[:skip_framework] && !File.exist?(framework_destination_file)
|
101
|
+
puts "Fetching #{framework_release} framework binary from: #{framework_distribution_url} ..."
|
102
|
+
begin
|
103
|
+
framework_swc = open(framework_distribution_url).read
|
104
|
+
rescue
|
105
|
+
puts "ERROR: Unable to download and install #{framework_distribution_url}."
|
106
|
+
puts "Please check your internet connectivity and try again."
|
107
|
+
exit
|
108
|
+
end
|
109
|
+
open(framework_destination_file, "wb").write(framework_swc) unless framework_swc.blank?
|
110
|
+
puts "done. saved to #{framework_destination_file}"
|
111
|
+
end
|
112
|
+
|
113
|
+
m.file 'swfobject.js', 'public/javascripts/swfobject.js'
|
114
|
+
m.file 'expressInstall.swf', 'public/expressInstall.swf'
|
115
|
+
|
116
|
+
m.file 'flex_controller.erb', 'app/controllers/flex_controller.rb'
|
117
|
+
|
118
|
+
m.directory "app/views/flex"
|
119
|
+
|
120
|
+
m.template 'index.erb', 'app/views/flex/index.html.erb'
|
121
|
+
|
122
|
+
m.file 'routes.erb', 'config/routes.rb', :collision => :ask
|
123
|
+
|
124
|
+
FileUtils.rm 'public/index.html' if File.exist?('public/index.html')
|
125
|
+
|
126
|
+
m.dependency 'rx_controller', @args
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
protected
|
131
|
+
def add_options!(opt)
|
132
|
+
opt.separator ''
|
133
|
+
opt.separator 'Options:'
|
134
|
+
opt.on("-a", "--air", "Configure AIR project instead of Flex. Flex is default.",
|
135
|
+
"Default: false") { |v| options[:air_config] = v }
|
136
|
+
opt.on("--skip-framework", "Don't fetch the latest framework binary. You'll have to link/build the framework yourself.",
|
137
|
+
"Default: false") { |v| options[:skip_framework] = v }
|
138
|
+
opt.on("--skip-tasks", "Don't install restfulx gem tasks hook into the project.",
|
139
|
+
"Default: false") { |v| options[:skip_tasks] = v }
|
140
|
+
opt.on("--flex-root [FOLDER]", "Root folder for generated flex code.",
|
141
|
+
"Default: app/flex") { |v| options[:flex_root] = v }
|
142
|
+
opt.on("--base-flex-package [PACKAGE]", "Base package for your application.",
|
143
|
+
"Default: #{flex_project_name}") { |v| options[:base_flex_package] = v }
|
144
|
+
opt.on("--distributed", "Creates migrations, controllers and models that use UUIDs and are distribution ready",
|
145
|
+
"Default: false") { |v| options[:distributed] = v }
|
146
|
+
end
|
147
|
+
|
148
|
+
def banner
|
149
|
+
"Usage: #{$0} #{spec.name}"
|
150
|
+
end
|
151
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<actionScriptProperties mainApplicationPath="<%= flex_project_name %>.mxml" version="3">
|
3
|
+
<compiler additionalCompilerArguments="-locale en_US -keep-as3-metadata+=Resource,HasOne,HasMany,BelongsTo,DateTime,Lazy,Ignored,Nested" copyDependentFiles="true" enableModuleDebug="true" generateAccessible="false" htmlExpressInstall="true" htmlGenerate="true" htmlHistoryManagement="true" htmlPlayerVersion="9.0.28" htmlPlayerVersionCheck="true" outputFolderPath="public/bin" rootURL="http://localhost:3000/bin" sourceFolderPath="<%= flex_root %>" 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="<%= flex_project_name %>.mxml"/>
|
13
|
+
</applications>
|
14
|
+
<modules/>
|
15
|
+
<buildCSSFiles/>
|
16
|
+
</actionScriptProperties>
|