restfulx 1.2.1 → 1.2.2

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.
Files changed (98) hide show
  1. data/Rakefile +65 -30
  2. data/VERSION.yml +4 -0
  3. data/app_generators/rx_app/rx_app_generator.rb +25 -9
  4. data/app_generators/rx_app/templates/actionscript.properties +3 -3
  5. data/app_generators/rx_app/templates/actionscriptair.properties +3 -3
  6. data/app_generators/rx_app/templates/app.yaml.erb +1 -1
  7. data/app_generators/rx_app/templates/default_tasks.rake +5 -18
  8. data/app_generators/rx_app/templates/generate.rb +1 -1
  9. data/app_generators/rx_app/templates/index.html.erb +1 -1
  10. data/app_generators/rx_app/templates/mainair-app.xml +3 -3
  11. data/app_generators/rx_app/templates/mainapp.mxml +123 -2
  12. data/app_generators/rx_app/templates/project-textmate.erb +4 -4
  13. data/app_generators/rx_app/templates/project.properties +1 -1
  14. data/app_generators/rx_app/templates/projectair.properties +1 -1
  15. data/app_generators/rx_app/templates/restfulx.yml +25 -0
  16. data/bin/rx-gen +1 -1
  17. data/lib/restfulx/active_foo.rb +0 -8
  18. data/lib/restfulx/active_record_tasks.rb +9 -0
  19. data/lib/restfulx/active_record_uuid_helper.rb +17 -0
  20. data/lib/restfulx/configuration.rb +19 -31
  21. data/lib/restfulx/rails/schema_to_yaml/extensions/enumerable.rb +8 -0
  22. data/lib/restfulx/rails/schema_to_yaml/settings/config.rb +17 -0
  23. data/lib/restfulx/rails/schema_to_yaml/settings/core.rb +70 -0
  24. data/lib/restfulx/rails/schema_to_yaml.rb +121 -0
  25. data/lib/restfulx/rails/swf_helper.rb +1 -6
  26. data/lib/restfulx/tasks.rb +68 -42
  27. data/lib/restfulx.rb +4 -35
  28. data/rails_generators/rx_config/USAGE +2 -1
  29. data/rails_generators/rx_config/rx_config_generator.rb +80 -53
  30. data/rails_generators/rx_config/templates/actionscript.properties +3 -3
  31. data/rails_generators/rx_config/templates/actionscriptair.properties +3 -3
  32. data/rails_generators/rx_config/templates/flex_controller.erb +4 -0
  33. data/rails_generators/rx_config/templates/{index.html.erb → index.erb} +2 -4
  34. data/rails_generators/rx_config/templates/mainair-app.xml +3 -3
  35. data/rails_generators/rx_config/templates/mainapp.mxml +100 -2
  36. data/rails_generators/rx_config/templates/project-textmate.erb +4 -4
  37. data/rails_generators/rx_config/templates/project.properties +1 -1
  38. data/rails_generators/rx_config/templates/projectair.properties +1 -1
  39. data/rails_generators/rx_config/templates/restfulx.erb +38 -0
  40. data/rails_generators/rx_config/templates/restfulx.yml +55 -4
  41. data/rails_generators/rx_config/templates/restfulx_tasks.rake +3 -0
  42. data/rails_generators/rx_config/templates/routes.erb +47 -0
  43. data/rails_generators/rx_controller/rx_controller_generator.rb +9 -6
  44. data/rails_generators/rx_controller/templates/controller.as.erb +7 -9
  45. data/rails_generators/rx_main_app/rx_main_app_generator.rb +60 -0
  46. data/rails_generators/rx_main_app/templates/mainapp.mxml +129 -0
  47. data/rails_generators/rx_scaffold/rx_scaffold_generator.rb +88 -34
  48. data/rails_generators/rx_scaffold/templates/{controller.rb.erb → controllers/default.rb.erb} +29 -1
  49. data/rails_generators/rx_scaffold/templates/controllers/resource_controller.rb.erb +23 -0
  50. data/rails_generators/rx_scaffold/templates/fixtures.yml.erb +9 -5
  51. data/{generators/rx_scaffold/templates/component.mxml.erb → rails_generators/rx_scaffold/templates/layouts/default.erb} +75 -59
  52. data/rails_generators/rx_scaffold/templates/migration.rb.erb +29 -2
  53. data/rails_generators/rx_scaffold/templates/model.as.erb +33 -2
  54. data/rails_generators/rx_scaffold/templates/model.rb.erb +36 -1
  55. data/rails_generators/rx_yaml_scaffold/rx_yaml_scaffold_generator.rb +29 -10
  56. data/{generators → rxgen_generators}/rx_controller/rx_controller_generator.rb +7 -5
  57. data/{generators → rxgen_generators}/rx_controller/templates/assist.py +3 -3
  58. data/{generators → rxgen_generators}/rx_controller/templates/controller.as.erb +8 -6
  59. data/rxgen_generators/rx_controller/templates/iso8601.py +92 -0
  60. data/rxgen_generators/rx_main_app/USAGE +8 -0
  61. data/{generators → rxgen_generators}/rx_main_app/rx_main_app_generator.rb +10 -5
  62. data/rxgen_generators/rx_main_app/templates/mainapp.mxml +152 -0
  63. data/{generators → rxgen_generators}/rx_scaffold/rx_scaffold_generator.rb +6 -5
  64. data/{rails_generators → rxgen_generators}/rx_scaffold/templates/component.mxml.erb +24 -52
  65. data/spec/restfulx_spec.rb +1 -4
  66. data/spec/spec_helper.rb +0 -3
  67. data/tasks/restfulx.rake +2 -0
  68. metadata +102 -81
  69. data/History.txt +0 -7
  70. data/Manifest.txt +0 -127
  71. data/generators/rx_main_app/templates/mainapp.mxml +0 -35
  72. data/rdoc/generators/template/html/jamis.rb +0 -588
  73. data/tasks/ann.rake +0 -80
  74. data/tasks/bones.rake +0 -20
  75. data/tasks/gem.rake +0 -201
  76. data/tasks/git.rake +0 -40
  77. data/tasks/manifest.rake +0 -48
  78. data/tasks/notes.rake +0 -27
  79. data/tasks/post_load.rake +0 -39
  80. data/tasks/rdoc.rake +0 -50
  81. data/tasks/rubyforge.rake +0 -55
  82. data/tasks/setup.rb +0 -279
  83. data/tasks/spec.rake +0 -54
  84. data/tasks/svn.rake +0 -47
  85. data/tasks/test.rake +0 -40
  86. data/test/rails/playing_around_in_a_console.txt +0 -71
  87. /data/{generators → rails_generators}/rx_main_app/USAGE +0 -0
  88. /data/{generators → rxgen_generators}/rx_config/USAGE +0 -0
  89. /data/{generators → rxgen_generators}/rx_config/rx_config_generator.rb +0 -0
  90. /data/{generators → rxgen_generators}/rx_controller/USAGE +0 -0
  91. /data/{generators → rxgen_generators}/rx_controller/templates/restful.py +0 -0
  92. /data/{generators → rxgen_generators}/rx_main_app/templates/main.py.erb +0 -0
  93. /data/{generators → rxgen_generators}/rx_scaffold/USAGE +0 -0
  94. /data/{generators → rxgen_generators}/rx_scaffold/templates/controller.py.erb +0 -0
  95. /data/{generators → rxgen_generators}/rx_scaffold/templates/model.as.erb +0 -0
  96. /data/{generators → rxgen_generators}/rx_scaffold/templates/model.py.erb +0 -0
  97. /data/{generators → rxgen_generators}/rx_yaml_scaffold/USAGE +0 -0
  98. /data/{generators → rxgen_generators}/rx_yaml_scaffold/rx_yaml_scaffold_generator.rb +0 -0
