captproton-restfulx 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.
Files changed (143) hide show
  1. data/README.rdoc +50 -0
  2. data/Rakefile +79 -0
  3. data/VERSION.yml +4 -0
  4. data/app_generators/rx_app/USAGE +22 -0
  5. data/app_generators/rx_app/rx_app_generator.rb +110 -0
  6. data/app_generators/rx_app/templates/actionscript.properties +16 -0
  7. data/app_generators/rx_app/templates/actionscriptair.properties +16 -0
  8. data/app_generators/rx_app/templates/app.yaml.erb +12 -0
  9. data/app_generators/rx_app/templates/default_tasks.rake +38 -0
  10. data/app_generators/rx_app/templates/empty.txt +0 -0
  11. data/app_generators/rx_app/templates/expressInstall.swf +0 -0
  12. data/app_generators/rx_app/templates/flex.properties +2 -0
  13. data/app_generators/rx_app/templates/generate.rb +17 -0
  14. data/app_generators/rx_app/templates/html-template/AC_OETags.js +276 -0
  15. data/app_generators/rx_app/templates/html-template/history/history.css +6 -0
  16. data/app_generators/rx_app/templates/html-template/history/history.js +645 -0
  17. data/app_generators/rx_app/templates/html-template/history/historyFrame.html +29 -0
  18. data/app_generators/rx_app/templates/html-template/index.template.html +121 -0
  19. data/app_generators/rx_app/templates/html-template/playerProductInstall.swf +0 -0
  20. data/app_generators/rx_app/templates/index.html.erb +18 -0
  21. data/app_generators/rx_app/templates/index.yaml +11 -0
  22. data/app_generators/rx_app/templates/mainair-app.xml +134 -0
  23. data/app_generators/rx_app/templates/mainapp-config.xml +22 -0
  24. data/app_generators/rx_app/templates/mainapp.mxml +152 -0
  25. data/app_generators/rx_app/templates/project-textmate.erb +72 -0
  26. data/app_generators/rx_app/templates/project.properties +18 -0
  27. data/app_generators/rx_app/templates/projectair.properties +24 -0
  28. data/app_generators/rx_app/templates/restfulx.yml +46 -0
  29. data/app_generators/rx_app/templates/swfobject.js +5 -0
  30. data/bin/rx-gen +31 -0
  31. data/lib/restfulx.rb +90 -0
  32. data/lib/restfulx/active_foo.rb +181 -0
  33. data/lib/restfulx/active_record_tasks.rb +90 -0
  34. data/lib/restfulx/active_record_uuid_helper.rb +17 -0
  35. data/lib/restfulx/configuration.rb +75 -0
  36. data/lib/restfulx/datamapper_foo.rb +81 -0
  37. data/lib/restfulx/rails/recipes.rb +60 -0
  38. data/lib/restfulx/rails/schema_to_yaml.rb +112 -0
  39. data/lib/restfulx/rails/schema_to_yaml/extensions/enumerable.rb +8 -0
  40. data/lib/restfulx/rails/schema_to_yaml/settings/config.rb +17 -0
  41. data/lib/restfulx/rails/schema_to_yaml/settings/core.rb +73 -0
  42. data/lib/restfulx/rails/swf_helper.rb +59 -0
  43. data/lib/restfulx/tasks.rb +110 -0
  44. data/rails_generators/rx_config/USAGE +19 -0
  45. data/rails_generators/rx_config/rx_config_generator.rb +151 -0
  46. data/rails_generators/rx_config/templates/actionscript.properties +16 -0
  47. data/rails_generators/rx_config/templates/actionscriptair.properties +16 -0
  48. data/rails_generators/rx_config/templates/expressInstall.swf +0 -0
  49. data/rails_generators/rx_config/templates/flex.properties +2 -0
  50. data/rails_generators/rx_config/templates/flex_controller.erb +4 -0
  51. data/rails_generators/rx_config/templates/html-template/AC_OETags.js +276 -0
  52. data/rails_generators/rx_config/templates/html-template/history/history.css +6 -0
  53. data/rails_generators/rx_config/templates/html-template/history/history.js +645 -0
  54. data/rails_generators/rx_config/templates/html-template/history/historyFrame.html +29 -0
  55. data/rails_generators/rx_config/templates/html-template/index.template.html +121 -0
  56. data/rails_generators/rx_config/templates/html-template/playerProductInstall.swf +0 -0
  57. data/rails_generators/rx_config/templates/index.erb +16 -0
  58. data/rails_generators/rx_config/templates/mainair-app.xml +134 -0
  59. data/rails_generators/rx_config/templates/mainapp-config.xml +22 -0
  60. data/rails_generators/rx_config/templates/mainapp.mxml +129 -0
  61. data/rails_generators/rx_config/templates/project-textmate.erb +72 -0
  62. data/rails_generators/rx_config/templates/project.properties +18 -0
  63. data/rails_generators/rx_config/templates/projectair.properties +24 -0
  64. data/rails_generators/rx_config/templates/restfulx.erb +75 -0
  65. data/rails_generators/rx_config/templates/restfulx.yml +65 -0
  66. data/rails_generators/rx_config/templates/restfulx_tasks.rake +9 -0
  67. data/rails_generators/rx_config/templates/routes.erb +47 -0
  68. data/rails_generators/rx_config/templates/session_store_flash.erb +1 -0
  69. data/rails_generators/rx_config/templates/swfobject.js +5 -0
  70. data/rails_generators/rx_controller/USAGE +10 -0
  71. data/rails_generators/rx_controller/rx_controller_generator.rb +31 -0
  72. data/rails_generators/rx_controller/templates/controller.as.erb +38 -0
  73. data/rails_generators/rx_main_app/USAGE +8 -0
  74. data/rails_generators/rx_main_app/rx_main_app_generator.rb +60 -0
  75. data/rails_generators/rx_main_app/templates/mainapp.mxml +129 -0
  76. data/rails_generators/rx_scaffold/USAGE +35 -0
  77. data/rails_generators/rx_scaffold/rx_scaffold_generator.rb +242 -0
  78. data/rails_generators/rx_scaffold/templates/controllers/default.rb.erb +125 -0
  79. data/rails_generators/rx_scaffold/templates/controllers/resource_controller.rb.erb +23 -0
  80. data/rails_generators/rx_scaffold/templates/fixtures.yml.erb +39 -0
  81. data/rails_generators/rx_scaffold/templates/functional_test.rb +45 -0
  82. data/rails_generators/rx_scaffold/templates/helper_test.rb +4 -0
  83. data/rails_generators/rx_scaffold/templates/layouts/default.erb +167 -0
  84. data/rails_generators/rx_scaffold/templates/migration.rb.erb +46 -0
  85. data/rails_generators/rx_scaffold/templates/model.as.erb +73 -0
  86. data/rails_generators/rx_scaffold/templates/model.rb.erb +46 -0
  87. data/rails_generators/rx_yaml_scaffold/USAGE +51 -0
  88. data/rails_generators/rx_yaml_scaffold/rx_yaml_scaffold_generator.rb +68 -0
  89. data/rxgen_generators/rx_config/USAGE +5 -0
  90. data/rxgen_generators/rx_config/rx_config_generator.rb +21 -0
  91. data/rxgen_generators/rx_controller/USAGE +10 -0
  92. data/rxgen_generators/rx_controller/rx_controller_generator.rb +41 -0
  93. data/rxgen_generators/rx_controller/templates/assist.py +65 -0
  94. data/rxgen_generators/rx_controller/templates/controller.as.erb +38 -0
  95. data/rxgen_generators/rx_controller/templates/iso8601.py +92 -0
  96. data/rxgen_generators/rx_controller/templates/restful.py +136 -0
  97. data/rxgen_generators/rx_main_app/USAGE +8 -0
  98. data/rxgen_generators/rx_main_app/rx_main_app_generator.rb +65 -0
  99. data/rxgen_generators/rx_main_app/templates/main.py.erb +29 -0
  100. data/rxgen_generators/rx_main_app/templates/mainapp.mxml +152 -0
  101. data/rxgen_generators/rx_scaffold/USAGE +29 -0
  102. data/rxgen_generators/rx_scaffold/rx_scaffold_generator.rb +194 -0
  103. data/rxgen_generators/rx_scaffold/templates/controller.py.erb +27 -0
  104. data/rxgen_generators/rx_scaffold/templates/layouts/default.erb +167 -0
  105. data/rxgen_generators/rx_scaffold/templates/model.as.erb +73 -0
  106. data/rxgen_generators/rx_scaffold/templates/model.py.erb +14 -0
  107. data/rxgen_generators/rx_yaml_scaffold/USAGE +45 -0
  108. data/rxgen_generators/rx_yaml_scaffold/rx_yaml_scaffold_generator.rb +47 -0
  109. data/spec/restfulx_spec.rb +4 -0
  110. data/spec/spec_helper.rb +13 -0
  111. data/tasks/restfulx.rake +2 -0
  112. data/test/rails/controllers/application_controller.rb +15 -0
  113. data/test/rails/controllers/locations_controller.rb +93 -0
  114. data/test/rails/controllers/notes_controller.rb +96 -0
  115. data/test/rails/controllers/projects_controller.rb +93 -0
  116. data/test/rails/controllers/tasks_controller.rb +93 -0
  117. data/test/rails/controllers/users_controller.rb +93 -0
  118. data/test/rails/database.yml +4 -0
  119. data/test/rails/fixtures/locations.yml +8 -0
  120. data/test/rails/fixtures/notes.yml +17 -0
  121. data/test/rails/fixtures/projects.yml +25 -0
  122. data/test/rails/fixtures/simple_properties.yml +19 -0
  123. data/test/rails/fixtures/tasks.yml +46 -0
  124. data/test/rails/fixtures/users.yml +13 -0
  125. data/test/rails/helpers/functional_test_helper.rb +21 -0
  126. data/test/rails/helpers/test_helper.rb +54 -0
  127. data/test/rails/helpers/unit_test_helper.rb +29 -0
  128. data/test/rails/model.yml +35 -0
  129. data/test/rails/models/location.rb +4 -0
  130. data/test/rails/models/note.rb +3 -0
  131. data/test/rails/models/project.rb +4 -0
  132. data/test/rails/models/simple_property.rb +2 -0
  133. data/test/rails/models/task.rb +18 -0
  134. data/test/rails/models/user.rb +20 -0
  135. data/test/rails/schema.rb +77 -0
  136. data/test/rails/test.swf +1 -0
  137. data/test/rails/test_active_foo.rb +36 -0
  138. data/test/rails/test_rails_integration_functional.rb +22 -0
  139. data/test/rails/test_to_fxml.rb +35 -0
  140. data/test/rails/test_to_json.rb +23 -0
  141. data/test/rails/views/notes/empty_params_action.html.erb +1 -0
  142. data/test/rails/views/notes/index.html.erb +1 -0
  143. metadata +234 -0
