emergent-core 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (349) hide show
  1. data/.bnsignore +16 -0
  2. data/History.txt +4 -0
  3. data/Manifest.txt +348 -0
  4. data/README.rdoc +47 -0
  5. data/Rakefile +39 -0
  6. data/app_generators/emergent_core/USAGE +5 -0
  7. data/app_generators/emergent_core/emergent_core_generator.rb +73 -0
  8. data/app_generators/emergent_core/templates/core/actionscript.properties +16 -0
  9. data/app_generators/emergent_core/templates/core/actionscriptair.properties +16 -0
  10. data/app_generators/emergent_core/templates/core/app.yaml.erb +12 -0
  11. data/app_generators/emergent_core/templates/core/default_tasks.rake +51 -0
  12. data/app_generators/emergent_core/templates/core/empty.txt +0 -0
  13. data/app_generators/emergent_core/templates/core/expressInstall.swf +0 -0
  14. data/app_generators/emergent_core/templates/core/flex.properties +2 -0
  15. data/app_generators/emergent_core/templates/core/generate.rb +17 -0
  16. data/app_generators/emergent_core/templates/core/html-template/AC_OETags.js +276 -0
  17. data/app_generators/emergent_core/templates/core/html-template/history/history.css +6 -0
  18. data/app_generators/emergent_core/templates/core/html-template/history/history.js +645 -0
  19. data/app_generators/emergent_core/templates/core/html-template/history/historyFrame.html +29 -0
  20. data/app_generators/emergent_core/templates/core/html-template/index.template.html +121 -0
  21. data/app_generators/emergent_core/templates/core/html-template/playerProductInstall.swf +0 -0
  22. data/app_generators/emergent_core/templates/core/index.html.erb +18 -0
  23. data/app_generators/emergent_core/templates/core/index.yaml +11 -0
  24. data/app_generators/emergent_core/templates/core/mainair-app.xml +134 -0
  25. data/app_generators/emergent_core/templates/core/mainapp-config.xml +21 -0
  26. data/app_generators/emergent_core/templates/core/mainapp.mxml +106 -0
  27. data/app_generators/emergent_core/templates/core/project-textmate.erb +52 -0
  28. data/app_generators/emergent_core/templates/core/project.properties +18 -0
  29. data/app_generators/emergent_core/templates/core/projectair.properties +24 -0
  30. data/app_generators/emergent_core/templates/core/swfobject.js +5 -0
  31. data/bin/emergent +17 -0
  32. data/lib/emergent_core.rb +49 -0
  33. data/lib/restfulx/active_foo.rb +194 -0
  34. data/lib/restfulx/active_record_tasks.rb +81 -0
  35. data/lib/restfulx/configuration.rb +76 -0
  36. data/lib/restfulx/datamapper_foo.rb +31 -0
  37. data/lib/restfulx/rails/recipes.rb +60 -0
  38. data/lib/restfulx/rails/swf_helper.rb +60 -0
  39. data/lib/restfulx/tasks.rb +85 -0
  40. data/lib/restfulx.rb +117 -0
  41. data/rails_generators/emergent_cms/USAGE +5 -0
  42. data/rails_generators/emergent_cms/emergent_cms_generator.rb +21 -0
  43. data/rails_generators/emergent_cms/templates/PagesEditModel.as +114 -0
  44. data/rails_generators/emergent_cms/templates/PagesEditView.mxml +102 -0
  45. data/rails_generators/emergent_config/USAGE +5 -0
  46. data/rails_generators/emergent_config/emergent_config_generator.rb +330 -0
  47. data/rails_generators/emergent_config/templates/app/controllers/accounts_controller.rb +104 -0
  48. data/rails_generators/emergent_config/templates/app/controllers/addresses_controller.rb +97 -0
  49. data/rails_generators/emergent_config/templates/app/controllers/application.rb +26 -0
  50. data/rails_generators/emergent_config/templates/app/controllers/assets_controller.rb +1 -0
  51. data/rails_generators/emergent_config/templates/app/controllers/content_assignments_controller.rb +97 -0
  52. data/rails_generators/emergent_config/templates/app/controllers/contents_controller.rb +114 -0
  53. data/rails_generators/emergent_config/templates/app/controllers/sessions_controller.rb +72 -0
  54. data/rails_generators/emergent_config/templates/app/controllers/sites_controller.rb +1 -0
  55. data/rails_generators/emergent_config/templates/app/controllers/users_controller.rb +97 -0
  56. data/rails_generators/emergent_config/templates/app/flex/application/controllers/command/ICommand.as +16 -0
  57. data/rails_generators/emergent_config/templates/app/flex/application/controllers/command/Undoable.as +46 -0
  58. data/rails_generators/emergent_config/templates/app/flex/application/controllers/command/UpdateDocumentCommand.as +73 -0
  59. data/rails_generators/emergent_config/templates/app/flex/application/controllers/event/DocumentEvent.as +46 -0
  60. data/rails_generators/emergent_config/templates/app/flex/application/controllers/event/NavigationEvent.as +31 -0
  61. data/rails_generators/emergent_config/templates/app/flex/application/controllers/event/ResourceEvent.as +27 -0
  62. data/rails_generators/emergent_config/templates/app/flex/application/controllers/event/UndoEvent.as +36 -0
  63. data/rails_generators/emergent_config/templates/app/flex/application/controllers/manager/AboutUsManager.as +15 -0
  64. data/rails_generators/emergent_config/templates/app/flex/application/controllers/manager/AccountManager.as +31 -0
  65. data/rails_generators/emergent_config/templates/app/flex/application/controllers/manager/AuthenticationManager.as +76 -0
  66. data/rails_generators/emergent_config/templates/app/flex/application/controllers/manager/ContentManager.as +92 -0
  67. data/rails_generators/emergent_config/templates/app/flex/application/controllers/manager/DocumentManager.as +131 -0
  68. data/rails_generators/emergent_config/templates/app/flex/application/controllers/manager/DocumentsManager.as +156 -0
  69. data/rails_generators/emergent_config/templates/app/flex/application/controllers/manager/HomeManager.as +18 -0
  70. data/rails_generators/emergent_config/templates/app/flex/application/controllers/manager/MainManager.as +23 -0
  71. data/rails_generators/emergent_config/templates/app/flex/application/controllers/manager/PagesManager.as +71 -0
  72. data/rails_generators/emergent_config/templates/app/flex/application/controllers/manager/ResourceManager.as +195 -0
  73. data/rails_generators/emergent_config/templates/app/flex/application/controllers/manager/SiteManager.as +25 -0
  74. data/rails_generators/emergent_config/templates/app/flex/application/controllers/manager/UndoManager.as +143 -0
  75. data/rails_generators/emergent_config/templates/app/flex/application/controllers/map/DocumentMap.mxml +123 -0
  76. data/rails_generators/emergent_config/templates/app/flex/application/controllers/map/DocumentsMap.mxml +134 -0
  77. data/rails_generators/emergent_config/templates/app/flex/application/controllers/map/ManagerPresentationModelMap.mxml +59 -0
  78. data/rails_generators/emergent_config/templates/app/flex/application/controllers/map/ObjectMap.mxml +75 -0
  79. data/rails_generators/emergent_config/templates/app/flex/application/controllers/map/PresentationModelViewMap.mxml +81 -0
  80. data/rails_generators/emergent_config/templates/app/flex/application/controllers/map/PresenterViewMap.mxml +67 -0
  81. data/rails_generators/emergent_config/templates/app/flex/application/models/constant/DocumentType.as +52 -0
  82. data/rails_generators/emergent_config/templates/app/flex/application/models/constant/Resource.as +25 -0
  83. data/rails_generators/emergent_config/templates/app/flex/application/models/constant/ResourceAction.as +28 -0
  84. data/rails_generators/emergent_config/templates/app/flex/application/models/constant/ResourceResult.as +8 -0
  85. data/rails_generators/emergent_config/templates/app/flex/application/models/domain/Account.as +32 -0
  86. data/rails_generators/emergent_config/templates/app/flex/application/models/domain/Address.as +26 -0
  87. data/rails_generators/emergent_config/templates/app/flex/application/models/domain/Asset.as +25 -0
  88. data/rails_generators/emergent_config/templates/app/flex/application/models/domain/AssetAssignment.as +25 -0
  89. data/rails_generators/emergent_config/templates/app/flex/application/models/domain/Content.as +46 -0
  90. data/rails_generators/emergent_config/templates/app/flex/application/models/domain/ContentAssignment.as +33 -0
  91. data/rails_generators/emergent_config/templates/app/flex/application/models/domain/Document.as +131 -0
  92. data/rails_generators/emergent_config/templates/app/flex/application/models/domain/PlainDocument.as +19 -0
  93. data/rails_generators/emergent_config/templates/app/flex/application/models/domain/RichDocument.as +19 -0
  94. data/rails_generators/emergent_config/templates/app/flex/application/models/domain/Session.as +13 -0
  95. data/rails_generators/emergent_config/templates/app/flex/application/models/domain/Snapshot.as +21 -0
  96. data/rails_generators/emergent_config/templates/app/flex/application/models/domain/User.as +28 -0
  97. data/rails_generators/emergent_config/templates/app/flex/application/models/factory/DocumentFactory.as +61 -0
  98. data/rails_generators/emergent_config/templates/app/flex/application/models/factory/DocumentViewFactory.as +59 -0
  99. data/rails_generators/emergent_config/templates/app/flex/application/models/factory/ResourceFactory.as +28 -0
  100. data/rails_generators/emergent_config/templates/app/flex/application/models/presentation/AboutUsModel.as +22 -0
  101. data/rails_generators/emergent_config/templates/app/flex/application/models/presentation/AccountModel.as +68 -0
  102. data/rails_generators/emergent_config/templates/app/flex/application/models/presentation/AuthenticationModel.as +44 -0
  103. data/rails_generators/emergent_config/templates/app/flex/application/models/presentation/ContactUsModel.as +45 -0
  104. data/rails_generators/emergent_config/templates/app/flex/application/models/presentation/ContentModel.as +70 -0
  105. data/rails_generators/emergent_config/templates/app/flex/application/models/presentation/DocumentModel.as +235 -0
  106. data/rails_generators/emergent_config/templates/app/flex/application/models/presentation/DocumentsModel.as +169 -0
  107. data/rails_generators/emergent_config/templates/app/flex/application/models/presentation/HomeModel.as +23 -0
  108. data/rails_generators/emergent_config/templates/app/flex/application/models/presentation/MainModel.as +35 -0
  109. data/rails_generators/emergent_config/templates/app/flex/application/models/presentation/PagesModel.as +44 -0
  110. data/rails_generators/emergent_config/templates/app/flex/application/models/presentation/ProfileModel.as +99 -0
  111. data/rails_generators/emergent_config/templates/app/flex/application/models/presentation/ResourceModel.as +100 -0
  112. data/rails_generators/emergent_config/templates/app/flex/application/views/about_us/about_us.mxml +105 -0
  113. data/rails_generators/emergent_config/templates/app/flex/application/views/account/account.mxml +97 -0
  114. data/rails_generators/emergent_config/templates/app/flex/application/views/contact_us/contact_us.mxml +65 -0
  115. data/rails_generators/emergent_config/templates/app/flex/application/views/document/document.mxml +71 -0
  116. data/rails_generators/emergent_config/templates/app/flex/application/views/document/documents.mxml +201 -0
  117. data/rails_generators/emergent_config/templates/app/flex/application/views/document/plain_document.mxml +9 -0
  118. data/rails_generators/emergent_config/templates/app/flex/application/views/document/rich_document.mxml +12 -0
  119. data/rails_generators/emergent_config/templates/app/flex/application/views/gallery/gallery.mxml +37 -0
  120. data/rails_generators/emergent_config/templates/app/flex/application/views/home/home.mxml +58 -0
  121. data/rails_generators/emergent_config/templates/app/flex/application/views/home/home_presenter.as +81 -0
  122. data/rails_generators/emergent_config/templates/app/flex/application/views/home/home_troparchy.mxml +71 -0
  123. data/rails_generators/emergent_config/templates/app/flex/application/views/login/login.mxml +50 -0
  124. data/rails_generators/emergent_config/templates/app/flex/application/views/main/main.mxml +131 -0
  125. data/rails_generators/emergent_config/templates/app/flex/application/views/main/main_presenter.as +166 -0
  126. data/rails_generators/emergent_config/templates/app/flex/application/views/main/main_troparchy.mxml +74 -0
  127. data/rails_generators/emergent_config/templates/app/flex/application/views/navigation/navigation_bar_bottom_model.as +13 -0
  128. data/rails_generators/emergent_config/templates/app/flex/application/views/navigation/navigation_bar_bottom_presenter.as +10 -0
  129. data/rails_generators/emergent_config/templates/app/flex/application/views/navigation/navigation_bar_bottom_view.mxml +48 -0
  130. data/rails_generators/emergent_config/templates/app/flex/application/views/navigation/navigation_bar_left_model.as +13 -0
  131. data/rails_generators/emergent_config/templates/app/flex/application/views/navigation/navigation_bar_left_presenter.as +10 -0
  132. data/rails_generators/emergent_config/templates/app/flex/application/views/navigation/navigation_bar_left_view.mxml +43 -0
  133. data/rails_generators/emergent_config/templates/app/flex/application/views/navigation/navigation_bar_right_model.as +13 -0
  134. data/rails_generators/emergent_config/templates/app/flex/application/views/navigation/navigation_bar_right_presenter.as +10 -0
  135. data/rails_generators/emergent_config/templates/app/flex/application/views/navigation/navigation_bar_right_view.mxml +47 -0
  136. data/rails_generators/emergent_config/templates/app/flex/application/views/navigation/navigation_bar_top_model.as +13 -0
  137. data/rails_generators/emergent_config/templates/app/flex/application/views/navigation/navigation_bar_top_presenter.as +10 -0
  138. data/rails_generators/emergent_config/templates/app/flex/application/views/navigation/navigation_bar_top_view.mxml +49 -0
  139. data/rails_generators/emergent_config/templates/app/flex/application/views/navigation/navigation_bars_presenter.as +63 -0
  140. data/rails_generators/emergent_config/templates/app/flex/application/views/navigation/navigation_bars_troparchy.mxml +63 -0
  141. data/rails_generators/emergent_config/templates/app/flex/application/views/navigation/navigation_bars_view.mxml +59 -0
  142. data/rails_generators/emergent_config/templates/app/flex/application/views/pages/pages.mxml +44 -0
  143. data/rails_generators/emergent_config/templates/app/flex/application/views/pages/pages_presenter.as +83 -0
  144. data/rails_generators/emergent_config/templates/app/flex/application/views/pages/pages_troparchy.mxml +62 -0
  145. data/rails_generators/emergent_config/templates/app/flex/application/views/profile/profile.mxml +73 -0
  146. data/rails_generators/emergent_config/templates/app/flex/assets/fonts/MyriadPro-Bold.otf +0 -0
  147. data/rails_generators/emergent_config/templates/app/flex/assets/fonts/MyriadPro-Regular.otf +0 -0
  148. data/rails_generators/emergent_config/templates/app/flex/assets/html/lorem.html +3 -0
  149. data/rails_generators/emergent_config/templates/app/flex/assets/images/alexgrey/Picture10.png +0 -0
  150. data/rails_generators/emergent_config/templates/app/flex/assets/images/alexgrey/Picture11.png +0 -0
  151. data/rails_generators/emergent_config/templates/app/flex/assets/images/alexgrey/Picture12.png +0 -0
  152. data/rails_generators/emergent_config/templates/app/flex/assets/images/alexgrey/Picture13.png +0 -0
  153. data/rails_generators/emergent_config/templates/app/flex/assets/images/alexgrey/Picture14.png +0 -0
  154. data/rails_generators/emergent_config/templates/app/flex/assets/images/alexgrey/Picture3.png +0 -0
  155. data/rails_generators/emergent_config/templates/app/flex/assets/images/alexgrey/Picture4.png +0 -0
  156. data/rails_generators/emergent_config/templates/app/flex/assets/images/alexgrey/Picture5.png +0 -0
  157. data/rails_generators/emergent_config/templates/app/flex/assets/images/alexgrey/Picture6.png +0 -0
  158. data/rails_generators/emergent_config/templates/app/flex/assets/images/alexgrey/Picture7.png +0 -0
  159. data/rails_generators/emergent_config/templates/app/flex/assets/images/alexgrey/Picture8.png +0 -0
  160. data/rails_generators/emergent_config/templates/app/flex/assets/images/alexgrey/Picture9.png +0 -0
  161. data/rails_generators/emergent_config/templates/app/flex/assets/images/hot_nebula_0.jpg +0 -0
  162. data/rails_generators/emergent_config/templates/app/flex/assets/images/hot_nebula_180.jpg +0 -0
  163. data/rails_generators/emergent_config/templates/app/flex/assets/images/hot_nebula_270.jpg +0 -0
  164. data/rails_generators/emergent_config/templates/app/flex/assets/images/hot_nebula_90.jpg +0 -0
  165. data/rails_generators/emergent_config/templates/app/flex/assets/images/hot_nebula_bottom.jpg +0 -0
  166. data/rails_generators/emergent_config/templates/app/flex/assets/images/hot_nebula_top.jpg +0 -0
  167. data/rails_generators/emergent_config/templates/app/flex/assets/styles/itunes7Bg.jpg +0 -0
  168. data/rails_generators/emergent_config/templates/app/flex/assets/styles/jukebox.css +764 -0
  169. data/rails_generators/emergent_config/templates/app/flex/assets/styles/jukeboxGfx.swf +0 -0
  170. data/rails_generators/emergent_config/templates/app/flex/assets/styles/obsidian.css +734 -0
  171. data/rails_generators/emergent_config/templates/app/flex/assets/styles/obsidianBg.jpg +0 -0
  172. data/rails_generators/emergent_config/templates/app/flex/assets/styles/obsidianGfx.swf +0 -0
  173. data/rails_generators/emergent_config/templates/app/flex/com/fourD/actions/LayoutAction.as +377 -0
  174. data/rails_generators/emergent_config/templates/app/flex/com/fourD/actions/SimpleLayoutAction.as +210 -0
  175. data/rails_generators/emergent_config/templates/app/flex/com/fourD/animators/FourDTweenCollection.mxml +50 -0
  176. data/rails_generators/emergent_config/templates/app/flex/com/fourD/animators/IAnimator.as +39 -0
  177. data/rails_generators/emergent_config/templates/app/flex/com/fourD/animators/TweenMaxAnimator.as +269 -0
  178. data/rails_generators/emergent_config/templates/app/flex/com/fourD/cameras/AstroCamera.as +177 -0
  179. data/rails_generators/emergent_config/templates/app/flex/com/fourD/components/FourDDataGrid.mxml +105 -0
  180. data/rails_generators/emergent_config/templates/app/flex/com/fourD/components/FourDItemRenderer.mxml +54 -0
  181. data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/CenterPerspectiveProjection.as +72 -0
  182. data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/ComplexCondition.as +44 -0
  183. data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/ConditionsUtil.as +82 -0
  184. data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/FourDComponent.as +309 -0
  185. data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/InstanceMethodInvoker.as +50 -0
  186. data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/InstancePropertyInjector.as +43 -0
  187. data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/MethodCaller.as +51 -0
  188. data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/Pathway.as +10 -0
  189. data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/PathwayEvent.as +28 -0
  190. data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/Pheron.as +34 -0
  191. data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/Pheron2.as +41 -0
  192. data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/PheronReceptor.as +125 -0
  193. data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/Properties.as +57 -0
  194. data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/Router.as +50 -0
  195. data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/RouterUtil.as +70 -0
  196. data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/SimpleCondition.as +42 -0
  197. data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/SimpleZSortVO.as +1 -0
  198. data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/SimpleZSorter.as +1 -0
  199. data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/Tecton.as +70 -0
  200. data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/Tecton2.as +234 -0
  201. data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/TectonCache.as +111 -0
  202. data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/TectonEvent.as +39 -0
  203. data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/TectonMap.as +515 -0
  204. data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/TectonMap2.as +289 -0
  205. data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/TectonMapSample.mxml +73 -0
  206. data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/TectonReceptor.as +43 -0
  207. data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/TectonScope.as +38 -0
  208. data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/TectonScopeProperties.as +18 -0
  209. data/rails_generators/emergent_config/templates/app/flex/com/fourD/core/TectonUtils.as +51 -0
  210. data/rails_generators/emergent_config/templates/app/flex/com/fourD/events/LayoutActionEvent.as +75 -0
  211. data/rails_generators/emergent_config/templates/app/flex/com/fourD/layouts/CarouselLayout.as +85 -0
  212. data/rails_generators/emergent_config/templates/app/flex/com/fourD/layouts/CircleLayout.as +102 -0
  213. data/rails_generators/emergent_config/templates/app/flex/com/fourD/layouts/CoverFlowLayout.as +136 -0
  214. data/rails_generators/emergent_config/templates/app/flex/com/fourD/layouts/FourDLayout.as +272 -0
  215. data/rails_generators/emergent_config/templates/app/flex/com/fourD/utils/TweenUtil.as +110 -0
  216. data/rails_generators/emergent_config/templates/app/helpers/accounts_helper.rb +93 -0
  217. data/rails_generators/emergent_config/templates/app/helpers/application_helper.rb +3 -0
  218. data/rails_generators/emergent_config/templates/app/models/account.rb +84 -0
  219. data/rails_generators/emergent_config/templates/app/models/account_mailer.rb +24 -0
  220. data/rails_generators/emergent_config/templates/app/models/account_observer.rb +17 -0
  221. data/rails_generators/emergent_config/templates/app/models/address.rb +2 -0
  222. data/rails_generators/emergent_config/templates/app/models/asset.rb +6 -0
  223. data/rails_generators/emergent_config/templates/app/models/asset_assignment.rb +4 -0
  224. data/rails_generators/emergent_config/templates/app/models/category.rb +35 -0
  225. data/rails_generators/emergent_config/templates/app/models/comment.rb +98 -0
  226. data/rails_generators/emergent_config/templates/app/models/content.rb +89 -0
  227. data/rails_generators/emergent_config/templates/app/models/content_assignment.rb +21 -0
  228. data/rails_generators/emergent_config/templates/app/models/image.rb +3 -0
  229. data/rails_generators/emergent_config/templates/app/models/post.rb +76 -0
  230. data/rails_generators/emergent_config/templates/app/models/section.rb +97 -0
  231. data/rails_generators/emergent_config/templates/app/models/site.rb +1 -0
  232. data/rails_generators/emergent_config/templates/app/models/tag.rb +1 -0
  233. data/rails_generators/emergent_config/templates/app/models/user.rb +4 -0
  234. data/rails_generators/emergent_config/templates/app/views/account_mailer/activation.erb +3 -0
  235. data/rails_generators/emergent_config/templates/app/views/account_mailer/signup_notification.erb +8 -0
  236. data/rails_generators/emergent_config/templates/config/Capfile +4 -0
  237. data/rails_generators/emergent_config/templates/config/README.txt +18 -0
  238. data/rails_generators/emergent_config/templates/config/deploy.rb +36 -0
  239. data/rails_generators/emergent_config/templates/config/routes.rb +72 -0
  240. data/rails_generators/emergent_config/templates/core/actionscript.properties +16 -0
  241. data/rails_generators/emergent_config/templates/core/actionscriptair.properties +16 -0
  242. data/rails_generators/emergent_config/templates/core/app.yaml.erb +12 -0
  243. data/rails_generators/emergent_config/templates/core/default_tasks.rake +51 -0
  244. data/rails_generators/emergent_config/templates/core/emergent_tasks.rake +42 -0
  245. data/rails_generators/emergent_config/templates/core/empty.txt +0 -0
  246. data/rails_generators/emergent_config/templates/core/expressInstall.swf +0 -0
  247. data/rails_generators/emergent_config/templates/core/flex.properties +2 -0
  248. data/rails_generators/emergent_config/templates/core/generate.rb +17 -0
  249. data/rails_generators/emergent_config/templates/core/html-template/AC_OETags.js +276 -0
  250. data/rails_generators/emergent_config/templates/core/html-template/history/history.css +6 -0
  251. data/rails_generators/emergent_config/templates/core/html-template/history/history.js +645 -0
  252. data/rails_generators/emergent_config/templates/core/html-template/history/historyFrame.html +29 -0
  253. data/rails_generators/emergent_config/templates/core/html-template/index.template.html +121 -0
  254. data/rails_generators/emergent_config/templates/core/html-template/playerProductInstall.swf +0 -0
  255. data/rails_generators/emergent_config/templates/core/index.html.erb +18 -0
  256. data/rails_generators/emergent_config/templates/core/index.yaml +11 -0
  257. data/rails_generators/emergent_config/templates/core/mainair-app.xml +134 -0
  258. data/rails_generators/emergent_config/templates/core/mainapp-config.xml +21 -0
  259. data/rails_generators/emergent_config/templates/core/mainapp.mxml +101 -0
  260. data/rails_generators/emergent_config/templates/core/project-textmate.erb +52 -0
  261. data/rails_generators/emergent_config/templates/core/project.properties +18 -0
  262. data/rails_generators/emergent_config/templates/core/projectair.properties +24 -0
  263. data/rails_generators/emergent_config/templates/core/restfulx.yml +14 -0
  264. data/rails_generators/emergent_config/templates/core/restfulx_tasks.rake +6 -0
  265. data/rails_generators/emergent_config/templates/core/swfobject.js +5 -0
  266. data/rails_generators/emergent_config/templates/db/migrate/create_accounts.rb +40 -0
  267. data/rails_generators/emergent_config/templates/db/migrate/create_addresses.rb +18 -0
  268. data/rails_generators/emergent_config/templates/db/migrate/create_asset_assignments.rb +19 -0
  269. data/rails_generators/emergent_config/templates/db/migrate/create_assets.rb +20 -0
  270. data/rails_generators/emergent_config/templates/db/migrate/create_content_assignments.rb +26 -0
  271. data/rails_generators/emergent_config/templates/db/migrate/create_contents.rb +21 -0
  272. data/rails_generators/emergent_config/templates/db/migrate/create_sessions.rb +16 -0
  273. data/rails_generators/emergent_config/templates/db/migrate/create_sites.rb +27 -0
  274. data/rails_generators/emergent_config/templates/db/migrate/create_users.rb +15 -0
  275. data/rails_generators/emergent_config/templates/lib/analytics.swc +0 -0
  276. data/rails_generators/emergent_config/templates/lib/app_controller.rb.erb +26 -0
  277. data/rails_generators/emergent_config/templates/lib/as3corelib-0.92.1.swc +0 -0
  278. data/rails_generators/emergent_config/templates/lib/as3crypto-1.3patched.swc +0 -0
  279. data/rails_generators/emergent_config/templates/lib/as3crypto.swc +0 -0
  280. data/rails_generators/emergent_config/templates/lib/as3ds-1.04.swc +0 -0
  281. data/rails_generators/emergent_config/templates/lib/as3httpclientlib-1.0.swc +0 -0
  282. data/rails_generators/emergent_config/templates/lib/authenticated_system.rb +189 -0
  283. data/rails_generators/emergent_config/templates/lib/authenticated_test_helper.rb +11 -0
  284. data/rails_generators/emergent_config/templates/lib/containerEx.swc +0 -0
  285. data/rails_generators/emergent_config/templates/lib/flare.swc +0 -0
  286. data/rails_generators/emergent_config/templates/lib/flash_session_hack.rb +27 -0
  287. data/rails_generators/emergent_config/templates/lib/flex2BrowserManager.swc +0 -0
  288. data/rails_generators/emergent_config/templates/lib/flexlib.swc +0 -0
  289. data/rails_generators/emergent_config/templates/lib/fluint.swc +0 -0
  290. data/rails_generators/emergent_config/templates/lib/mate_0_8_6_enhanced.swc +0 -0
  291. data/rails_generators/emergent_config/templates/lib/openflux.swc +0 -0
  292. data/rails_generators/emergent_config/templates/lib/pv3d.swc +0 -0
  293. data/rails_generators/emergent_config/templates/lib/restfulx.swc +0 -0
  294. data/rails_generators/emergent_config/templates/lib/site_keys.rb +38 -0
  295. data/rails_generators/emergent_config/templates/lib/tweenMax.swc +0 -0
  296. data/rails_generators/emergent_config/templates/lib/urlkitFlex3.swc +0 -0
  297. data/rails_generators/emergent_config/templates/shell_script +31 -0
  298. data/rails_generators/emergent_controller/USAGE +5 -0
  299. data/rails_generators/emergent_controller/emergent_controller_generator.rb +25 -0
  300. data/rails_generators/emergent_controller/templates/controller.as.erb +37 -0
  301. data/rails_generators/emergent_core/USAGE +5 -0
  302. data/rails_generators/emergent_core/emergent_core_generator.rb +157 -0
  303. data/rails_generators/emergent_iphone/USAGE +5 -0
  304. data/rails_generators/emergent_iphone/emergent_iphone_generator.rb +27 -0
  305. data/rails_generators/emergent_scaffold/USAGE +5 -0
  306. data/rails_generators/emergent_scaffold/emergent_scaffold_generator.rb +157 -0
  307. data/rails_generators/emergent_scaffold/templates/component.mxml.erb +101 -0
  308. data/rails_generators/emergent_scaffold/templates/controller.rb.erb +101 -0
  309. data/rails_generators/emergent_scaffold/templates/edit_index_view.mxml.erb +114 -0
  310. data/rails_generators/emergent_scaffold/templates/edit_show_view.mxml.erb +84 -0
  311. data/rails_generators/emergent_scaffold/templates/filter_view.mxml.erb +1 -0
  312. data/rails_generators/emergent_scaffold/templates/fixtures.yml.erb +128 -0
  313. data/rails_generators/emergent_scaffold/templates/index_view.mxml.erb +58 -0
  314. data/rails_generators/emergent_scaffold/templates/item_renderer.mxml.erb +53 -0
  315. data/rails_generators/emergent_scaffold/templates/manager.as.erb +31 -0
  316. data/rails_generators/emergent_scaffold/templates/migration.rb.erb +22 -0
  317. data/rails_generators/emergent_scaffold/templates/model.as.erb +42 -0
  318. data/rails_generators/emergent_scaffold/templates/model.rb.erb +11 -0
  319. data/rails_generators/emergent_scaffold/templates/presentation_model.as.erb +33 -0
  320. data/rails_generators/emergent_scaffold/templates/presenter.as.erb +98 -0
  321. data/rails_generators/emergent_scaffold/templates/show_view.mxml.erb +50 -0
  322. data/rails_generators/emergent_scaffold/templates/view_map.mxml.erb +40 -0
  323. data/rails_generators/emergent_scaffold/templates/views_panel.mxml.erb +64 -0
  324. data/rails_generators/emergent_styler/USAGE +5 -0
  325. data/rails_generators/emergent_styler/emergent_styler_generator.rb +21 -0
  326. data/rails_generators/rx_yaml_scaffold/USAGE +51 -0
  327. data/rails_generators/rx_yaml_scaffold/rx_yaml_scaffold_generator.rb +49 -0
  328. data/script/console +10 -0
  329. data/script/destroy +14 -0
  330. data/script/generate +14 -0
  331. data/spec/emergent_core_spec.rb +7 -0
  332. data/spec/spec_helper.rb +16 -0
  333. data/tasks/ann.rake +80 -0
  334. data/tasks/bones.rake +20 -0
  335. data/tasks/gem.rake +201 -0
  336. data/tasks/git.rake +40 -0
  337. data/tasks/manifest.rake +48 -0
  338. data/tasks/notes.rake +27 -0
  339. data/tasks/post_load.rake +39 -0
  340. data/tasks/rdoc.rake +50 -0
  341. data/tasks/rubyforge.rake +55 -0
  342. data/tasks/setup.rb +279 -0
  343. data/tasks/spec.rake +54 -0
  344. data/tasks/svn.rake +47 -0
  345. data/tasks/test.rake +40 -0
  346. data/test/test_emergent_core.rb +0 -0
  347. data/test/test_emergent_iphone_generator.rb +46 -0
  348. data/test/test_generator_helper.rb +29 -0
  349. metadata +437 -0