@@ -11,11 +11,20 @@ class RxConfigGenerator < Rails::Generator::Base
11
11
  :command_controller_name,
12
12
  :component_names,
13
13
  :application_tag,
14
- :use_air
14
+ :use_air,
15
+ :flex_root,
16
+ :base_flex_package,
17
+ :distributed
15
18
 
16
19
  def initialize(runtime_args, runtime_options = {})
17
20
  super
18
- @project_name, @flex_project_name, @command_controller_name, @base_package, @base_folder = extract_names
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]
19
28
 
20
29
  # if we are updating main file only we probably want to maintain the type of project it is
21
30
  if options[:main_only]
@@ -32,7 +41,7 @@ class RxConfigGenerator < Rails::Generator::Base
32
41
  else
33
42
  @use_air = options[:air_config]
34
43
  end
35
-
44
+
36
45
  if @use_air
37
46
  @application_tag = 'WindowedApplication'
38
47
  else
@@ -40,60 +49,72 @@ class RxConfigGenerator < Rails::Generator::Base
40
49
  end
41
50
 
42
51
  @component_names = []
43
- if File.exists?("app/flex/#{base_folder}/components/generated")
44
- @component_names = list_mxml_files("app/flex/#{base_folder}/components/generated")
52
+ if File.exists?("#{flex_root}/#{base_folder}/components/generated")
53
+ @component_names = list_mxml_files("#{flex_root}/#{base_folder}/components/generated")
45
54
  end
