dima-restfulx 1.2.2 → 1.2.3
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/README.rdoc +1 -1
- data/Rakefile +4 -2
- data/VERSION.yml +1 -1
- data/app_generators/rx_app/rx_app_generator.rb +2 -2
- data/app_generators/rx_app/templates/actionscript.properties +1 -1
- data/app_generators/rx_app/templates/actionscriptair.properties +1 -1
- data/app_generators/rx_app/templates/mainapp-config.xml +1 -0
- data/app_generators/rx_app/templates/mainapp.mxml +19 -3
- data/app_generators/rx_app/templates/restfulx.yml +9 -24
- data/bin/rx-gen +1 -1
- data/lib/restfulx/active_foo.rb +5 -3
- data/lib/restfulx/active_record_tasks.rb +1 -2
- data/lib/restfulx/active_record_uuid_helper.rb +17 -0
- data/lib/restfulx/configuration.rb +20 -26
- data/lib/restfulx/{schema_to_yaml → rails/schema_to_yaml}/extensions/enumerable.rb +1 -0
- data/lib/restfulx/{schema_to_yaml → rails/schema_to_yaml}/settings/config.rb +1 -0
- data/lib/restfulx/{schema_to_yaml → rails/schema_to_yaml}/settings/core.rb +4 -1
- data/lib/restfulx/{schema_to_yaml.rb → rails/schema_to_yaml.rb} +2 -12
- data/lib/restfulx/rails/swf_helper.rb +7 -8
- data/lib/restfulx/tasks.rb +0 -1
- data/lib/restfulx.rb +2 -10
- data/rails_generators/rx_config/rx_config_generator.rb +20 -9
- data/rails_generators/rx_config/templates/actionscript.properties +1 -1
- data/rails_generators/rx_config/templates/actionscriptair.properties +1 -1
- data/rails_generators/rx_config/templates/mainapp-config.xml +1 -0
- data/rails_generators/rx_config/templates/restfulx.erb +46 -10
- data/rails_generators/rx_config/templates/restfulx.yml +9 -5
- data/rails_generators/rx_config/templates/session_store_flash.erb +1 -0
- data/rails_generators/rx_main_app/rx_main_app_generator.rb +2 -2
- data/rails_generators/rx_main_app/templates/mainapp.mxml +1 -1
- data/rails_generators/rx_scaffold/rx_scaffold_generator.rb +16 -7
- data/rails_generators/rx_scaffold/templates/controllers/resource_controller.rb.erb +2 -2
- 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 +7 -5
- data/rails_generators/rx_scaffold/templates/migration.rb.erb +4 -4
- data/rxgen_generators/rx_config/rx_config_generator.rb +2 -0
- data/rxgen_generators/rx_controller/rx_controller_generator.rb +1 -0
- data/rxgen_generators/rx_controller/templates/assist.py +4 -4
- data/rxgen_generators/rx_controller/templates/iso8601.py +92 -0
- data/rxgen_generators/rx_main_app/rx_main_app_generator.rb +2 -2
- data/rxgen_generators/rx_main_app/templates/mainapp.mxml +19 -3
- data/rxgen_generators/rx_scaffold/rx_scaffold_generator.rb +57 -10
- data/rxgen_generators/rx_scaffold/templates/{component.mxml.erb → layouts/default.erb} +56 -10
- data/rxgen_generators/rx_scaffold/templates/model.as.erb +33 -2
- data/spec/restfulx_spec.rb +1 -4
- data/spec/spec_helper.rb +0 -3
- data/tasks/restfulx.rake +2 -0
- data/test/rails/helpers/functional_test_helper.rb +1 -1
- data/test/rails/helpers/test_helper.rb +1 -8
- data/test/rails/helpers/unit_test_helper.rb +2 -3
- data/test/rails/test_active_foo.rb +1 -1
- data/test/rails/test_rails_integration_functional.rb +1 -1
- data/test/rails/test_to_fxml.rb +1 -1
- data/test/rails/test_to_json.rb +1 -1
- metadata +60 -75
- data/lib/restfulx/uuid_helper.rb +0 -15
- /data/test/rails/controllers/{application.rb → application_controller.rb} +0 -0
data/README.rdoc
CHANGED
@@ -39,7 +39,7 @@ For details on how to get started with the RestfulX framework refer to:
|
|
39
39
|
|
40
40
|
Report bugs or track framework development progress:
|
41
41
|
|
42
|
-
http://
|
42
|
+
http://github.com/dima/restfulx_framework/issues
|
43
43
|
|
44
44
|
Get involved with the community:
|
45
45
|
|
data/Rakefile
CHANGED
@@ -9,12 +9,14 @@ begin
|
|
9
9
|
gem.homepage = "http://restfulx.org"
|
10
10
|
gem.rubyforge_project = "restfulx"
|
11
11
|
gem.authors = ["Dima Berastau"]
|
12
|
-
gem.files = FileList["[A-Z]*", "{bin,app_generators,rails_generators,rxgen_generators,lib,test,spec}/**/*"]
|
12
|
+
gem.files = FileList["[A-Z]*", "{bin,app_generators,rails_generators,rxgen_generators,lib,test,spec,tasks}/**/*"]
|
13
|
+
gem.files.exclude 'test/**/*.log', 'test/**/*.sqlite3'
|
14
|
+
gem.test_files.exclude 'test/**/*.log', 'test/**/*.sqlite3'
|
13
15
|
gem.add_dependency('rubigen', '>= 1.5.0')
|
14
16
|
gem.add_dependency('activesupport', '>=2.0.0')
|
15
17
|
end
|
16
18
|
rescue LoadError
|
17
|
-
puts "Jeweler not available. Install it with: sudo gem install
|
19
|
+
puts "Jeweler not available. Install it with: sudo gem install jeweler"
|
18
20
|
end
|
19
21
|
|
20
22
|
require 'rake/rdoctask'
|
data/VERSION.yml
CHANGED
@@ -79,11 +79,11 @@ class RxAppGenerator < RubiGen::Base
|
|
79
79
|
m.template 'index.html.erb', 'public/index.html'
|
80
80
|
end
|
81
81
|
|
82
|
-
%w(
|
82
|
+
%w(views controllers commands models events helpers).each do |dir|
|
83
83
|
m.directory "#{flex_root}/#{base_folder}/#{dir}"
|
84
84
|
end
|
85
85
|
|
86
|
-
m.directory "#{flex_root}/#{base_folder}/
|
86
|
+
m.directory "#{flex_root}/#{base_folder}/views/generated"
|
87
87
|
|
88
88
|
m.template 'project-textmate.erb', "#{project_name}.tmproj"
|
89
89
|
m.template 'mainapp.mxml', File.join("#{flex_root}", "#{flex_project_name}.mxml")
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
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" 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">
|
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
4
|
<compilerSourcePath/>
|
5
5
|
<libraryPath defaultLinkType="1">
|
6
6
|
<libraryPathEntry kind="4" path=""/>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
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" copyDependentFiles="true" enableModuleDebug="true" generateAccessible="false" htmlExpressInstall="true" htmlGenerate="false" htmlHistoryManagement="false" htmlPlayerVersion="9.0.28" htmlPlayerVersionCheck="true" outputFolderPath="bin-debug" sourceFolderPath="<%= flex_root %>" strict="true" useApolloConfig="true" verifyDigests="true" warn="true">
|
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="false" htmlHistoryManagement="false" htmlPlayerVersion="9.0.28" htmlPlayerVersionCheck="true" outputFolderPath="bin-debug" sourceFolderPath="<%= flex_root %>" strict="true" useApolloConfig="true" verifyDigests="true" warn="true">
|
4
4
|
<compilerSourcePath/>
|
5
5
|
<libraryPath defaultLinkType="1">
|
6
6
|
<libraryPathEntry kind="4" path=""/>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<?xml version="1.0" encoding="utf-8"?>
|
2
2
|
<mx:<%= application_tag %> xmlns:mx="http://www.adobe.com/2006/mxml"
|
3
|
-
xmlns:generated="<%= base_package %>.
|
3
|
+
xmlns:generated="<%= base_package %>.views.generated.*"
|
4
4
|
paddingBottom="8" paddingLeft="8" paddingRight="8" paddingTop="8"
|
5
5
|
layout="horizontal" styleName="plain" initialize="init()">
|
6
6
|
<mx:Script>
|
@@ -14,12 +14,13 @@
|
|
14
14
|
import org.restfulx.events.PushStartEvent;
|
15
15
|
import org.restfulx.controllers.ChangeController;
|
16
16
|
import org.restfulx.services.ISyncingServiceProvider;
|
17
|
-
import org.restfulx.services.http.XMLHTTPServiceProvider;
|
18
17
|
<% end -%>
|
19
18
|
import org.restfulx.services.air.AIRServiceProvider;
|
20
19
|
<% end -%>
|
21
20
|
<% if use_gae -%>
|
22
21
|
import org.restfulx.services.http.GAEHTTPServiceProvider;
|
22
|
+
<% else -%>
|
23
|
+
import org.restfulx.services.http.XMLHTTPServiceProvider;
|
23
24
|
<% end -%>
|
24
25
|
import org.restfulx.Rx;
|
25
26
|
import <%= base_package %>.controllers.<%= command_controller_name %>;
|
@@ -53,9 +54,15 @@
|
|
53
54
|
AIRServiceProvider.ID, "<%= base_package %>");
|
54
55
|
<% if distributed -%>
|
55
56
|
|
57
|
+
<% if use_gae -%>
|
58
|
+
Rx.changes.setSyncProviders(
|
59
|
+
ISyncingServiceProvider(Rx.services.getServiceProvider(AIRServiceProvider.ID)),
|
60
|
+
Rx.services.getServiceProvider(GAEHTTPServiceProvider.ID));
|
61
|
+
<% else -%>
|
56
62
|
Rx.changes.setSyncProviders(
|
57
63
|
ISyncingServiceProvider(Rx.services.getServiceProvider(AIRServiceProvider.ID)),
|
58
64
|
Rx.services.getServiceProvider(XMLHTTPServiceProvider.ID));
|
65
|
+
<% end -%>
|
59
66
|
|
60
67
|
Rx.changes.addEventListener(PushStartEvent.ID, onPushStart);
|
61
68
|
Rx.changes.addEventListener(PushEndEvent.ID, onPushEnd);
|
@@ -93,7 +100,11 @@
|
|
93
100
|
online = (socketMonitor.available) ? true : false;
|
94
101
|
|
95
102
|
if (online) {
|
103
|
+
<% if use_gae -%>
|
104
|
+
Rx.defaultServiceId = GAEHTTPServiceProvider.ID;
|
105
|
+
<% else -%>
|
96
106
|
Rx.defaultServiceId = XMLHTTPServiceProvider.ID;
|
107
|
+
<% end -%>
|
97
108
|
} else {
|
98
109
|
Rx.defaultServiceId = AIRServiceProvider.ID;
|
99
110
|
}
|
@@ -101,8 +112,13 @@
|
|
101
112
|
|
102
113
|
private function getCurrentProviderName(id:int):String {
|
103
114
|
switch (id) {
|
115
|
+
<% if use_gae -%>
|
116
|
+
case GAEHTTPServiceProvider.ID:
|
117
|
+
return "GAE";
|
118
|
+
<% else -%>
|
104
119
|
case XMLHTTPServiceProvider.ID:
|
105
|
-
return "
|
120
|
+
return "XML/HTTP";
|
121
|
+
<% end -%>
|
106
122
|
case AIRServiceProvider.ID:
|
107
123
|
return "AIR (SQLite)";
|
108
124
|
default :
|
@@ -2,50 +2,35 @@
|
|
2
2
|
|
3
3
|
# This option controls what the main Flex application file will be called.
|
4
4
|
# By default it will be equal to the name of your rails project camelized
|
5
|
-
|
5
|
+
project_name: <%= project_name %>
|
6
6
|
|
7
7
|
# This options determines what the root folder for generated Flex code is.
|
8
8
|
# By default 'app/flex'
|
9
|
-
|
9
|
+
flex_root: <%= flex_root %>
|
10
10
|
|
11
11
|
# By default flex models, commands, controllers and components are genearated into
|
12
12
|
# <flex-root>/<your rails project name> folder. If you'd like to customize the target folder
|
13
13
|
# (to say append a "com" package before your rails project name) uncomment the line below
|
14
14
|
# base-package must follow the usual flex package notation (a string separated by ".")
|
15
|
-
|
15
|
+
base_package: <%= base_package %>
|
16
16
|
|
17
17
|
# Main RestfulX controller is typically named AppicationController. This controller is created in
|
18
18
|
# <base-package>.controllers folder. You can customize the name by uncommenting the following line
|
19
19
|
# and changing the controller name.
|
20
|
-
|
20
|
+
controller_name: <%= command_controller_name %>
|
21
21
|
|
22
22
|
# If you are using Rails on the back-end and Adobe AIR as the client you can generate Rails/Flex/AIR
|
23
23
|
# code to take advantage of synchronization (online/offline) support in RestfulX by changing the following
|
24
24
|
# option to true. By default distribution is disabled.
|
25
25
|
distributed: <%= distributed %>
|
26
26
|
|
27
|
-
#
|
28
|
-
|
29
|
-
|
30
|
-
attachment_plugin: 'paperclip' # => paperclip/attachment_fu
|
31
|
-
controller_pattern: 'default' # => default/resource_controller
|
32
|
-
layouts:
|
33
|
-
default: 'default' # => default (more coming soon)
|
34
|
-
ignored: # => ignored tables/fields won't appear in model.yml
|
35
|
-
tables: [table1 table2]
|
36
|
-
fields: [field1 field2]
|
37
|
-
|
38
|
-
development:
|
39
|
-
<<: *defaults
|
40
|
-
|
41
|
-
test:
|
42
|
-
<<: *defaults
|
43
|
-
|
44
|
-
production:
|
45
|
-
<<: *defaults
|
27
|
+
# Choose the layout to use for generated Flex view components
|
28
|
+
layouts:
|
29
|
+
default: 'default'
|
46
30
|
|
47
|
-
#
|
31
|
+
# The following special model.yml fields are supported.
|
48
32
|
#
|
33
|
+
# For example:
|
49
34
|
# attachment_field: [avatar]
|
50
35
|
# * arg takes Paperclip field name, or takes [uploaded_data] for Attachment_Fu
|
51
36
|
# belongs_to: [account, profile]
|
data/bin/rx-gen
CHANGED
@@ -22,7 +22,7 @@ require 'rubigen'
|
|
22
22
|
require File.join(File.dirname(__FILE__), '..', 'lib', 'restfulx')
|
23
23
|
|
24
24
|
if %w(-v --version).include? ARGV.first
|
25
|
-
puts "#{File.basename($0)} #{RestfulX::
|
25
|
+
puts "#{File.basename($0)} #{RestfulX::FRAMEWORK_VERSION}"
|
26
26
|
exit(0)
|
27
27
|
end
|
28
28
|
|
data/lib/restfulx/active_foo.rb
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
# ~wrong~ from the point of view of Flex clients.
|
3
3
|
#
|
4
4
|
# Some of these things are:
|
5
|
-
# * Date formats
|
6
5
|
# * XML format (Flex *really* doesn't like dashes in XML messages)
|
7
6
|
# * Errors (we need to be more specific and communicate what went wrong *where*)
|
8
7
|
#
|
@@ -89,6 +88,9 @@ module ActiveSupport
|
|
89
88
|
options[:indent] ||= 2
|
90
89
|
options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent])
|
91
90
|
options.merge!(:dasherize => false)
|
91
|
+
|
92
|
+
options[:attributes] ||= {}
|
93
|
+
options[:attributes].merge!(:type => "array")
|
92
94
|
|
93
95
|
root = options.delete(:root).to_s
|
94
96
|
children = options.delete(:children)
|
@@ -103,9 +105,9 @@ module ActiveSupport
|
|
103
105
|
|
104
106
|
xml = options[:builder]
|
105
107
|
if empty?
|
106
|
-
xml.tag!(root, options[:
|
108
|
+
xml.tag!(root, options[:attributes])
|
107
109
|
else
|
108
|
-
xml.tag!(root, options[:
|
110
|
+
xml.tag!(root, options[:attributes]) {
|
109
111
|
yield xml if block_given?
|
110
112
|
each { |e| e.to_fxml(opts.merge!({ :skip_instruct => true })) }
|
111
113
|
}
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# - db:mysql:stage
|
3
3
|
# - db:refresh
|
4
4
|
require File.join(File.dirname(__FILE__), 'tasks')
|
5
|
-
require File.join(File.dirname(__FILE__), 'schema_to_yaml')
|
5
|
+
require File.join(File.dirname(__FILE__), 'rails', 'schema_to_yaml')
|
6
6
|
|
7
7
|
# stores local copy of the application environment ('production', 'test', etc)
|
8
8
|
# so that appropriate values in config/database.yml are used
|
@@ -87,5 +87,4 @@ namespace :db do
|
|
87
87
|
SchemaToYaml.schema_to_yaml
|
88
88
|
end
|
89
89
|
end
|
90
|
-
|
91
90
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Patches ActiveRecord models to use UUID based IDs instead of the default numeric ones
|
2
|
+
require 'uuidtools'
|
3
|
+
|
4
|
+
# Extends ActiveRecord models with UUID based IDs
|
5
|
+
module RestfulX
|
6
|
+
module UUIDHelper
|
7
|
+
def self.included(base)
|
8
|
+
base.class_eval do
|
9
|
+
before_create :generate_uuid
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def generate_uuid
|
14
|
+
self.id = UUIDTools::UUID.random_create.to_s.gsub("-", "") unless self.id
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -1,6 +1,15 @@
|
|
1
1
|
# Interestingly enough there's no way to *just* upper-case or down-case first letter of a given
|
2
2
|
# string. Ruby's own +capitalize+ actually downcases all the rest of the characters in the string
|
3
3
|
# We patch the class to add our own implementation.
|
4
|
+
require "yaml"
|
5
|
+
require "erb"
|
6
|
+
require File.dirname(__FILE__) + "/rails/schema_to_yaml/settings/config"
|
7
|
+
require File.dirname(__FILE__) + "/rails/schema_to_yaml/settings/core"
|
8
|
+
|
9
|
+
Dir[File.dirname(__FILE__) + "/rails/schema_to_yaml/extensions/*.rb"].each do |f|
|
10
|
+
require f
|
11
|
+
end
|
12
|
+
|
4
13
|
class String
|
5
14
|
# Upper-case first character of a string leave the rest of the string intact
|
6
15
|
def ucfirst
|
@@ -13,33 +22,18 @@ class String
|
|
13
22
|
end
|
14
23
|
end
|
15
24
|
|
25
|
+
# Primary RestfulX configuration options
|
16
26
|
module RestfulX
|
17
27
|
# Computes necessary configuration options from the environment. This can be used in Rails, Merb
|
18
28
|
# or standalone from the command line.
|
19
29
|
module Configuration
|
30
|
+
# We try to figure out the application root using a number of possible options
|
20
31
|
APP_ROOT = defined?(RAILS_ROOT) ? RAILS_ROOT : defined?(Merb) ? Merb.root : File.expand_path(".")
|
32
|
+
|
33
|
+
RxSettings = SchemaToYaml::Settings::Core
|
21
34
|
|
22
|
-
# Extract project, package, controller
|
23
|
-
# config/restfulx.yml if it exists, you can override all of the defaults there.
|
24
|
-
# - *base-package* same as project name downcased
|
25
|
-
# - *controller-name* 'ApplicationController'
|
26
|
-
#
|
27
|
-
# Here's a sample restfulx.yml file:
|
28
|
-
#
|
29
|
-
# RestfulX code generation configuration options
|
30
|
-
#
|
31
|
-
# By default flex models, commands, controllers and components are genearated into
|
32
|
-
# app/flex/<your rails project name> folder. If you'd like to customize the target folder
|
33
|
-
# (to say append a "com" package before your rails project name) uncomment the line below
|
34
|
-
# base-package must follow the usual flex package notation (a string separated by ".")
|
35
|
-
#
|
36
|
-
# base-package: com.pomodo
|
37
|
-
#
|
38
|
-
# Main RestfulX controller is typically named AppicationController. This controller is created in
|
39
|
-
# <base-package>.controllers folder. You can customize the name by uncommenting the following line
|
40
|
-
# and changing the controller name.
|
41
|
-
#
|
42
|
-
# controller-name: ApplicationController
|
35
|
+
# Extract project, package, controller name, etc from the environment. This will respect
|
36
|
+
# config/restfulx.yml if it exists, you can override all of the defaults there.
|
43
37
|
def extract_names(project = nil)
|
44
38
|
if project
|
45
39
|
project_name = project.downcase.gsub(/\W/, '')
|
@@ -52,12 +46,12 @@ module RestfulX
|
|
52
46
|
# give a chance to override the settings via restfulx.yml
|
53
47
|
begin
|
54
48
|
config = YAML.load(File.open("#{APP_ROOT}/config/restfulx.yml"))
|
55
|
-
base_package = config['
|
56
|
-
base_folder = base_package.gsub('.', '/')
|
57
|
-
project_name = config['
|
49
|
+
base_package = config['base_package'] || flex_project_name.downcase
|
50
|
+
base_folder = base_package.gsub('.', '/')
|
51
|
+
project_name = config['project_name'].downcase.gsub(/\W/, '') || project_name
|
58
52
|
flex_project_name = project_name.camelize
|
59
|
-
controller_name = config['
|
60
|
-
flex_root = config['
|
53
|
+
controller_name = config['controller_name'] || "ApplicationController"
|
54
|
+
flex_root = config['flex_root'] || "app/flex"
|
61
55
|
distributed = config['distributed'] || false
|
62
56
|
rescue
|
63
57
|
base_folder = base_package = flex_project_name.downcase
|
@@ -2,6 +2,9 @@
|
|
2
2
|
# Used to read in settings from restfulx.yml for use in code generation
|
3
3
|
module SchemaToYaml
|
4
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
|
+
|
5
8
|
class Core
|
6
9
|
class << self
|
7
10
|
def name
|
@@ -29,7 +32,7 @@ module SchemaToYaml
|
|
29
32
|
when Hash
|
30
33
|
self._settings = name_or_hash
|
31
34
|
when String, Symbol
|
32
|
-
root_path = defined?(
|
35
|
+
root_path = defined?(APP_ROOT) ? "#{APP_ROOT}/config/" : ""
|
33
36
|
file_path = name_or_hash.is_a?(Symbol) ? "#{root_path}#{name_or_hash}.yml" : name_or_hash
|
34
37
|
self._settings = YAML.load(ERB.new(File.read(file_path)).result)
|
35
38
|
self._settings = _settings[RAILS_ENV] if defined?(RAILS_ENV)
|
@@ -1,16 +1,7 @@
|
|
1
1
|
# Used for analyzing your schema and exporting a model.yml file for Rx
|
2
|
-
|
3
|
-
|
4
|
-
require File.dirname(__FILE__) + "/schema_to_yaml/settings/config"
|
5
|
-
require File.dirname(__FILE__) + "/schema_to_yaml/settings/core"
|
6
|
-
|
7
|
-
Dir[File.dirname(__FILE__) + "/schema_to_yaml/extensions/*.rb"].each do |f|
|
8
|
-
require f
|
9
|
-
end
|
10
|
-
|
2
|
+
# Provides facilities to convert an existing Rails application schema.rb file to
|
3
|
+
# RestfulX model.yml file
|
11
4
|
module SchemaToYaml
|
12
|
-
RxSettings = SchemaToYaml::Settings::Core
|
13
|
-
|
14
5
|
# SchemaToYaml.schema_to_yaml
|
15
6
|
# - set of commands that introspects your database and formats your model.yml for export
|
16
7
|
def self.schema_to_yaml
|
@@ -116,5 +107,4 @@ module SchemaToYaml
|
|
116
107
|
File.open(yml_file, "w") { |f| f << schema.to_s }
|
117
108
|
puts "Model.yml created at db/model.yml"
|
118
109
|
end
|
119
|
-
|
120
110
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
# Adds a little helper to make it easier empbedding SWFs in ERB templates.
|
2
2
|
module SWFHelper
|
3
|
-
|
4
3
|
# Creates a swfObject Javascript call. You must include swfobject.js to use this.
|
5
4
|
# See http://code.google.com/p/swfobject/wiki/documentation for full details and documentation
|
6
5
|
# of the swfobject js library.
|
@@ -11,8 +10,8 @@ module SWFHelper
|
|
11
10
|
:version => '9.0.0',
|
12
11
|
:express_install_swf => '/expressInstall.swf',
|
13
12
|
:flash_vars => nil,
|
14
|
-
:params =>
|
15
|
-
:attributes =>
|
13
|
+
:params => { },
|
14
|
+
:attributes => { },
|
16
15
|
:create_div => false,
|
17
16
|
:include_authenticity_token => true,
|
18
17
|
:include_session_token => true
|
@@ -29,16 +28,17 @@ module SWFHelper
|
|
29
28
|
# flashVars['authenticity_token'] = <%= form_authenticity_token -%>
|
30
29
|
# flashVars['session_token'] = <%= session.session_id -%>
|
31
30
|
# </script>
|
32
|
-
# If you include an authenticity_token parameter in flashVars,
|
33
|
-
# then the Flex app will add it to Rx.defaultMetadata, so that it will be sent
|
34
|
-
# back up to your Rails app with every request.
|
35
31
|
params[:flash_vars] ||= {}
|
36
32
|
if params[:flash_vars].is_a?(Hash)
|
37
33
|
if params[:include_authenticity_token] && ActionController::Base.allow_forgery_protection
|
38
34
|
params[:flash_vars].reverse_merge!(:authenticity_token => form_authenticity_token)
|
39
35
|
end
|
40
36
|
if params[:include_session_token]
|
41
|
-
|
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
42
|
end
|
43
43
|
end
|
44
44
|
|
@@ -56,5 +56,4 @@ module SWFHelper
|
|
56
56
|
swf_tag += content_tag(:div, nil, :id => params[:id]) if params[:create_div]
|
57
57
|
swf_tag
|
58
58
|
end
|
59
|
-
|
60
59
|
end
|
data/lib/restfulx/tasks.rb
CHANGED
data/lib/restfulx.rb
CHANGED
@@ -5,17 +5,10 @@
|
|
5
5
|
module RestfulX
|
6
6
|
|
7
7
|
# :stopdoc:
|
8
|
-
|
9
|
-
FRAMEWORK_VERSION = '1.2.2'
|
8
|
+
FRAMEWORK_VERSION = '1.2.3'
|
10
9
|
LIB_DIR = File.join(File.dirname(__FILE__), 'restfulx/')
|
11
10
|
# :startdoc:
|
12
11
|
|
13
|
-
# Returns the version string for the library.
|
14
|
-
#
|
15
|
-
def self.version
|
16
|
-
VERSION
|
17
|
-
end
|
18
|
-
|
19
12
|
# Utility method used to require all files ending in .rb that lie in the
|
20
13
|
# directory below this file that has the same name as the filename passed
|
21
14
|
# in. Optionally, a specific _directory_ name can be passed in such that
|
@@ -28,7 +21,6 @@ module RestfulX
|
|
28
21
|
|
29
22
|
Dir.glob(search_me).sort.each {|rb| require rb}
|
30
23
|
end
|
31
|
-
|
32
24
|
end
|
33
25
|
|
34
26
|
require RestfulX::LIB_DIR + 'configuration'
|
@@ -54,7 +46,7 @@ elsif defined?(ActionController::Base)
|
|
54
46
|
# if we are not running in Merb, try to hook up Rails
|
55
47
|
Mime::Type.register_alias "application/xml", :fxml
|
56
48
|
|
57
|
-
['active_foo', 'rails/swf_helper', 'schema_to_yaml'].each { |lib| require RestfulX::LIB_DIR + lib }
|
49
|
+
['active_foo', 'rails/swf_helper', 'rails/schema_to_yaml'].each { |lib| require RestfulX::LIB_DIR + lib }
|
58
50
|
|
59
51
|
ActionView::Base.send :include, SWFHelper unless ActionView::Base.included_modules.include?(SWFHelper)
|
60
52
|
ActiveRecord::Migration.send :include, SchemaToYaml
|
@@ -22,7 +22,7 @@ class RxConfigGenerator < Rails::Generator::Base
|
|
22
22
|
@flex_root = extract_names
|
23
23
|
|
24
24
|
@base_package = options[:base_flex_package] if options[:base_flex_package]
|
25
|
-
@base_folder = options[:base_flex_package].gsub('.', '/')
|
25
|
+
@base_folder = options[:base_flex_package].gsub('.', '/') if options[:base_flex_package]
|
26
26
|
@flex_root = options[:flex_root] if options[:flex_root]
|
27
27
|
@distributed = options[:distributed]
|
28
28
|
|
@@ -49,18 +49,20 @@ class RxConfigGenerator < Rails::Generator::Base
|
|
49
49
|
end
|
50
50
|
|
51
51
|
@component_names = []
|
52
|
-
if File.exists?("#{flex_root}/#{base_folder}/
|
53
|
-
@component_names = list_mxml_files("#{flex_root}/#{base_folder}/
|
52
|
+
if File.exists?("#{flex_root}/#{base_folder}/views/generated")
|
53
|
+
@component_names = list_mxml_files("#{flex_root}/#{base_folder}/views/generated")
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
57
|
def manifest
|
58
58
|
record do |m|
|
59
|
-
m.file 'restfulx_tasks.rake', 'lib/tasks/restfulx_tasks.rake'
|
59
|
+
m.file 'restfulx_tasks.rake', 'lib/tasks/restfulx_tasks.rake' if !options[:skip_tasks]
|
60
60
|
m.file 'flex.properties', '.flexProperties'
|
61
61
|
m.template 'restfulx.yml', 'config/restfulx.yml'
|
62
62
|
m.template 'restfulx.erb', 'config/initializers/restfulx.rb'
|
63
63
|
|
64
|
+
m.template 'session_store_flash.erb', 'config/initializers/session_store_flash.rb' if RAILS_GEM_VERSION =~ /2.3/
|
65
|
+
|
64
66
|
m.directory "#{flex_root}"
|
65
67
|
|
66
68
|
if @use_air
|
@@ -85,19 +87,26 @@ class RxConfigGenerator < Rails::Generator::Base
|
|
85
87
|
m.file "html-template/history/#{file}", "html-template/history/#{file}"
|
86
88
|
end
|
87
89
|
|
88
|
-
%w(
|
90
|
+
%w(views controllers commands models events helpers).each do |dir|
|
89
91
|
m.directory "#{flex_root}/#{base_folder}/#{dir}"
|
90
92
|
end
|
91
93
|
|
92
|
-
m.directory "#{flex_root}/#{base_folder}/
|
94
|
+
m.directory "#{flex_root}/#{base_folder}/views/generated"
|
93
95
|
|
94
96
|
framework_release = RestfulX::FRAMEWORK_VERSION
|
95
97
|
framework_distribution_url = "http://restfulx.github.com/releases/restfulx-#{framework_release}.swc"
|
96
98
|
framework_destination_file = "lib/restfulx-#{framework_release}.swc"
|
97
99
|
|
98
100
|
if !options[:skip_framework] && !File.exist?(framework_destination_file)
|
99
|
-
puts "
|
100
|
-
|
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?
|
101
110
|
puts "done. saved to #{framework_destination_file}"
|
102
111
|
end
|
103
112
|
|
@@ -110,7 +119,7 @@ class RxConfigGenerator < Rails::Generator::Base
|
|
110
119
|
|
111
120
|
m.template 'index.erb', 'app/views/flex/index.html.erb'
|
112
121
|
|
113
|
-
m.file 'routes.erb', 'config/routes.rb', :collision => :
|
122
|
+
m.file 'routes.erb', 'config/routes.rb', :collision => :ask
|
114
123
|
|
115
124
|
FileUtils.rm 'public/index.html' if File.exist?('public/index.html')
|
116
125
|
|
@@ -126,6 +135,8 @@ class RxConfigGenerator < Rails::Generator::Base
|
|
126
135
|
"Default: false") { |v| options[:air_config] = v }
|
127
136
|
opt.on("--skip-framework", "Don't fetch the latest framework binary. You'll have to link/build the framework yourself.",
|
128
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 }
|
129
140
|
opt.on("--flex-root [FOLDER]", "Root folder for generated flex code.",
|
130
141
|
"Default: app/flex") { |v| options[:flex_root] = v }
|
131
142
|
opt.on("--base-flex-package [PACKAGE]", "Base package for your application.",
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
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" 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">
|
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
4
|
<compilerSourcePath/>
|
5
5
|
<libraryPath defaultLinkType="1">
|
6
6
|
<libraryPathEntry kind="4" path=""/>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
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" copyDependentFiles="true" enableModuleDebug="true" generateAccessible="false" htmlExpressInstall="true" htmlGenerate="false" htmlHistoryManagement="false" htmlPlayerVersion="9.0.28" htmlPlayerVersionCheck="true" outputFolderPath="bin-debug" sourceFolderPath="<%= flex_root %>" strict="true" useApolloConfig="true" verifyDigests="true" warn="true">
|
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="false" htmlHistoryManagement="false" htmlPlayerVersion="9.0.28" htmlPlayerVersionCheck="true" outputFolderPath="bin-debug" sourceFolderPath="<%= flex_root %>" strict="true" useApolloConfig="true" verifyDigests="true" warn="true">
|
4
4
|
<compilerSourcePath/>
|
5
5
|
<libraryPath defaultLinkType="1">
|
6
6
|
<libraryPathEntry kind="4" path=""/>
|