@@ -0,0 +1,194 @@
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
+ # * Date formats
6
+ # * XML format (Flex *really* doesn't like dashes in XML messages)
7
+ # * Errors (we need to be more specific and communicate what went wrong *where*)
8
+ #
9
+ # This is where we try to fix this stuff.
10
+ #
11
+ # Some of the things that are done can be called _monkey_ _patching_ while others can
12
+ # be called extensions. Caveat emptor.
13
+
14
+ # Flex friendly date, datetime formats
15
+ ActiveSupport::CoreExtensions::Date::Conversions::DATE_FORMATS.merge!(:flex_date => "%Y/%m/%d")
16
+ ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.merge!(:flex_datetime => "%Y/%m/%d %H:%M:%S")
17
+
18
+ Hash::XML_FORMATTING['date'] = Proc.new { |date| date.to_s(:flex_date) }
19
+ Hash::XML_FORMATTING['datetime'] = Proc.new { |datetime| datetime.to_s(:flex_datetime) }
20
+
21
+ # ActiveSupport specific patches. More specifically we add +to_fxml+ methods to Array and
22
+ # Hash conversion modules
23
+ module ActiveSupport
24
+ # refer to: http://api.rubyonrails.org/ for more details
25
+ module CoreExtensions
26
+ # Add Flex friendly +to_fxml+ to Hash conversions
27
+ module Hash
28
+ # refer to: http://api.rubyonrails.org/ for more details
29
+ module Conversions
30
+
31
+ # Flex friendly XML format, no dashes, etc
32
+ def to_fxml(options = {})
33
+ options.merge!(:dasherize => false)
34
+ options[:indent] ||= 2
35
+ options.reverse_merge!({ :builder => Builder::XmlMarkup.new(:indent => options[:indent]),
36
+ :root => "hash" })
37
+ options[:builder].instruct! unless options.delete(:skip_instruct)
38
+ dasherize = !options.has_key?(:dasherize) || options[:dasherize]
39
+ root = dasherize ? options[:root].to_s.dasherize : options[:root].to_s
40
+
41
+ options[:builder].__send__(:method_missing, root) do
42
+ each do |key, value|
43
+ case value
44
+ when ::Hash
45
+ value.to_fxml(options.merge({ :root => key, :skip_instruct => true }))
46
+ when ::Array
47
+ value.to_fxml(options.merge({ :root => key, :children => key.to_s.singularize, :skip_instruct => true}))
48
+ when ::Method, ::Proc
49
+ # If the Method or Proc takes two arguments, then
50
+ # pass the suggested child element name. This is
51
+ # used if the Method or Proc will be operating over
52
+ # multiple records and needs to create an containing
53
+ # element that will contain the objects being
54
+ # serialized.
55
+ if 1 == value.arity
56
+ value.call(options.merge({ :root => key, :skip_instruct => true }))
57
+ else
58
+ value.call(options.merge({ :root => key, :skip_instruct => true }), key.to_s.singularize)
59
+ end
60
+ else
61
+ if value.respond_to?(:to_fxml)
62
+ value.to_fxml(options.merge({ :root => key, :skip_instruct => true }))
63
+ else
64
+ type_name = XML_TYPE_NAMES[value.class.name]
65
+
66
+ key = dasherize ? key.to_s.dasherize : key.to_s
67
+
68
+ attributes = options[:skip_types] || value.nil? || type_name.nil? ? { } : { :type => type_name }
69
+ if value.nil?
70
+ attributes[:nil] = true
71
+ end
72
+
73
+ options[:builder].tag!(key,
74
+ XML_FORMATTING[type_name] ? XML_FORMATTING[type_name].call(value) : value,
75
+ attributes
76
+ )
77
+ end
78
+ end
79
+ end
80
+
81
+ yield options[:builder] if block_given?
82
+ end
83
+ end
84
+ end
85
+ end
86
+ # Add Flex friendly to_fxml to array conversions
87
+ module Array
88
+ # refer to: http://api.rubyonrails.org/ for more details
89
+ module Conversions
90
+ # Flex friendly XML format (no dashes, etc)
91
+ def to_fxml(options = {})
92
+ raise "Not all elements respond to to_fxml" unless all? { |e| e.respond_to? :to_fxml }
93
+
94
+ options[:root] ||= all? { |e| e.is_a?(first.class) && first.class.to_s != "Hash" } ? first.class.to_s.underscore.pluralize : "records"
95
+ options[:children] ||= options[:root].singularize
96
+ options[:indent] ||= 2
97
+ options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent])
98
+ options.merge!(:dasherize => false)
99
+
100
+ root = options.delete(:root).to_s
101
+ children = options.delete(:children)
102
+
103
+ if !options.has_key?(:dasherize) || options[:dasherize]
104
+ root = root.dasherize
105
+ end
106
+
107
+ options[:builder].instruct! unless options.delete(:skip_instruct)
108
+
109
+ opts = options.merge({ :root => children })
110
+
111
+ xml = options[:builder]
112
+ if empty?
113
+ xml.tag!(root, options[:skip_types] ? {} : {:type => "array"})
114
+ else
115
+ xml.tag!(root, options[:skip_types] ? {} : {:type => "array"}) {
116
+ yield xml if block_given?
117
+ # Extended by Lance Pollard
118
+ each_with_index do |e, i|
119
+ if options[:child_proc]
120
+ e.to_fxml(opts.merge!({ :skip_instruct => true,
121
+ :procs => options[:child_proc][i] }))
122
+ else
123
+ e.to_fxml(opts.merge!({ :skip_instruct => true }))
124
+ end
125
+ end
126
+ }
127
+ end
128
+ end
129
+ end
130
+ end
131
+ end
132
+ end
133
+
134
+ # Flex friendly ActiveRecord patches. More specifically XML serialization improvements.
135
+ # These won't override whatever you may normally do with XML, hence there's Flex specific
136
+ # name for this stuff +to_fxml+.
137
+ module ActiveRecord
138
+ # refer to: http://api.rubyonrails.org/ for more details
139
+ module Serialization
140
+ # Enforces Flex friendly options on XML and delegates processing to standard +to_xml+
141
+ def to_fxml(options = {}, &block)
142
+ options.merge!(:dasherize => false)
143
+ default_except = [:crypted_password, :salt, :remember_token, :remember_token_expires_at]
144
+ options[:except] = (options[:except] ? options[:except] + default_except : default_except)
145
+ to_xml(options, &block)
146
+ end
147
+ end
148
+
149
+ # Change the xml serializer so that '?'s are stripped from attribute names.
150
+ # This makes it possible to serialize methods that end in a question mark, like 'valid?' or 'is_true?'
151
+ class XmlSerializer
152
+ # Strips '?' from serialized method names
153
+ def add_tag(attribute)
154
+ builder.tag!(
155
+ dasherize? ? attribute.display_name.dasherize : attribute.display_name,
156
+ attribute.value.to_s,
157
+ attribute.decorations(!options[:skip_types])
158
+ )
159
+ end
160
+ # Strips '?' from serialized method names
161
+ class Attribute
162
+ # Strips '?' from serialized method names
163
+ def display_name
164
+ @name.gsub('?','')
165
+ end
166
+ end
167
+ end
168
+
169
+ # Add more extensive reporting on errors including field name along with a message
170
+ # when errors are serialized to XML
171
+ class Errors
172
+ # Flex friendly errors
173
+ def to_fxml(options={})
174
+ options[:root] ||= "errors"
175
+ options[:indent] ||= 2
176
+ options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent])
177
+ options[:builder].instruct! unless options.delete(:skip_instruct)
178
+ options[:builder].errors do |e|
179
+ # The @errors instance variable is a Hash inside the Errors class
180
+ @errors.each_key do |attr|
181
+ @errors[attr].each do |msg|
182
+ next if msg.nil?
183
+ if attr == "base"
184
+ options[:builder].error("message" => msg)
185
+ else
186
+ fullmsg = @base.class.human_attribute_name(attr) + ' ' + msg
187
+ options[:builder].error("field" => attr.camelcase(:lower), "message" => fullmsg)
188
+ end
189
+ end
190
+ end
191
+ end
192
+ end
193
+ end
194
+ end
@@ -0,0 +1,81 @@
1
+ # ActiveRecord specific Rake tasks. Namely, nice little extras such as:
2
+ # - db:mysql:stage
3
+ # - db:refresh
4
+ require File.join(File.dirname(__FILE__), 'tasks')
5
+
6
+ # stores local copy of the application environment ('production', 'test', etc)
7
+ # so that appropriate values in config/database.yml are used
8
+ APP_ENV = defined?(ENV['RAILS_ENV']) ? ENV['RAILS_ENV'] : ENV['MERB_ENV']
9
+
10
+ namespace :db do
11
+ namespace :mysql do
12
+ namespace :stage do
13
+ desc "Stage production, test and development databases"
14
+ task :all do
15
+ db_names = %w(development test production)
16
+ admin_password = ENV["ADMINPASS"] || ""
17
+ db_user_name = ENV["USER"] || "root"
18
+ db_password = ENV["PASS"] || ""
19
+ stage_database(db_names, admin_password, db_user_name, db_password)
20
+ end
21
+ end
22
+
23
+ desc "Stage the database environment for #{APP_ENV}"
24
+ task :stage do
25
+ db_names = [APP_ENV]
26
+ admin_password = ENV["ADMINPASS"] || ""
27
+ db_user_name = ENV["USER"] || "root"
28
+ db_password = ENV["PASS"] || ""
29
+ stage_database(db_names, admin_password, db_user_name, db_password)
30
+ end
31
+ end
32
+
33
+ # Performs MySQL database set-up based on the username and password
34
+ # provided. Also updates Rails config/database.yml file with database
35
+ # username and password
36
+ def stage_database(db_names, admin_password, db_user_name, db_password)
37
+ sql_command = ""
38
+
39
+ db_names.each do |name|
40
+ db_name = ActiveRecord::Base.configurations[name]['database']
41
+ sql_command += "drop database if exists #{db_name}; " <<
42
+ "create database #{db_name}; grant all privileges on #{db_name}.* " <<
43
+ "to #{db_user_name}@localhost identified by \'#{db_password}\';"
44
+ ActiveRecord::Base.configurations[name]['username'] = db_user_name
45
+ ActiveRecord::Base.configurations[name]['password'] = db_password
46
+ end
47
+
48
+ if (!File.exist?("#{APP_ROOT}/tmp/stage.sql"))
49
+ File.open("#{APP_ROOT}/tmp/stage.sql", "w") do |file|
50
+ file.print sql_command
51
+ end
52
+ end
53
+
54
+ # back up the original database.yml file just in case
55
+ File.copy("#{APP_ROOT}/config/database.yml",
56
+ "#{APP_ROOT}/config/database.yml.sample") if !File.exist?("#{APP_ROOT}/config/database.yml.sample")
57
+
58
+ dbconfig = File.read("#{APP_ROOT}/config/database.yml")
59
+ dbconfig.gsub!(/username:.*/, "username: #{db_user_name}")
60
+ dbconfig.gsub!(/password:.*/, "password: #{db_password}")
61
+
62
+ File.open("#{APP_ROOT}/config/database.yml", "w") do |file|
63
+ file.print dbconfig
64
+ end
65
+
66
+ if system %(mysql -h localhost -u root --password=#{admin_password} < tmp/stage.sql)
67
+ puts "Updated config/database.yml and staged the database based on your settings"
68
+ File.delete("tmp/stage.sql") if File.file?("tmp/stage.sql")
69
+ else
70
+ puts "Staging was not performed. Check console for errors. It is possible that 'mysql' executable was not found."
71
+ end
72
+ end
73
+
74
+ desc "Drop the database environment for #{APP_ENV} only if it exists"
75
+ task :drop_if_exists do
76
+ Rake::Task["db:drop"].invoke rescue nil
77
+ end
78
+
79
+ desc "Refresh the database environment for #{APP_ENV}"
80
+ task :refresh => ['db:drop_if_exists', 'db:create', 'db:migrate', 'db:fixtures:load']
81
+ end
@@ -0,0 +1,76 @@
1
+ # Interestingly enough there's no way to *just* upper-case or down-case first letter of a given
2
+ # string. Ruby's own +capitalize+ actually downcases all the rest of the characters in the string
3
+ # We patch the class to add our own implementation.
4
+ class String
5
+ # Upper-case first character of a string leave the rest of the string intact
6
+ def ucfirst
7
+ self[0,1].capitalize + self[1..-1]
8
+ end
9
+
10
+ # Down-case first character of a string leaving the rest of it intact
11
+ def dcfirst
12
+ self[0,1].downcase + self[1..-1]
13
+ end
14
+ end
15
+
16
+ module RestfulX
17
+ # Computes necessary configuration options from the environment. This can be used in Rails, Merb
18
+ # or standalone from the command line.
19
+ module Configuration
20
+ APP_ROOT = defined?(RAILS_ROOT) ? RAILS_ROOT : defined?(Merb) ? Merb.root : File.expand_path(".")
21
+
22
+ # Extract project, package, controller names from the environment. This will respect
23
+ # config/restfulx.yml if it exists, you can override all of the defaults there. The defaults are:
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
43
+ def extract_names(project = nil)
44
+ if project
45
+ project_name = project.camelcase.gsub(/\s/, '')
46
+ project_name_downcase = project_name.downcase
47
+ else
48
+ project_name = APP_ROOT.split("/").last.camelcase.gsub(/\s/, '')
49
+ project_name_downcase = project_name.downcase
50
+ end
51
+
52
+ # give a chance to override the settings via restfulx.yml
53
+ begin
54
+ config = YAML.load(File.open("#{APP_ROOT}/config/restfulx.yml"))
55
+ base_package = config['base-package'] || project_name_downcase
56
+ base_folder = base_package.gsub('.', '/').gsub(/\s/, '')
57
+ project_name = config['project-name'].camelcase.gsub(/\s/, '') || project_name
58
+ controller_name = config['controller-name'] || "ApplicationController"
59
+ rescue
60
+ base_folder = base_package = project_name_downcase
61
+ controller_name = "ApplicationController"
62
+ end
63
+ [project_name, project_name_downcase, controller_name, base_package, base_folder]
64
+ end
65
+
66
+ # List files ending in *.as (ActionScript) in a given folder
67
+ def list_as_files(dir_name)
68
+ Dir.entries(dir_name).grep(/\.as$/).map { |name| name.sub(/\.as$/, "") }.join(", ")
69
+ end
70
+
71
+ # List files ending in *.mxml in a given folder
72
+ def list_mxml_files(dir_name)
73
+ Dir.entries(dir_name).grep(/\.mxml$/).map { |name| name.sub(/\.mxml$/, "") }
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,31 @@
1
+ require 'builder'
2
+ require RestfulX::LIB_DIR + 'configuration'
3
+
4
+ # Flex friendly DataMapper patches, more specifically we just add +to_xml+ on
5
+ # ValidationErrors class
6
+ module DataMapper
7
+ # see DataMapper docs for more details
8
+ module Validate
9
+ # By default DataMapper validation errors doesn't have +to_xml+ method. This is
10
+ # actually very useful when dealing with remote stateful clients such as Flex/AIR.
11
+ class ValidationErrors
12
+ # Add Flex-friendly +to_xml+ implementation
13
+ def to_xml
14
+ xml = Builder::XmlMarkup.new(:indent => 2)
15
+ xml.instruct! :xml, :version => "1.0", :encoding => "UTF-8"
16
+ xml.errors do |e|
17
+ @errors.each_key do |attribute|
18
+ @errors[attribute].each do |msg|
19
+ next if msg.nil?
20
+ if attribute == "base"
21
+ e.error("message" => msg)
22
+ else
23
+ e.error("field" => attribute.to_s.camelcase(:lower), "message" => msg)
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,60 @@
1
+ # Adds Capistrano recipes for deploying Flex applications
2
+ #
3
+ # To use these recipes, add the following to your Capfile:
4
+ #
5
+ # require 'restfulx/rails/recipes'
6
+ require 'find'
7
+
8
+ Capistrano::Configuration.instance(:must_exist).load do
9
+ after "deploy:setup", "deploy:flex:setup"
10
+
11
+ namespace :db do
12
+ desc "runs db:refresh in the latest release directory."
13
+ task :refresh, :roles => :db do
14
+ run("cd #{latest_release} && rake db:refresh RAILS_ENV=production")
15
+ end
16
+ end
17
+
18
+ namespace :deploy do
19
+ namespace :flex do
20
+
21
+ desc "Creates the flex_files directory in the shared directory"
22
+ task :setup do
23
+ flex_dir = File.join(shared_path, 'flex_files')
24
+ run "#{try_sudo} mkdir -p #{flex_dir} && #{try_sudo} chmod g+w #{flex_dir}"
25
+ end
26
+
27
+ desc "uploads everything in public/bin up to the server"
28
+ task :via_dumb_copy, :roles => :app do
29
+ # the -p flag on mkdir makes intermediate directories (i.e. both /bin and /bin/history),
30
+ # and doesn't raise an error if any of the directories already exist.
31
+ rails_root = Dir.pwd # You have to run cap tasks from RAILS_ROOT anyways
32
+ base_dir = File.join(rails_root, 'public', 'bin')
33
+ ec2_base_dir = File.join(shared_path, 'flex_files')
34
+
35
+ Find.find(base_dir) do |file|
36
+ filename_without_base_dir = file.sub(base_dir, '')
37
+ if File.directory?(file)
38
+ run "mkdir -p #{File.join(ec2_base_dir, filename_without_base_dir)}"
39
+ else
40
+ content = File.open(file, 'rb') {|f| f.read}
41
+ put content, File.join(ec2_base_dir, filename_without_base_dir)
42
+ end
43
+ end
44
+ end
45
+
46
+ desc "synchronizes the local and remote public/bin directories using rsync"
47
+ task :via_rsync, :roles => :app do
48
+ username = user || ENV['USER']
49
+ rails_root = Dir.pwd # You have to run cap tasks from RAILS_ROOT anyways
50
+ execute_on_servers do |server|
51
+ `rsync -r -p -v -e \"ssh -i #{ssh_options[:keys]}\" #{File.join(rails_root, 'public', 'bin')}/ #{username}@#{server}:#{File.join(shared_path, 'flex_files')}/`
52
+ end
53
+ end
54
+
55
+ task :make_symlink, :roles => :app do
56
+ run "ln -s #{shared_path}/flex_files #{release_path}/public/bin"
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,60 @@
1
+ # Adds a little helper to make it easier empbedding SWFs in ERB templates.
2
+ module SWFHelper
3
+
4
+ # Creates a swfObject Javascript call. You must include swfobject.js to use this.
5
+ # See http://code.google.com/p/swfobject/wiki/documentation for full details and documentation
6
+ # of the swfobject js library.
7
+ def swfobject(swf_url, params = {})
8
+ params.reverse_merge!({:width => '100%',
9
+ :height => '100%',
10
+ :id => 'flashContent',
11
+ :version => '9.0.0',
12
+ :express_install_swf => '/expressInstall.swf',
13
+ :flash_vars => nil,
14
+ :params => nil,
15
+ :attributes => nil,
16
+ :create_div => false,
17
+ :include_authenticity_token => true,
18
+ :include_session_token => true
19
+ })
20
+ arg_order = [:id, :width, :height, :version, :express_install_swf]
21
+ js_params = ["'#{swf_url}?#{rails_asset_id(swf_url)}'"]
22
+ js_params += arg_order.collect {|arg| "'#{params[arg]}'" }
23
+
24
+ # Add authenticity_token and the session key to flashVars. This will only work if flashVars is a Hash or nil
25
+ # If it's a string representing the name of a Javascript variable, then you need to add them yourself
26
+ # like this:
27
+ # <script>
28
+ # ... other code that defines flashVars and sets some of its parameters
29
+ # flashVars['authenticity_token'] = <%= form_authenticity_token -%>
30
+ # flashVars['session_token'] = <%= session.session_id -%>
31
+ # </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
+ params[:flash_vars] ||= {}
36
+ if params[:flash_vars].is_a?(Hash)
37
+ if params[:include_authenticity_token] && ActionController::Base.allow_forgery_protection
38
+ params[:flash_vars].reverse_merge!(:authenticity_token => form_authenticity_token)
39
+ end
40
+ if params[:include_session_token]
41
+ params[:flash_vars].reverse_merge!(:session_token => session.session_id)
42
+ end
43
+ end
44
+
45
+ js_params += [params[:flash_vars], params[:params], params[:attributes]].collect do |hash_or_string|
46
+ if hash_or_string.is_a?(Hash)
47
+ hash_or_string.to_json
48
+ else # If it's not a hash, then it should be a string giving the name of the Javascript variable to use
49
+ hash_or_string
50
+ end
51
+ end.compact
52
+
53
+ swf_tag = javascript_tag do
54
+ "swfobject.embedSWF(#{js_params.join(',')})"
55
+ end
56
+ swf_tag += content_tag(:div, nil, :id => params[:id]) if params[:create_div]
57
+ swf_tag
58
+ end
59
+
60
+ end
@@ -0,0 +1,85 @@
1
+ # Rake tasks for building RestfulX-based Flex and AIR applications
2
+ require 'rake'
3
+ require 'ftools'
4
+ require 'rexml/document'
5
+ require File.join(File.dirname(__FILE__), 'configuration')
6
+
7
+ APP_ROOT = RestfulX::Configuration::APP_ROOT
8
+
9
+ namespace :rx do
10
+ # Compile the main Flex/AIR application using given executable to the given
11
+ # destination folder
12
+ def compile_app(executable, destination, opts = '')
13
+ app_properties = REXML::Document.new(File.open(File.join(APP_ROOT, ".actionScriptProperties")))
14
+ app_properties.elements.each("*/applications/application") do |elm|
15
+ app_path = elm.attributes['path']
16
+ project_path = File.join(APP_ROOT, "app/flex", app_path)
17
+ target_project_path = project_path.sub(/.mxml$/, '.swf')
18
+ target_project_air_descriptor = project_path.sub(/.mxml$/, '-app.xml')
19
+
20
+ libs = Dir.glob(File.join(APP_ROOT, 'lib', '*.swc')).map {|lib| lib.gsub(' ', '\ ')}
21
+
22
+ cmd = "#{executable} #{opts} -library-path+=#{libs.join(',')} " <<
23
+ "-keep-as3-metadata+=Resource,HasOne,HasMany,BelongsTo,DateTime,Lazy,Ignored #{project_path.gsub(' ', '\ ')}"
24
+ puts "Compiling #{project_path}"
25
+ if system(cmd)
26
+ FileUtils.makedirs File.join(APP_ROOT, destination)
27
+ puts "Moving #{target_project_path} to " + File.join(APP_ROOT, destination)
28
+ FileUtils.mv target_project_path, File.join(APP_ROOT, destination), :force => true
29
+ if File.exist?(target_project_air_descriptor)
30
+ descriptor = File.read(target_project_air_descriptor)
31
+ descriptor_name = target_project_air_descriptor.split("/").last
32
+ app_swf = target_project_path.split("/").last
33
+ descriptor.gsub!("[This value will be overwritten by Flex Builder in the output app.xml]",
34
+ app_swf)
35
+
36
+ File.open("#{APP_ROOT}/#{destination}/#{descriptor_name}", "w") do |file|
37
+ file.print descriptor
38
+ end
39
+ puts "Created #{APP_ROOT}/#{destination}/#{descriptor_name} descriptor."
40
+ end
41
+ puts 'Done!'
42
+ else
43
+ puts "The application was not compiled. Check console for errors. " <<
44
+ "It is possible that '(a)mxmlc' executable was not found or there are compilation errors."
45
+ end
46
+ end
47
+ end
48
+
49
+ # Find what the main application is based on .actionScriptProperties file
50
+ def get_main_application
51
+ app_properties = REXML::Document.new(File.open(File.join(APP_ROOT, ".actionScriptProperties")))
52
+ app_properties.root.attributes['mainApplicationPath'].split("/").last
53
+ end
54
+
55
+ # Get appropriate executable based on platform
56
+ def get_executable(executable)
57
+ if RUBY_PLATFORM =~ /mswin32/
58
+ executable << '.exe'
59
+ end
60
+ executable
61
+ end
62
+
63
+ namespace :flex do
64
+ desc "Build project swf file and move it into public/bin folder"
65
+ task :build do
66
+ compile_app(get_executable('mxmlc'), 'public/bin')
67
+ end
68
+ end
69
+
70
+ namespace :air do
71
+ desc "Build project swf file as an AIR application and move it into bin-debug folder"
72
+ task :build do
73
+ compile_app(get_executable('mxmlc'), 'bin-debug', '+configname=air')
74
+ end
75
+
76
+ desc "Run the AIR application (if this project is configured as an AIR project)"
77
+ task :run do
78
+ target = get_main_application.gsub(/.mxml$/, '-app.xml')
79
+ puts "Running AIR application with descriptor: #{target}"
80
+ if !system("#{get_executable('adl')} bin-debug/#{target}")
81
+ puts "Could not run the application with descriptor: #{target}. Check console for errors."
82
+ end
83
+ end
84
+ end
85
+ end