46
55
  end
47
56
 
48
57
  def manifest
49
58
  record do |m|
50
- if !options[:main_only]
51
- m.file 'restfulx_tasks.rake', 'lib/tasks/restfulx_tasks.rake'
52
- m.file 'flex.properties', '.flexProperties'
53
- m.file 'restfulx.yml', 'config/restfulx.yml'
54
- if @use_air
55
- m.template 'actionscriptair.properties', '.actionScriptProperties'
56
- m.template 'projectair.properties', '.project'
57
- else
58
- m.template 'actionscript.properties', '.actionScriptProperties'
59
- m.template 'project.properties', '.project'
60
- end
61
-
62
- m.directory 'html-template/history'
63
- %w(index.template.html AC_OETags.js playerProductInstall.swf).each do |file|
64
- m.file "html-template/#{file}", "html-template/#{file}"
65
- end
66
-
67
- %w(history.css history.js historyFrame.html).each do |file|
68
- m.file "html-template/history/#{file}", "html-template/history/#{file}"
69
- end
70
-
71
- %w(components controllers commands models events).each do |dir|
72
- m.directory "app/flex/#{base_folder}/#{dir}"
73
- end
74
-
75
- m.directory "app/flex/#{base_folder}/components/generated"
76
-
77
- framework_release = RestfulX::FRAMEWORK_VERSION
78
- framework_distribution_url = "http://restfulx.github.com/releases/restfulx-#{framework_release}.swc"
79
- framework_destination_file = "lib/restfulx-#{framework_release}.swc"
80
-
81
- if !options[:skip_framework] && !File.exist?(framework_destination_file)
82
- puts "fetching #{framework_release} framework binary from: #{framework_distribution_url} ..."
83
- open(framework_destination_file, "wb").write(open(framework_distribution_url).read)
84
- puts "done. saved to #{framework_destination_file}"
85
- end
86
-
87
- m.file 'swfobject.js', 'public/javascripts/swfobject.js'
88
- m.file 'expressInstall.swf', 'public/expressInstall.swf'
89
- m.template 'index.html.erb', 'public/index.html'
90
-
91
- m.dependency 'rx_controller', @args
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.directory "#{flex_root}"
65
+
66
+ if @use_air
67
+ m.template 'actionscriptair.properties', '.actionScriptProperties'
68
+ m.template 'projectair.properties', '.project'
69
+ else
70
+ m.template 'actionscript.properties', '.actionScriptProperties'
71
+ m.template 'project.properties', '.project'
72
+ end
73
+
74
+ m.template 'project-textmate.erb', "#{project_name}.tmproj"
75
+ m.template 'mainapp.mxml', File.join("#{flex_root}", "#{flex_project_name}.mxml")
76
+ m.template 'mainapp-config.xml', File.join("#{flex_root}", "#{flex_project_name}-config.xml")
77
+ m.template 'mainair-app.xml', File.join("#{flex_root}", "#{flex_project_name}-app.xml") if @use_air
78
+
79
+ m.directory 'html-template/history'
80
+ %w(index.template.html AC_OETags.js playerProductInstall.swf).each do |file|
81
+ m.file "html-template/#{file}", "html-template/#{file}"
82
+ end
83
+
84
+ %w(history.css history.js historyFrame.html).each do |file|
85
+ m.file "html-template/history/#{file}", "html-template/history/#{file}"
92
86
  end