@@ -0,0 +1,72 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>currentDocument</key>
6
+ <string>app/flex/<%= flex_project_name %>.mxml</string>
7
+ <key>documents</key>
8
+ <array>
9
+ <dict>
10
+ <key>expanded</key>
11
+ <true/>
12
+ <key>name</key>
13
+ <string><%= project_name %></string>
14
+ <key>regexFolderFilter</key>
15
+ <string>!.*/(\.[^/]*|CVS|_darcs|_MTN|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$</string>
16
+ <key>sourceDirectory</key>
17
+ <string></string>
18
+ </dict>
19
+ </array>
20
+ <key>fileHierarchyDrawerWidth</key>
21
+ <integer>299</integer>
22
+ <key>metaData</key>
23
+ <dict/>
24
+ <key>shellVariables</key>
25
+ <array>
26
+ <dict>
27
+ <key>enabled</key>
28
+ <true/>
29
+ <key>value</key>
30
+ <string>app/flex/<%= flex_project_name %>.mxml</string>
31
+ <key>variable</key>
32
+ <string>TM_FLEX_FILE_SPECS</string>
33
+ </dict>
34
+ <dict>
35
+ <key>enabled</key>
36
+ <true/>
37
+ <key>value</key>
38
+ <string>public/bin/<%= flex_project_name %>.swf</string>
39
+ <key>variable</key>
40
+ <string>TM_FLEX_OUTPUT</string>
41
+ </dict>
42
+ <dict>
43
+ <key>enabled</key>
44
+ <true/>
45
+ <key>value</key>
46
+ <string>app/flex</string>
47
+ <key>variable</key>
48
+ <string>TM_AS3_USUAL_SRC_DIRS</string>
49
+ </dict>
50
+ <dict>
51
+ <key>enabled</key>
52
+ <true/>
53
+ <key>value</key>
54
+ <string>/Users/Dima/Projects/dev/restfulx_framework/framework/src</string>
55
+ <key>variable</key>
56
+ <string>TM_AS3_LIB_SRC_DIRS</string>
57
+ </dict>
58
+ <dict>
59
+ <key>enabled</key>
60
+ <true/>
61
+ <key>value</key>
62
+ <string><%= use_air ? 'air' : 'flex' %></string>
63
+ <key>variable</key>
64
+ <string>TM_FLEX_RUNTIME</string>
65
+ </dict>
66
+ </array>
67
+ <key>showFileHierarchyDrawer</key>
68
+ <false/>
69
+ <key>windowFrame</key>
70
+ <string>{{53, 14}, {1221, 864}}</string>
71
+ </dict>
72
+ </plist>
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <projectDescription>
3
+ <name><%= project_name %></name>
4
+ <comment></comment>
5
+ <projects>
6
+ </projects>
7
+ <buildSpec>
8
+ <buildCommand>
9
+ <name>com.adobe.flexbuilder.project.flexbuilder</name>
10
+ <arguments>
11
+ </arguments>
12
+ </buildCommand>
13
+ </buildSpec>
14
+ <natures>
15
+ <nature>com.adobe.flexbuilder.project.flexnature</nature>
16
+ <nature>com.adobe.flexbuilder.project.actionscriptnature</nature>
17
+ </natures>
18
+ </projectDescription>
@@ -0,0 +1,24 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <projectDescription>
3
+ <name><%= project_name %></name>
4
+ <comment></comment>
5
+ <projects>
6
+ </projects>
7
+ <buildSpec>
8
+ <buildCommand>
9
+ <name>com.adobe.flexbuilder.project.flexbuilder</name>
10
+ <arguments>
11
+ </arguments>
12
+ </buildCommand>
13
+ <buildCommand>
14
+ <name>com.adobe.flexbuilder.apollo.apollobuilder</name>
15
+ <arguments>
16
+ </arguments>
17
+ </buildCommand>
18
+ </buildSpec>
19
+ <natures>
20
+ <nature>com.adobe.flexbuilder.apollo.apollonature</nature>
21
+ <nature>com.adobe.flexbuilder.project.flexnature</nature>
22
+ <nature>com.adobe.flexbuilder.project.actionscriptnature</nature>
23
+ </natures>
24
+ </projectDescription>
@@ -0,0 +1,46 @@
1
+ # RestfulX code generation configuration options
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
+
11
+ # By default flex models, commands, controllers and components are genearated into
12
+ # <flex-root>/<your rails project name> folder. If you'd like to customize the target folder
13
+ # (to say append a "com" package before your rails project name) uncomment the line below
14
+ # base-package must follow the usual flex package notation (a string separated by ".")
15
+ base_package: <%= base_package %>
16
+
17
+ # Main RestfulX controller is typically named AppicationController. This controller is created in
18
+ # <base-package>.controllers folder. You can customize the name by uncommenting the following line
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
+ # Choose the layout to use for generated Flex view components
28
+ layouts:
29
+ default: 'default'
30
+
31
+ # The following special model.yml fields are supported.
32
+ #
33
+ # For example:
34
+ # attachment_field: [avatar]
35
+ # * arg takes Paperclip field name, or takes [uploaded_data] for Attachment_Fu
36
+ # belongs_to: [account, profile]
37
+ # has_many: [announcements, files, folders, users]
38
+ # has_many_through: [permissions, roles]
39
+ # * has_many :roles, :through => :permissions
40
+ # has_one: [suitcase]
41
+ # polymorphic: [commentable]
42
+ # tree_model: [parent]
43
+ # layout: [default]
44
+ # * default template is the only current theme, with more coming soon
45
+ # ignored_fields: [children_count, ancestors_count, descendants_count, position]
46
+ # * specify fields you don't want generated for your template
@@ -0,0 +1,5 @@
1
+ /* SWFObject v2.0 <http://code.google.com/p/swfobject/>
2
+ Copyright (c) 2007 Geoff Stearns, Michael Williams, and Bobby van der Sluis
3
+ This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
4
+ */
5
+ var swfobject=function(){var Z="undefined",P="object",B="Shockwave Flash",h="ShockwaveFlash.ShockwaveFlash",W="application/x-shockwave-flash",K="SWFObjectExprInst",G=window,g=document,N=navigator,f=[],H=[],Q=null,L=null,T=null,S=false,C=false;var a=function(){var l=typeof g.getElementById!=Z&&typeof g.getElementsByTagName!=Z&&typeof g.createElement!=Z&&typeof g.appendChild!=Z&&typeof g.replaceChild!=Z&&typeof g.removeChild!=Z&&typeof g.cloneNode!=Z,t=[0,0,0],n=null;if(typeof N.plugins!=Z&&typeof N.plugins[B]==P){n=N.plugins[B].description;if(n){n=n.replace(/^.*\s+(\S+\s+\S+$)/,"$1");t[0]=parseInt(n.replace(/^(.*)\..*$/,"$1"),10);t[1]=parseInt(n.replace(/^.*\.(.*)\s.*$/,"$1"),10);t[2]=/r/.test(n)?parseInt(n.replace(/^.*r(.*)$/,"$1"),10):0}}else{if(typeof G.ActiveXObject!=Z){var o=null,s=false;try{o=new ActiveXObject(h+".7")}catch(k){try{o=new ActiveXObject(h+".6");t=[6,0,21];o.AllowScriptAccess="always"}catch(k){if(t[0]==6){s=true}}if(!s){try{o=new ActiveXObject(h)}catch(k){}}}if(!s&&o){try{n=o.GetVariable("$version");if(n){n=n.split(" ")[1].split(",");t=[parseInt(n[0],10),parseInt(n[1],10),parseInt(n[2],10)]}}catch(k){}}}}var v=N.userAgent.toLowerCase(),j=N.platform.toLowerCase(),r=/webkit/.test(v)?parseFloat(v.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,i=false,q=j?/win/.test(j):/win/.test(v),m=j?/mac/.test(j):/mac/.test(v);/*@cc_on i=true;@if(@_win32)q=true;@elif(@_mac)m=true;@end@*/return{w3cdom:l,pv:t,webkit:r,ie:i,win:q,mac:m}}();var e=function(){if(!a.w3cdom){return }J(I);if(a.ie&&a.win){try{g.write("<script id=__ie_ondomload defer=true src=//:><\/script>");var i=c("__ie_ondomload");if(i){i.onreadystatechange=function(){if(this.readyState=="complete"){this.parentNode.removeChild(this);V()}}}}catch(j){}}if(a.webkit&&typeof g.readyState!=Z){Q=setInterval(function(){if(/loaded|complete/.test(g.readyState)){V()}},10)}if(typeof g.addEventListener!=Z){g.addEventListener("DOMContentLoaded",V,null)}M(V)}();function V(){if(S){return }if(a.ie&&a.win){var m=Y("span");try{var l=g.getElementsByTagName("body")[0].appendChild(m);l.parentNode.removeChild(l)}catch(n){return }}S=true;if(Q){clearInterval(Q);Q=null}var j=f.length;for(var k=0;k<j;k++){f[k]()}}function J(i){if(S){i()}else{f[f.length]=i}}function M(j){if(typeof G.addEventListener!=Z){G.addEventListener("load",j,false)}else{if(typeof g.addEventListener!=Z){g.addEventListener("load",j,false)}else{if(typeof G.attachEvent!=Z){G.attachEvent("onload",j)}else{if(typeof G.onload=="function"){var i=G.onload;G.onload=function(){i();j()}}else{G.onload=j}}}}}function I(){var l=H.length;for(var j=0;j<l;j++){var m=H[j].id;if(a.pv[0]>0){var k=c(m);if(k){H[j].width=k.getAttribute("width")?k.getAttribute("width"):"0";H[j].height=k.getAttribute("height")?k.getAttribute("height"):"0";if(O(H[j].swfVersion)){if(a.webkit&&a.webkit<312){U(k)}X(m,true)}else{if(H[j].expressInstall&&!C&&O("6.0.65")&&(a.win||a.mac)){D(H[j])}else{d(k)}}}}else{X(m,true)}}}function U(m){var k=m.getElementsByTagName(P)[0];if(k){var p=Y("embed"),r=k.attributes;if(r){var o=r.length;for(var n=0;n<o;n++){if(r[n].nodeName.toLowerCase()=="data"){p.setAttribute("src",r[n].nodeValue)}else{p.setAttribute(r[n].nodeName,r[n].nodeValue)}}}var q=k.childNodes;if(q){var s=q.length;for(var l=0;l<s;l++){if(q[l].nodeType==1&&q[l].nodeName.toLowerCase()=="param"){p.setAttribute(q[l].getAttribute("name"),q[l].getAttribute("value"))}}}m.parentNode.replaceChild(p,m)}}function F(i){if(a.ie&&a.win&&O("8.0.0")){G.attachEvent("onunload",function(){var k=c(i);if(k){for(var j in k){if(typeof k[j]=="function"){k[j]=function(){}}}k.parentNode.removeChild(k)}})}}function D(j){C=true;var o=c(j.id);if(o){if(j.altContentId){var l=c(j.altContentId);if(l){L=l;T=j.altContentId}}else{L=b(o)}if(!(/%$/.test(j.width))&&parseInt(j.width,10)<310){j.width="310"}if(!(/%$/.test(j.height))&&parseInt(j.height,10)<137){j.height="137"}g.title=g.title.slice(0,47)+" - Flash Player Installation";var n=a.ie&&a.win?"ActiveX":"PlugIn",k=g.title,m="MMredirectURL="+G.location+"&MMplayerType="+n+"&MMdoctitle="+k,p=j.id;if(a.ie&&a.win&&o.readyState!=4){var i=Y("div");p+="SWFObjectNew";i.setAttribute("id",p);o.parentNode.insertBefore(i,o);o.style.display="none";G.attachEvent("onload",function(){o.parentNode.removeChild(o)})}R({data:j.expressInstall,id:K,width:j.width,height:j.height},{flashvars:m},p)}}function d(j){if(a.ie&&a.win&&j.readyState!=4){var i=Y("div");j.parentNode.insertBefore(i,j);i.parentNode.replaceChild(b(j),i);j.style.display="none";G.attachEvent("onload",function(){j.parentNode.removeChild(j)})}else{j.parentNode.replaceChild(b(j),j)}}function b(n){var m=Y("div");if(a.win&&a.ie){m.innerHTML=n.innerHTML}else{var k=n.getElementsByTagName(P)[0];if(k){var o=k.childNodes;if(o){var j=o.length;for(var l=0;l<j;l++){if(!(o[l].nodeType==1&&o[l].nodeName.toLowerCase()=="param")&&!(o[l].nodeType==8)){m.appendChild(o[l].cloneNode(true))}}}}}return m}function R(AE,AC,q){var p,t=c(q);if(typeof AE.id==Z){AE.id=q}if(a.ie&&a.win){var AD="";for(var z in AE){if(AE[z]!=Object.prototype[z]){if(z=="data"){AC.movie=AE[z]}else{if(z.toLowerCase()=="styleclass"){AD+=' class="'+AE[z]+'"'}else{if(z!="classid"){AD+=" "+z+'="'+AE[z]+'"'}}}}}var AB="";for(var y in AC){if(AC[y]!=Object.prototype[y]){AB+='<param name="'+y+'" value="'+AC[y]+'" />'}}t.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+AD+">"+AB+"</object>";F(AE.id);p=c(AE.id)}else{if(a.webkit&&a.webkit<312){var AA=Y("embed");AA.setAttribute("type",W);for(var x in AE){if(AE[x]!=Object.prototype[x]){if(x=="data"){AA.setAttribute("src",AE[x])}else{if(x.toLowerCase()=="styleclass"){AA.setAttribute("class",AE[x])}else{if(x!="classid"){AA.setAttribute(x,AE[x])}}}}}for(var w in AC){if(AC[w]!=Object.prototype[w]){if(w!="movie"){AA.setAttribute(w,AC[w])}}}t.parentNode.replaceChild(AA,t);p=AA}else{var s=Y(P);s.setAttribute("type",W);for(var v in AE){if(AE[v]!=Object.prototype[v]){if(v.toLowerCase()=="styleclass"){s.setAttribute("class",AE[v])}else{if(v!="classid"){s.setAttribute(v,AE[v])}}}}for(var u in AC){if(AC[u]!=Object.prototype[u]&&u!="movie"){E(s,u,AC[u])}}t.parentNode.replaceChild(s,t);p=s}}return p}function E(k,i,j){var l=Y("param");l.setAttribute("name",i);l.setAttribute("value",j);k.appendChild(l)}function c(i){return g.getElementById(i)}function Y(i){return g.createElement(i)}function O(k){var j=a.pv,i=k.split(".");i[0]=parseInt(i[0],10);i[1]=parseInt(i[1],10);i[2]=parseInt(i[2],10);return(j[0]>i[0]||(j[0]==i[0]&&j[1]>i[1])||(j[0]==i[0]&&j[1]==i[1]&&j[2]>=i[2]))?true:false}function A(m,j){if(a.ie&&a.mac){return }var l=g.getElementsByTagName("head")[0],k=Y("style");k.setAttribute("type","text/css");k.setAttribute("media","screen");if(!(a.ie&&a.win)&&typeof g.createTextNode!=Z){k.appendChild(g.createTextNode(m+" {"+j+"}"))}l.appendChild(k);if(a.ie&&a.win&&typeof g.styleSheets!=Z&&g.styleSheets.length>0){var i=g.styleSheets[g.styleSheets.length-1];if(typeof i.addRule==P){i.addRule(m,j)}}}function X(k,i){var j=i?"visible":"hidden";if(S){c(k).style.visibility=j}else{A("#"+k,"visibility:"+j)}}return{registerObject:function(l,i,k){if(!a.w3cdom||!l||!i){return }var j={};j.id=l;j.swfVersion=i;j.expressInstall=k?k:false;H[H.length]=j;X(l,false)},getObjectById:function(l){var i=null;if(a.w3cdom&&S){var j=c(l);if(j){var k=j.getElementsByTagName(P)[0];if(!k||(k&&typeof j.SetVariable!=Z)){i=j}else{if(typeof k.SetVariable!=Z){i=k}}}}return i},embedSWF:function(n,u,r,t,j,m,k,p,s){if(!a.w3cdom||!n||!u||!r||!t||!j){return }r+="";t+="";if(O(j)){X(u,false);var q=(typeof s==P)?s:{};q.data=n;q.width=r;q.height=t;var o=(typeof p==P)?p:{};if(typeof k==P){for(var l in k){if(k[l]!=Object.prototype[l]){if(typeof o.flashvars!=Z){o.flashvars+="&"+l+"="+k[l]}else{o.flashvars=l+"="+k[l]}}}}J(function(){R(q,o,u);if(q.id==u){X(u,true)}})}else{if(m&&!C&&O("6.0.65")&&(a.win||a.mac)){X(u,false);J(function(){var i={};i.id=i.altContentId=u;i.width=r;i.height=t;i.expressInstall=m;D(i)})}}},getFlashPlayerVersion:function(){return{major:a.pv[0],minor:a.pv[1],release:a.pv[2]}},hasFlashPlayerVersion:O,createSWF:function(k,j,i){if(a.w3cdom&&S){return R(k,j,i)}else{return undefined}},createCSS:function(j,i){if(a.w3cdom){A(j,i)}},addDomLoadEvent:J,addLoadEvent:M,getQueryParamValue:function(m){var l=g.location.search||g.location.hash;if(m==null){return l}if(l){var k=l.substring(1).split("&");for(var j=0;j<k.length;j++){if(k[j].substring(0,k[j].indexOf("="))==m){return k[j].substring((k[j].indexOf("=")+1))}}}return""},expressInstallCallback:function(){if(C&&L){var i=c(K);if(i){i.parentNode.replaceChild(L,i);if(T){X(T,true);if(a.ie&&a.win){L.style.display="block"}}L=null;T=null;C=false}}}}}();
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Generates the primary RestfulX project directory structure and
4
+ # sets up Flex Builder and TextMate specific descriptor files
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
+ # `rx-gen pomodo` # generates project structure and a
12
+ # # default Flex app configuration.
13
+ # `rx-gen -a pomodo` # as above but generates an AIR app
14
+ # # and configuration
15
+ #
16
+ # Next Steps:
17
+ # In your new RestfulX project folder run `ruby script/generate` for
18
+ # a list of available generators.
19
+
20
+ require 'rubygems'
21
+ require 'rubigen'
22
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'restfulx')
23
+
24
+ if %w(-v --version).include? ARGV.first
25
+ puts "#{File.basename($0)} #{RestfulX::FRAMEWORK_VERSION}"
26
+ exit(0)
27
+ end
28
+
29
+ require 'rubigen/scripts/generate'
30
+ RubiGen::Base.use_application_sources!
31
+ RubiGen::Scripts::Generate.new.run(ARGV, :generator => 'rx_app')
@@ -0,0 +1,90 @@
1
+ # Sets up all the relevant configuration options and brings together
2
+ # patches for Rails, Merb, ActiveRecord and Data Mapper.
3
+ #
4
+ # Loads RestfulX specific rake tasks if appropriate.
5
+ module RestfulX
6
+
7
+ # :stopdoc:
8
+ FRAMEWORK_VERSION = '1.2.3'
9
+ LIB_DIR = File.join(File.dirname(__FILE__), 'restfulx/')
10
+ # :startdoc:
11
+
12
+ # Utility method used to require all files ending in .rb that lie in the
13
+ # directory below this file that has the same name as the filename passed
14
+ # in. Optionally, a specific _directory_ name can be passed in such that
15
+ # the _filename_ does not have to be equivalent to the directory.
16
+ #
17
+ def self.require_all_libs_relative_to( fname, dir = nil )
18
+ dir ||= ::File.basename(fname, '.*')
19
+ search_me = ::File.expand_path(
20
+ ::File.join(::File.dirname(fname), dir, '*', '*.rb'))
21
+
22
+ Dir.glob(search_me).sort.each {|rb| require rb}
23
+ end
24
+ end
25
+
26
+ require RestfulX::LIB_DIR + 'configuration'
27
+
28
+ # make sure we're running inside Merb
29
+ if defined?(Merb::Plugins)
30
+ Merb::Plugins.add_rakefiles RestfulX::LIB_DIR + 'tasks'
31
+
32
+ Merb::BootLoader.before_app_loads do
33
+
34
+ if defined?(ActiveRecord::Base)
35
+ Merb.add_mime_type(:fxml, :to_fxml, %w[application/xml text/xml application/x-xml], :charset => "utf-8")
36
+ ['active_foo', 'active_record_default_methods'].each { |lib| require RestfulX::LIB_DIR + lib }
37
+ Merb::Plugins.add_rakefiles RestfulX::LIB_DIR + 'active_record_tasks'
38
+ else
39
+ Merb.add_mime_type(:fxml, :to_xml, %w[application/xml text/xml application/x-xml], :charset => "utf-8")
40
+ if defined?(Merb::Orms::DataMapper)
41
+ require RestfulX::LIB_DIR + 'datamapper_foo'
42
+ end
43
+ end
44
+ end
45
+ elsif defined?(ActionController::Base)
46
+ # if we are not running in Merb, try to hook up Rails
47
+ Mime::Type.register_alias "application/xml", :fxml
48
+
49
+ ['active_foo', 'rails/swf_helper', 'rails/schema_to_yaml'].each { |lib| require RestfulX::LIB_DIR + lib }
50
+
51
+ ActionView::Base.send :include, SWFHelper unless ActionView::Base.included_modules.include?(SWFHelper)
52
+ ActiveRecord::Migration.send :include, SchemaToYaml
53
+
54
+ # We mess with default +render+ implementation a bit to add support for expressions
55
+ # such as format.fxml { render :fxml => @foo }
56
+ module ActionController
57
+ # Override render to add support for render :fxml
58
+ class Base
59
+ alias_method :old_render, :render unless method_defined?(:old_render)
60
+
61
+ # so that we can have handling for :fxml option and write code like
62
+ # format.fxml { render :fxml => @projects }
63
+ def render(options = nil, extra_options = {}, &block)
64
+ if options.is_a?(Hash) && options[:fxml]
65
+ xml = options[:fxml]
66
+ response.content_type ||= Mime::XML
67
+ render_for_text(xml.respond_to?(:to_fxml) ? xml.to_fxml : xml, options[:status])
68
+ else
69
+ old_render(options, extra_options, &block)
70
+ end
71
+ end
72
+ end
73
+ end
74
+
75
+ module ActiveRecord
76
+ # ActiveRecord named scopes are computed *before* restfulx gem gets loaded
77
+ # this patch addresses that and makes sure +to_fxml+ calls are properly
78
+ # delegated
79
+ module NamedScope
80
+ # make sure we properly delegate +to_fxml+ calls to the proxy
81
+ class Scope
82
+ delegate :to_fxml, :to => :proxy_found
83
+ end
84
+ end
85
+ end
86
+ elsif defined?(DataMapper)
87
+ require RestfulX::LIB_DIR + 'datamapper_foo'
88
+ elsif defined?(ActiveRecord::Base)
89
+ require RestfulX::LIB_DIR + 'active_foo'
90
+ end
@@ -0,0 +1,181 @@
1
+ # There's a number of things that ActiveRecord/ActiveSupport and the rest of the family get
2
+ # ~wrong~ from the point of view of Flex clients.
3
+ #
4
+ # Some of these things are:
5
+ # * XML format (Flex *really* doesn't like dashes in XML messages)
6
+ # * Errors (we need to be more specific and communicate what went wrong *where*)
7
+ #
8
+ # This is where we try to fix this stuff.
9
+ #
10
+ # Some of the things that are done can be called _monkey_ _patching_ while others can
11
+ # be called extensions. Caveat emptor.
12
+
13
+ # ActiveSupport specific patches. More specifically we add +to_fxml+ methods to Array and
14
+ # Hash conversion modules
15
+ module ActiveSupport
16
+ # refer to: http://api.rubyonrails.org/ for more details
17
+ module CoreExtensions
18
+ # Add Flex friendly +to_fxml+ to Hash conversions
19
+ module Hash
20
+ # refer to: http://api.rubyonrails.org/ for more details
21
+ module Conversions
22
+
23
+ # Flex friendly XML format, no dashes, etc
24
+ def to_fxml(options = {})
25
+ options.merge!(:dasherize => false)
26
+ options[:indent] ||= 2
27
+ options.reverse_merge!({ :builder => Builder::XmlMarkup.new(:indent => options[:indent]),
28
+ :root => "hash" })
29
+ options[:builder].instruct! unless options.delete(:skip_instruct)
30
+ dasherize = !options.has_key?(:dasherize) || options[:dasherize]
31
+ root = dasherize ? options[:root].to_s.dasherize : options[:root].to_s
32
+
33
+ options[:builder].__send__(:method_missing, root) do
34
+ each do |key, value|
35
+ case value
36
+ when ::Hash
37
+ value.to_fxml(options.merge({ :root => key, :skip_instruct => true }))
38
+ when ::Array
39
+ value.to_fxml(options.merge({ :root => key, :children => key.to_s.singularize, :skip_instruct => true}))
40
+ when ::Method, ::Proc
41
+ # If the Method or Proc takes two arguments, then
42
+ # pass the suggested child element name. This is
43
+ # used if the Method or Proc will be operating over
44
+ # multiple records and needs to create an containing
45
+ # element that will contain the objects being
46
+ # serialized.
47
+ if 1 == value.arity
48
+ value.call(options.merge({ :root => key, :skip_instruct => true }))
49
+ else
50
+ value.call(options.merge({ :root => key, :skip_instruct => true }), key.to_s.singularize)
51
+ end
52
+ else
53
+ if value.respond_to?(:to_fxml)
54
+ value.to_fxml(options.merge({ :root => key, :skip_instruct => true }))
55
+ else
56
+ type_name = XML_TYPE_NAMES[value.class.name]
57
+
58
+ key = dasherize ? key.to_s.dasherize : key.to_s
59
+
60
+ attributes = options[:skip_types] || value.nil? || type_name.nil? ? { } : { :type => type_name }
61
+ if value.nil?
62
+ attributes[:nil] = true
63
+ end
64
+
65
+ options[:builder].tag!(key,
66
+ XML_FORMATTING[type_name] ? XML_FORMATTING[type_name].call(value) : value,
67
+ attributes
68
+ )
69
+ end
70
+ end
71
+ end
72
+
73
+ yield options[:builder] if block_given?
74
+ end
75
+ end
76
+ end
77
+ end
78
+ # Add Flex friendly to_fxml to array conversions
79
+ module Array
80
+ # refer to: http://api.rubyonrails.org/ for more details
81
+ module Conversions
82
+ # Flex friendly XML format (no dashes, etc)
83
+ def to_fxml(options = {})
84
+ raise "Not all elements respond to to_fxml" unless all? { |e| e.respond_to? :to_fxml }
85
+
86
+ options[:root] ||= all? { |e| e.is_a?(first.class) && first.class.to_s != "Hash" } ? first.class.to_s.underscore.pluralize : "records"
87
+ options[:children] ||= options[:root].singularize
88
+ options[:indent] ||= 2
89
+ options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent])
90
+ options.merge!(:dasherize => false)
91
+
92
+ options[:attributes] ||= {}
93
+ options[:attributes].merge!(:type => "array")
94
+
95
+ root = options.delete(:root).to_s
96
+ children = options.delete(:children)
97
+
98
+ if !options.has_key?(:dasherize) || options[:dasherize]
99
+ root = root.dasherize
100
+ end
101
+
102
+ options[:builder].instruct! unless options.delete(:skip_instruct)
103
+
104
+ opts = options.merge({ :root => children })
105
+
106
+ xml = options[:builder]
107
+ if empty?
108
+ xml.tag!(root, options[:attributes])
109
+ else
110
+ xml.tag!(root, options[:attributes]) {
111
+ yield xml if block_given?
112
+ each { |e| e.to_fxml(opts.merge!({ :skip_instruct => true })) }
113
+ }
114
+ end
115
+ end
116
+ end
117
+ end
118
+ end
119
+ end
120
+
121
+ # Flex friendly ActiveRecord patches. More specifically XML serialization improvements.
122
+ # These won't override whatever you may normally do with XML, hence there's Flex specific
123
+ # name for this stuff +to_fxml+.
124
+ module ActiveRecord
125
+ # refer to: http://api.rubyonrails.org/ for more details
126
+ module Serialization
127
+ # Enforces Flex friendly options on XML and delegates processing to standard +to_xml+
128
+ def to_fxml(options = {}, &block)
129
+ options.merge!(:dasherize => false)
130
+ default_except = [:crypted_password, :salt, :remember_token, :remember_token_expires_at]
131
+ options[:except] = (options[:except] ? options[:except] + default_except : default_except)
132
+ to_xml(options, &block)
133
+ end
134
+ end
135
+
136
+ # Change the xml serializer so that '?'s are stripped from attribute names.
137
+ # This makes it possible to serialize methods that end in a question mark, like 'valid?' or 'is_true?'
138
+ class XmlSerializer
139
+ # Strips '?' from serialized method names
140
+ def add_tag(attribute)
141
+ builder.tag!(
142
+ dasherize? ? attribute.display_name.dasherize : attribute.display_name,
143
+ attribute.value.to_s,
144
+ attribute.decorations(!options[:skip_types])
145
+ )
146
+ end
147
+ # Strips '?' from serialized method names
148
+ class Attribute
149
+ # Strips '?' from serialized method names
150
+ def display_name
151
+ @name.gsub('?','')
152
+ end
153
+ end
154
+ end
155
+
156
+ # Add more extensive reporting on errors including field name along with a message
157
+ # when errors are serialized to XML
158
+ class Errors
159
+ # Flex friendly errors
160
+ def to_fxml(options={})
161
+ options[:root] ||= "errors"
162
+ options[:indent] ||= 2
163
+ options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent])
164
+ options[:builder].instruct! unless options.delete(:skip_instruct)
165
+ options[:builder].errors do |e|
166
+ # The @errors instance variable is a Hash inside the Errors class
167
+ @errors.each_key do |attr|
168
+ @errors[attr].each do |msg|
169
+ next if msg.nil?
170
+ if attr == "base"
171
+ options[:builder].error("message" => msg)
172
+ else
173
+ fullmsg = @base.class.human_attribute_name(attr) + ' ' + msg
174
+ options[:builder].error("field" => attr.camelcase(:lower), "message" => fullmsg)
175
+ end
176
+ end
177
+ end
178
+ end
179
+ end
180
+ end
181
+ end