93
- m.template 'project-textmate.erb', "#{project_name.underscore}.tmproj"
94
- m.template 'mainapp.mxml', File.join('app/flex', "#{project_name}.mxml")
95
- m.template 'mainapp-config.xml', File.join('app/flex', "#{project_name}-config.xml")
96
- m.template 'mainair-app.xml', File.join('app/flex', "#{project_name}-app.xml") if @use_air
87
+
88
+ %w(components controllers commands models events).each do |dir|
89
+ m.directory "#{flex_root}/#{base_folder}/#{dir}"
90
+ end
91
+
92
+ m.directory "#{flex_root}/#{base_folder}/components/generated"
93
+
94
+ framework_release = RestfulX::FRAMEWORK_VERSION
95
+ framework_distribution_url = "http://restfulx.github.com/releases/restfulx-#{framework_release}.swc"
96
+ framework_destination_file = "lib/restfulx-#{framework_release}.swc"
97
+
98
+ if !options[:skip_framework] && !File.exist?(framework_destination_file)
99
+ puts "fetching #{framework_release} framework binary from: #{framework_distribution_url} ..."
100
+ open(framework_destination_file, "wb").write(open(framework_distribution_url).read)
101
+ puts "done. saved to #{framework_destination_file}"
102
+ end
103
+
104
+ m.file 'swfobject.js', 'public/javascripts/swfobject.js'
105
+ m.file 'expressInstall.swf', 'public/expressInstall.swf'
106
+
107
+ m.file 'flex_controller.erb', 'app/controllers/flex_controller.rb'
108
+
109
+ m.directory "app/views/flex"
110
+
111
+ m.template 'index.erb', 'app/views/flex/index.html.erb'
112
+
113
+ m.file 'routes.erb', 'config/routes.rb', :collision => :force
114
+
115
+ FileUtils.rm 'public/index.html' if File.exist?('public/index.html')
116
+
117
+ m.dependency 'rx_controller', @args
97
118
  end
98
119
  end
99
120
 
@@ -101,12 +122,18 @@ class RxConfigGenerator < Rails::Generator::Base
101
122
  def add_options!(opt)
102
123
  opt.separator ''
103
124
  opt.separator 'Options:'
104
- opt.on("-m", "--main-only", "Only generate the main Flex/AIR application file.",
105
- "Default: false") { |v| options[:main_only] = v }
106
125
  opt.on("-a", "--air", "Configure AIR project instead of Flex. Flex is default.",
107
126
  "Default: false") { |v| options[:air_config] = v }
108
127
  opt.on("--skip-framework", "Don't fetch the latest framework binary. You'll have to link/build the framework yourself.",
109
128
  "Default: false") { |v| options[:skip_framework] = v }
129
+ opt.on("--skip-tasks", "Don't install restfulx gem tasks hook into the project.",
130
+ "Default: false") { |v| options[:skip_tasks] = v }
131
+ opt.on("--flex-root [FOLDER]", "Root folder for generated flex code.",
132
+ "Default: app/flex") { |v| options[:flex_root] = v }
133
+ opt.on("--base-flex-package [PACKAGE]", "Base package for your application.",
134
+ "Default: #{flex_project_name}") { |v| options[:base_flex_package] = v }
135
+ opt.on("--distributed", "Creates migrations, controllers and models that use UUIDs and are distribution ready",
136
+ "Default: false") { |v| options[:distributed] = v }
110
137
  end
111
138
 
112
139
  def banner
@@ -1,6 +1,6 @@
1
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:3000/bin" sourceFolderPath="app/flex" strict="true" useApolloConfig="false" verifyDigests="true" warn="true">
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">
4
4
  <compilerSourcePath/>
5
5
  <libraryPath defaultLinkType="1">
6
6
  <libraryPathEntry kind="4" path=""/>
@@ -9,7 +9,7 @@
9
9
  <sourceAttachmentPath/>
10
10
  </compiler>
11
11
  <applications>
12
- <application path="<%= project_name %>.mxml"/>
12
+ <application path="<%= flex_project_name %>.mxml"/>
13
13
  </applications>
14
14
  <modules/>
15
15
  <buildCSSFiles/>
@@ -1,6 +1,6 @@
1
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">
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">
4
4
  <compilerSourcePath/>
5
5
  <libraryPath defaultLinkType="1">
6
6
  <libraryPathEntry kind="4" path=""/>
@@ -9,7 +9,7 @@
9
9
  <sourceAttachmentPath/>
10
10
  </compiler>
11
11
  <applications>
12
- <application path="<%= project_name %>.mxml"/>
12
+ <application path="<%= flex_project_name %>.mxml"/>
13
13
  </applications>
14
14
  <modules/>
15
15
  <buildCSSFiles/>
@@ -0,0 +1,4 @@
1
+ class FlexController < ApplicationController
2
+ def index
3
+ end
4
+ end
@@ -3,15 +3,13 @@
3
3
  <title><%= project_name %></title>
4
4
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
5
5
  <script type="text/javascript" src="javascripts/swfobject.js"></script>
6
- <script type="text/javascript">
7
- swfobject.embedSWF("bin/<%= project_name %>.swf", "mainApp", "100%", "100%", "9.0.0", "expressInstall.swf");
8
- </script>
6
+ <%%= swfobject("/bin/<%= flex_project_name %>.swf") %>
9
7
  <style>
10
8
  body { margin: 0px; overflow: hidden; }
11
9
  </style>
12
10
  </head>
13
11
  <body>
14
- <div id="mainApp">
12
+ <div id="flashContent">
15
13
  <p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>
16
14
  </div>
17
15
  </body>
@@ -15,13 +15,13 @@
15
15
  -->
16
16
 
17
17
  <!-- The application identifier string, unique to this application. Required. -->
18
- <id><%= project_name %></id>
18
+ <id><%= flex_project_name %></id>
19
19
 
20
20
  <!-- Used as the filename for the application. Required. -->
21
- <filename><%= project_name %></filename>
21
+ <filename><%= flex_project_name %></filename>
22
22
 
23
23
  <!-- The name that is displayed in the AIR application installer. Optional. -->
24
- <name><%= project_name %></name>
24
+ <name><%= flex_project_name %></name>
25
25
 
26
26
  <!-- An application version designator (such as "v1", "2.5", or "Alpha 1"). Required. -->
27
27
  <version>v1</version>
@@ -6,20 +6,119 @@
6
6
  <mx:Script>
7
7
  <![CDATA[
8
8
  <% if use_air -%>
9
+ <% if distributed -%>
10
+ import air.net.SocketMonitor;
11
+ import org.restfulx.events.PullEndEvent;
12
+ import org.restfulx.events.PullStartEvent;
13
+ import org.restfulx.events.PushEndEvent;
14
+ import org.restfulx.events.PushStartEvent;
15
+ import org.restfulx.controllers.ChangeController;
16
+ import org.restfulx.services.ISyncingServiceProvider;
17
+ import org.restfulx.services.http.XMLHTTPServiceProvider;
18
+ <% end -%>
9
19
  import org.restfulx.services.air.AIRServiceProvider;
10
20
  <% end -%>
11
21
  import org.restfulx.Rx;
12
22
  import <%= base_package %>.controllers.<%= command_controller_name %>;
23
+ <% if use_air -%>
24
+ <% if distributed -%>
25
+
26
+ [Bindable]
27
+ private var socketMonitor:SocketMonitor;
28
+
29
+ [Bindable]
30
+ private var online:Boolean;
31
+
32
+ [Bindable]
33
+ private var syncStatus:String;
34
+ <% end -%>
35
+ <% end -%>
13
36
 
14
37
  private function init():void {
15
38
  <% if use_air -%>
16
- <%= command_controller_name %>.initialize([AIRServiceProvider], AIRServiceProvider.ID, "<%= base_package %>");
39
+ <% if distributed -%>
40
+ Rx.httpRootUrl = "http://localhost:3000/";
41
+ Rx.enableSync = true;
42
+
43
+ socketMonitor = new SocketMonitor("localhost", 3000);
44
+ socketMonitor.pollInterval = 2000; /* miliseconds */
45
+ socketMonitor.addEventListener(StatusEvent.STATUS, onNetworkStatusChange);
46
+ socketMonitor.start();
47
+
48
+ <% end -%>
49
+ <%= command_controller_name %>.initialize([AIRServiceProvider],
50
+ AIRServiceProvider.ID, "<%= base_package %>");
51
+ <% if distributed -%>
52
+
53
+ Rx.changes.setSyncProviders(
54
+ ISyncingServiceProvider(Rx.services.getServiceProvider(AIRServiceProvider.ID)),
55
+ Rx.services.getServiceProvider(XMLHTTPServiceProvider.ID));
56
+
57
+ Rx.changes.addEventListener(PushStartEvent.ID, onPushStart);
58
+ Rx.changes.addEventListener(PushEndEvent.ID, onPushEnd);
59
+ Rx.changes.addEventListener(PullStartEvent.ID, onPullStart);
60
+ Rx.changes.addEventListener(PullEndEvent.ID, onPullEnd);
61
+ <% end -%>
17
62
  <% else -%>
18
63
  <%= command_controller_name %>.initialize();
19
64
  <% end -%>
20
65
  }
66
+ <% if use_air -%>
67
+ <% if distributed -%>
68
+
69
+ private function onPushStart(event:Event):void {
70
+ syncStatus = "Pushing changes ...";
71
+ }
72
+
73
+ private function onPushEnd(event:Event):void {
74
+ syncStatus = "Push complete.";
75
+ }
76
+
77
+ private function onPullStart(event:Event):void {
78
+ syncStatus = "Pulling data...";
79
+ }
80
+
81
+ private function onPullEnd(event:Event):void {
82
+ syncStatus = "Pull complete.";
83
+ }
84
+
85
+ private function onNetworkStatusChange(event:StatusEvent):void {
86
+ online = (socketMonitor.available) ? true : false;
87
+
88
+ if (online) {
89
+ Rx.defaultServiceId = XMLHTTPServiceProvider.ID;
90
+ } else {
91
+ Rx.defaultServiceId = AIRServiceProvider.ID;
92
+ }
93
+ }
94
+
95
+ private function getCurrentProviderName(id:int):String {
96
+ switch (id) {
97
+ case XMLHTTPServiceProvider.ID:
98
+ return "Rails";
99
+ case AIRServiceProvider.ID:
100
+ return "AIR (SQLite)";
101
+ default :
102
+ return "No idea";
103
+ }
104
+ }
105
+ <% end -%>
106
+ <% end -%>
21
107
  ]]>
22
108
  </mx:Script>
109
+ <% if use_air -%>
110
+ <% if distributed -%>
111
+ <mx:VBox height="100%">
112
+ <mx:Label text="Current Provider: {getCurrentProviderName(Rx.defaultServiceId)}"/>
113
+ <mx:Label text="Status: {online ? 'Online' : 'Offline' }"/>
114
+ <mx:HBox>
115
+ <mx:Button label="Push" click="{Rx.changes.push()}" enabled="{online}"/>
116
+ <mx:Button label="Pull" click="{Rx.changes.pull()}" enabled="{online}"/>
117
+ </mx:HBox>
118
+ <mx:Label text="{syncStatus}"/>
119
+ </mx:VBox>
120
+ <% end -%>
121
+ <% end -%>
23
122
  <mx:LinkBar dataProvider="{mainViewStack}" direction="vertical" borderStyle="solid" backgroundColor="#EEEEEE"/>
24
123
  <mx:ViewStack id="mainViewStack" width="100%" height="100%">
25
124
  <!-- For a simple demo, put all the components here. -->
@@ -28,4 +127,3 @@
28
127
  <% end -%>
29
128
  </mx:ViewStack>
30
129
  </mx:<%= application_tag %>>
31
-
@@ -3,14 +3,14 @@
3
3
  <plist version="1.0">
4
4
  <dict>
5
5
  <key>currentDocument</key>
6
- <string>app/flex/<%= project_name %>.mxml</string>
6
+ <string>app/flex/<%= flex_project_name %>.mxml</string>
7
7
  <key>documents</key>
8
8
  <array>
9
9
  <dict>
10
10
  <key>expanded</key>
11
11
  <true/>
12
12
  <key>name</key>
13
- <string><%= project_name.underscore %></string>
13
+ <string><%= project_name %></string>
14
14
  <key>regexFolderFilter</key>
15
15
  <string>!.*/(\.[^/]*|CVS|_darcs|_MTN|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$</string>
16
16
  <key>sourceDirectory</key>
@@ -27,7 +27,7 @@
27
27
  <key>enabled</key>
28
28
  <true/>
29
29
  <key>value</key>
30
- <string>app/flex/<%= project_name %>.mxml</string>
30
+ <string>app/flex/<%= flex_project_name %>.mxml</string>
31
31
  <key>variable</key>
32
32
  <string>TM_FLEX_FILE_SPECS</string>
33
33
  </dict>
@@ -35,7 +35,7 @@
35
35
  <key>enabled</key>
36
36
  <true/>
37
37
  <key>value</key>
38
- <string>public/bin/<%= project_name %>.swf</string>
38
+ <string>public/bin/<%= flex_project_name %>.swf</string>
39
39
  <key>variable</key>
40
40
  <string>TM_FLEX_OUTPUT</string>
41
41
  </dict>
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <projectDescription>
3
- <name><%= flex_project_name %></name>
3
+ <name><%= project_name %></name>
4
4
  <comment></comment>
5
5
  <projects>
6
6
  </projects>
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <projectDescription>
3
- <name><%= flex_project_name %></name>
3
+ <name><%= project_name %></name>
4
4
  <comment></comment>
5
5
  <projects>
6
6
  </projects>
@@ -0,0 +1,38 @@
1
+ # When you do file uploads from Flash with File.upload() that, unfortunately generates a new session id,
2
+ # which will fail to authenticate if you are using restful-authentication plugin or equivalent.
3
+ #
4
+ # The following code is a work-around for the Flash bug that prevents file uploader
5
+ # from sending correct session_id. Here, we hack the Session#initialize method and force the session_id
6
+ # to load from the query string via the request URI.
7
+ #
8
+ # Based on the code from http://seventytwo.co.uk/posts/making-swfupload-and-rails-work-together
9
+ class CGI::Session
10
+ alias original_initialize initialize
11
+
12
+ def initialize(request, option = {})
13
+ option = scan_for_session_id(request, '_session_id', option) unless option['session_id']
14
+ original_initialize(request, option)
15
+ end
16
+
17
+ def scan_for_session_id(request, session_key = '_session_id', option = {})
18
+ query_string = if (qs = request.env_table["QUERY_STRING"]) and qs != ""
19
+ qs
20
+ elsif (ru = request.env_table["REQUEST_URI"][0..-1]).include?("?")
21
+ ru[(ru.index("?") + 1)..-1]
22
+ end
23
+ if query_string and query_string.include?(session_key)
24
+ option['session_id'] = query_string.scan(/#{session_key}=(.*?)(&.*?)*$/).flatten.first
25
+ end
26
+ return option
27
+ end
28
+ end
29
+
30
+ # If you have configured your Rails/Flex/AIR application to share authenticity_token
31
+ # comment this out to enable forgery protection. By default, this is disabled to allow
32
+ # generated code to work out of the box.
33
+ ActionController::Base.allow_forgery_protection = false
34
+
35
+ <% if distributed -%>
36
+ # If we are in distributed mode we need to make sure that the RestfulX::UUIDHelper is loaded
37
+ require "restfulx/active_record_uuid_helper"
38
+ <% end -%>
@@ -1,14 +1,65 @@
1
1
  # RestfulX code generation configuration options
2
2
 
3
+ # This option controls what the main Flex application file will be called.
4
+ # By default it will be equal to the name of your rails project camelized
5
+ project-name: <%= project_name %>
6
+
7
+ # This options determines what the root folder for generated Flex code is.
8
+ # By default 'app/flex'
9
+ flex-root: <%= flex_root %>
10
+
3
11
  # By default flex models, commands, controllers and components are genearated into
4
- # app/flex/<your rails project name> folder. If you'd like to customize the target folder
12
+ # <flex-root>/<your rails project name> folder. If you'd like to customize the target folder
5
13
  # (to say append a "com" package before your rails project name) uncomment the line below
6
14
  # base-package must follow the usual flex package notation (a string separated by ".")
7
-
8
- #base-package: com.pomodo
15
+ base-package: <%= base_package %>
9
16
 
10
17
  # Main RestfulX controller is typically named AppicationController. This controller is created in
11
18
  # <base-package>.controllers folder. You can customize the name by uncommenting the following line
12
19
  # and changing the controller name.
20
+ controller-name: <%= command_controller_name %>
21
+
22
+ # If you are using Rails on the back-end and Adobe AIR as the client you can generate Rails/Flex/AIR
23
+ # code to take advantage of synchronization (online/offline) support in RestfulX by changing the following
24
+ # option to true. By default distribution is disabled.
25
+ distributed: <%= distributed %>
26
+
27
+ # These options control code-generation options for view components, Flex and Rails models and so on.
28
+ # Allowing you to choose what controller patterns, layouts, attachment plugin you want to use, etc.
29
+ defaults: &defaults
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
+ # set up specific options for development environment
39
+ development:
40
+ <<: *defaults
41
+
42
+ # set up specific options for test environment
43
+ test:
44
+ <<: *defaults
13
45
 
14
- #controller-name: ApplicationController
46
+ # set up specific options for production environment
47
+ production:
48
+ <<: *defaults
49
+
50
+ # The following special model.yml fields are supported.
51
+ #
52
+ # For example:
53
+ # attachment_field: [avatar]
54
+ # * arg takes Paperclip field name, or takes [uploaded_data] for Attachment_Fu
55
+ # belongs_to: [account, profile]
56
+ # has_many: [announcements, files, folders, users]
57
+ # has_many_through: [permissions, roles]
58
+ # * has_many :roles, :through => :permissions
59
+ # has_one: [suitcase]
60
+ # polymorphic: [commentable]
61
+ # tree_model: [parent]
62
+ # layout: [default]
63
+ # * default template is the only current theme, with more coming soon
64
+ # ignored_fields: [children_count, ancestors_count, descendants_count, position]
65
+ # * specify fields you don't want generated for your template
@@ -3,4 +3,7 @@ begin
3
3
  # this will load the latest restfulx gem version
4
4
  require 'restfulx/active_record_tasks'
5
5
  rescue LoadError
6
+ puts "Could not load active_record_tasks from 'restfulx/active_record_tasks'. " <<
7
+ "If you are loading restfulx gem from vendor/gems, adjust the path to active_record_tasks in " <<
8
+ "lib/tasks/restfulx_tasks.rake accordingly."
6
9
  end
@@ -0,0 +1,47 @@
1
+ ActionController::Routing::Routes.draw do |map|
2
+
3
+ # Map application root to default RestfulX controller
4
+ map.root :controller => "flex"
5
+
6
+ # The priority is based upon order of creation: first created -> highest priority.
7
+
8
+ # Sample of regular route:
9
+ # map.connect 'products/:id', :controller => 'catalog', :action => 'view'
10
+ # Keep in mind you can assign values other than :controller and :action
11
+
12
+ # Sample of named route:
13
+ # map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
14
+ # This route can be invoked with purchase_url(:id => product.id)
15
+
16
+ # Sample resource route (maps HTTP verbs to controller actions automatically):
17
+ # map.resources :products
18
+
19
+ # Sample resource route with options:
20
+ # map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
21
+
22
+ # Sample resource route with sub-resources:
23
+ # map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
24
+
25
+ # Sample resource route with more complex sub-resources
26
+ # map.resources :products do |products|
27
+ # products.resources :comments
28
+ # products.resources :sales, :collection => { :recent => :get }
29
+ # end
30
+
31
+ # Sample resource route within a namespace:
32
+ # map.namespace :admin do |admin|
33
+ # # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
34
+ # admin.resources :products
35
+ # end
36
+
37
+ # You can have the root of your site routed with map.root -- just remember to delete public/index.html.
38
+ # map.root :controller => "welcome"
39
+
40
+ # See how all your routes lay out with "rake routes"
41
+
42
+ # Install the default routes as the lowest priority.
43
+ # Note: These default routes make all actions in every controller accessible via GET requests. You should
44
+ # consider removing the them or commenting them out if you're using named routes and resources.
45
+ map.connect ':controller/:action/:id'
46
+ map.connect ':controller/:action/:id.:format'
47
+ end
@@ -9,20 +9,23 @@ class RxControllerGenerator < Rails::Generator::Base
9
9
  :base_folder,
10
10
  :command_controller_name,
11
11
  :model_names,
12
- :command_names
12
+ :command_names,
13
+ :flex_root,
14
+ :distributed
13
15
 
14
16
  def initialize(runtime_args, runtime_options = {})
15
17
  super
16
- @project_name, @flex_project_name, @command_controller_name, @base_package, @base_folder = extract_names
18
+ @project_name, @flex_project_name, @command_controller_name, @base_package, @base_folder,
19
+ @flex_root, @distributed = extract_names
17
20
 
18
- @model_names = list_as_files("app/flex/#{base_folder}/models")
19
- @command_names = list_as_files("app/flex/#{base_folder}/commands")
21
+ @model_names = list_as_files("#{@flex_root}/#{@base_folder}/models")
22
+ @command_names = list_as_files("#{@flex_root}/#{@base_folder}/commands")
20
23
  end
21
24
 
22
25
  def manifest
23
26
  record do |m|
24
- m.template 'controller.as.erb', File.join("app/flex/#{base_folder}/controllers",
25
- "#{command_controller_name}.as")
27
+ m.template 'controller.as.erb', File.join("#{@flex_root}/#{@base_folder}/controllers",
28
+ "#{@command_controller_name}.as")
26
29
  end
27
30
  end
28
31
  end