rtml 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (397) hide show
  1. data/History.txt +4 -0
  2. data/Manifest.txt +396 -0
  3. data/PostInstall.txt +2 -0
  4. data/README.rdoc +42 -0
  5. data/Rakefile +33 -0
  6. data/app_generators/rtml/USAGE +5 -0
  7. data/app_generators/rtml/rtml_generator.rb +78 -0
  8. data/app_generators/rtml/templates/rails_template.rb +36 -0
  9. data/app_generators/rtml/templates/rtml/MIT-LICENSE +20 -0
  10. data/app_generators/rtml/templates/rtml/README +109 -0
  11. data/app_generators/rtml/templates/rtml/Rakefile +38 -0
  12. data/app_generators/rtml/templates/rtml/app/controllers/beryl_controller.rb +70 -0
  13. data/app_generators/rtml/templates/rtml/app/controllers/rtml/magcard_demo_controller.rb +9 -0
  14. data/app_generators/rtml/templates/rtml/app/controllers/rtml/oe/btmlpa_controller.rb +158 -0
  15. data/app_generators/rtml/templates/rtml/app/controllers/rtml/rtml_app_controller.rb +252 -0
  16. data/app_generators/rtml/templates/rtml/app/controllers/rtml/tml_app_controller.rb +418 -0
  17. data/app_generators/rtml/templates/rtml/app/helpers/beryl_helper.rb +72 -0
  18. data/app_generators/rtml/templates/rtml/app/helpers/beryl_tml_helpers/auth_result.rb +56 -0
  19. data/app_generators/rtml/templates/rtml/app/helpers/beryl_tml_helpers/common.rb +19 -0
  20. data/app_generators/rtml/templates/rtml/app/helpers/beryl_tml_helpers/index.rb +82 -0
  21. data/app_generators/rtml/templates/rtml/app/helpers/rtml/magcard_demo_helper.rb +2 -0
  22. data/app_generators/rtml/templates/rtml/app/helpers/rtml/magcard_demo_tml_helpers/authorized.rb +10 -0
  23. data/app_generators/rtml/templates/rtml/app/helpers/rtml/magcard_demo_tml_helpers/common.rb +20 -0
  24. data/app_generators/rtml/templates/rtml/app/helpers/rtml/magcard_demo_tml_helpers/index.rb +33 -0
  25. data/app_generators/rtml/templates/rtml/app/helpers/rtml/oe/btmlpa_helper.rb +2 -0
  26. data/app_generators/rtml/templates/rtml/app/helpers/rtml/oe/btmlpa_tml_helpers/auth_result.rb +23 -0
  27. data/app_generators/rtml/templates/rtml/app/helpers/rtml/oe/btmlpa_tml_helpers/common.rb +23 -0
  28. data/app_generators/rtml/templates/rtml/app/helpers/rtml/oe/btmlpa_tml_helpers/dynamic.rb +11 -0
  29. data/app_generators/rtml/templates/rtml/app/helpers/rtml/oe/btmlpa_tml_helpers/icc.rb +384 -0
  30. data/app_generators/rtml/templates/rtml/app/helpers/rtml/oe/btmlpa_tml_helpers/index.rb +191 -0
  31. data/app_generators/rtml/templates/rtml/app/helpers/rtml/oe/btmlpa_tml_helpers/receipt.rb +152 -0
  32. data/app_generators/rtml/templates/rtml/app/helpers/rtml/rtml_app_helper.rb +74 -0
  33. data/app_generators/rtml/templates/rtml/app/helpers/rtml/rtml_app_tml_helpers/common.rb +9 -0
  34. data/app_generators/rtml/templates/rtml/app/helpers/rtml/tml_app_helper.rb +43 -0
  35. data/app_generators/rtml/templates/rtml/app/models/rtml/card.rb +83 -0
  36. data/app_generators/rtml/templates/rtml/app/models/rtml/card_avs.rb +14 -0
  37. data/app_generators/rtml/templates/rtml/app/models/rtml/card_cvv.rb +14 -0
  38. data/app_generators/rtml/templates/rtml/app/models/rtml/card_parser.rb +21 -0
  39. data/app_generators/rtml/templates/rtml/app/models/rtml/card_pin.rb +18 -0
  40. data/app_generators/rtml/templates/rtml/app/models/rtml/emv_card_data.rb +25 -0
  41. data/app_generators/rtml/templates/rtml/app/models/rtml/mag_card_data.rb +21 -0
  42. data/app_generators/rtml/templates/rtml/app/models/rtml/reference_code.rb +26 -0
  43. data/app_generators/rtml/templates/rtml/app/models/rtml/state.rb +12 -0
  44. data/app_generators/rtml/templates/rtml/app/models/rtml/terminal.rb +8 -0
  45. data/app_generators/rtml/templates/rtml/app/models/rtml/transaction.rb +68 -0
  46. data/app_generators/rtml/templates/rtml/app/views/beryl/auth_result/another_rcpt.rtml.erb +15 -0
  47. data/app_generators/rtml/templates/rtml/app/views/beryl/auth_result/receipt.rtml.erb +108 -0
  48. data/app_generators/rtml/templates/rtml/app/views/beryl/auth_result/receipt_single_column.rtml.erb +106 -0
  49. data/app_generators/rtml/templates/rtml/app/views/beryl/index/about.rtml.erb +8 -0
  50. data/app_generators/rtml/templates/rtml/app/views/beryl/index/admin.rtml.erb +4 -0
  51. data/app_generators/rtml/templates/rtml/app/views/beryl/index/construction.rtml.erb +10 -0
  52. data/app_generators/rtml/templates/rtml/app/views/beryl/index/idle.rtml.erb +13 -0
  53. data/app_generators/rtml/templates/rtml/app/views/beryl/index/main_menu.rtml.erb +12 -0
  54. data/app_generators/rtml/templates/rtml/app/views/beryl/index/menu_credit.rtml.erb +8 -0
  55. data/app_generators/rtml/templates/rtml/app/views/beryl/index/menu_debit.rtml.erb +3 -0
  56. data/app_generators/rtml/templates/rtml/app/views/layouts/rtml/beryl_color.rtml.erb +24 -0
  57. data/app_generators/rtml/templates/rtml/app/views/layouts/rtml/beryl_mono.rtml.erb +8 -0
  58. data/app_generators/rtml/templates/rtml/app/views/layouts/rtml/magcard_demo_color.rtml.erb +24 -0
  59. data/app_generators/rtml/templates/rtml/app/views/layouts/rtml/magcard_demo_mono.rtml.erb +3 -0
  60. data/app_generators/rtml/templates/rtml/app/views/layouts/rtml/oe/btmlpa_i5100.rtml.erb +3 -0
  61. data/app_generators/rtml/templates/rtml/app/views/layouts/rtml/oe/btmlpa_i8550.rtml.erb +17 -0
  62. data/app_generators/rtml/templates/rtml/app/views/layouts/rtml/uml.html.erb +11 -0
  63. data/app_generators/rtml/templates/rtml/app/views/rtml/magcard_demo/authorized.html.erb +15 -0
  64. data/app_generators/rtml/templates/rtml/app/views/rtml/magcard_demo/authorized/main.rtml.erb +5 -0
  65. data/app_generators/rtml/templates/rtml/app/views/rtml/magcard_demo/index.html.erb +15 -0
  66. data/app_generators/rtml/templates/rtml/app/views/rtml/magcard_demo/index/_error.rtml.erb +2 -0
  67. data/app_generators/rtml/templates/rtml/app/views/rtml/magcard_demo/index/enter_amount.rtml.erb +5 -0
  68. data/app_generators/rtml/templates/rtml/app/views/rtml/magcard_demo/index/main.rtml.erb +4 -0
  69. data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/dynamic/response.rtml.erb +2 -0
  70. data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/icc.rtml.erb +760 -0
  71. data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/_enter_amount.rtml.erb +4 -0
  72. data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/_menu_about.rtml.erb +8 -0
  73. data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/_menu_duplicate.rtml.erb +9 -0
  74. data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/_menu_examples.rtml.erb +9 -0
  75. data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/_menu_logo.rtml.erb +11 -0
  76. data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/_menu_other.rtml.erb +20 -0
  77. data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/_menu_refund.rtml.erb +8 -0
  78. data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/_menu_reversal.rtml.erb +9 -0
  79. data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/_menu_sale.rtml.erb +8 -0
  80. data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/_menu_sale_cashback.rtml.erb +8 -0
  81. data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/about.rtml.erb +1 -0
  82. data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/assert.rtml.erb +2 -0
  83. data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/card_nmb.rtml.erb +19 -0
  84. data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/compl_txn.rtml.erb +1 -0
  85. data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/confirm_rev.rtml.erb +3 -0
  86. data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/duplicate_na.rtml.erb +1 -0
  87. data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/error_scr.rtml.erb +4 -0
  88. data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/main_menu.rtml.bak +31 -0
  89. data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/main_menu.rtml.erb +40 -0
  90. data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/print_pf.rtml.erb +1 -0
  91. data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/rd_sale_disp.rtml.erb +1 -0
  92. data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/read_refund.rtml.erb +1 -0
  93. data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/read_scb.rtml.erb +10 -0
  94. data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/reject_trans.rtml.erb +1 -0
  95. data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/remove_card.rtml.erb +1 -0
  96. data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/rev_bad.rtml.erb +1 -0
  97. data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/scb_check_f.rtml.erb +2 -0
  98. data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/sign_check.rtml.erb +3 -0
  99. data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/subm_err.rtml.erb +2 -0
  100. data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/to_man_entry.rtml.erb +2 -0
  101. data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/trans_abrt.rtml.erb +1 -0
  102. data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/index/void_trans.rtml.erb +1 -0
  103. data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/receipt/_receipt.rtml.erb +29 -0
  104. data/app_generators/rtml/templates/rtml/app/views/rtml/oe/btmlpa/receipt/error_paper.rtml.erb +3 -0
  105. data/app_generators/rtml/templates/rtml/app/views/rtml/rtml_app/_default_development.html.erb +167 -0
  106. data/app_generators/rtml/templates/rtml/app/views/rtml/rtml_app/_default_header.html.erb +12 -0
  107. data/app_generators/rtml/templates/rtml/app/views/rtml/rtml_app/_default_production.html.erb +8 -0
  108. data/app_generators/rtml/templates/rtml/app/views/rtml/rtml_app/charts.html.erb +14 -0
  109. data/app_generators/rtml/templates/rtml/app/views/rtml/tml_app/do_tml_redirect.rtml.erb +7 -0
  110. data/app_generators/rtml/templates/rtml/app/views/rtml/tml_app/get_terminal_info.rtml.erb +26 -0
  111. data/app_generators/rtml/templates/rtml/app/views/rtml/tml_app/rescue_action_in_public.rtml.erb +9 -0
  112. data/app_generators/rtml/templates/rtml/app/views/rtml/tml_app/rescue_action_locally.rtml.erb +42 -0
  113. data/app_generators/rtml/templates/rtml/components/rtml/features/common.rb +303 -0
  114. data/app_generators/rtml/templates/rtml/components/rtml/features/force.rb +46 -0
  115. data/app_generators/rtml/templates/rtml/components/rtml/features/return.rb +22 -0
  116. data/app_generators/rtml/templates/rtml/components/rtml/features/sale.rb +49 -0
  117. data/app_generators/rtml/templates/rtml/components/rtml/features/views/_confirmation.rtml.erb +10 -0
  118. data/app_generators/rtml/templates/rtml/components/rtml/features/views/_receipt_agreement.rtml.erb +3 -0
  119. data/app_generators/rtml/templates/rtml/components/rtml/features/views/_receipt_footer.rtml.erb +2 -0
  120. data/app_generators/rtml/templates/rtml/components/rtml/features/views/_receipt_header.rtml.erb +4 -0
  121. data/app_generators/rtml/templates/rtml/components/rtml/features/views/ask_cashback.rtml.erb +11 -0
  122. data/app_generators/rtml/templates/rtml/components/rtml/features/views/card_imprint.rtml.erb +7 -0
  123. data/app_generators/rtml/templates/rtml/components/rtml/features/views/check_cb.rtml.erb +11 -0
  124. data/app_generators/rtml/templates/rtml/components/rtml/features/views/conf_debit.rtml.erb +5 -0
  125. data/app_generators/rtml/templates/rtml/components/rtml/features/views/confirm_sale.rtml.erb +4 -0
  126. data/app_generators/rtml/templates/rtml/components/rtml/features/views/confrm_force.rtml.erb +4 -0
  127. data/app_generators/rtml/templates/rtml/components/rtml/features/views/cvv_skipped.rtml.erb +10 -0
  128. data/app_generators/rtml/templates/rtml/components/rtml/features/views/disp_avs.rtml.erb +8 -0
  129. data/app_generators/rtml/templates/rtml/components/rtml/features/views/do_avs_zip.rtml.erb +8 -0
  130. data/app_generators/rtml/templates/rtml/components/rtml/features/views/enter_amount.rtml.erb +12 -0
  131. data/app_generators/rtml/templates/rtml/components/rtml/features/views/enter_card.rtml.erb +8 -0
  132. data/app_generators/rtml/templates/rtml/components/rtml/features/views/enter_cashbk.rtml.erb +10 -0
  133. data/app_generators/rtml/templates/rtml/components/rtml/features/views/enter_cvv2.rtml.erb +8 -0
  134. data/app_generators/rtml/templates/rtml/components/rtml/features/views/enter_expiry.rtml.erb +9 -0
  135. data/app_generators/rtml/templates/rtml/components/rtml/features/views/fraud_check1.rtml.erb +6 -0
  136. data/app_generators/rtml/templates/rtml/components/rtml/features/views/fraud_check2.rtml.erb +8 -0
  137. data/app_generators/rtml/templates/rtml/components/rtml/features/views/frc_aprvl.rtml.erb +8 -0
  138. data/app_generators/rtml/templates/rtml/components/rtml/features/views/frc_avs_zip.rtml.erb +8 -0
  139. data/app_generators/rtml/templates/rtml/components/rtml/features/views/frc_bad_aprv.rtml.erb +5 -0
  140. data/app_generators/rtml/templates/rtml/components/rtml/features/views/frd_chk_fail.rtml.erb +5 -0
  141. data/app_generators/rtml/templates/rtml/components/rtml/features/views/invalid_exp.rtml.erb +1 -0
  142. data/app_generators/rtml/templates/rtml/components/rtml/features/views/no_entr_crd.rtml.erb +1 -0
  143. data/app_generators/rtml/templates/rtml/components/rtml/features/views/remove_card.rtml.erb +1 -0
  144. data/app_generators/rtml/templates/rtml/components/rtml/features/views/swipe_card.rtml.erb +7 -0
  145. data/app_generators/rtml/templates/rtml/components/rtml/features/views/trans_abort.rtml.erb +1 -0
  146. data/app_generators/rtml/templates/rtml/components/rtml/features/views/trans_reject.rtml.erb +1 -0
  147. data/app_generators/rtml/templates/rtml/components/rtml/features/views/void_ref.rtml.erb +10 -0
  148. data/app_generators/rtml/templates/rtml/components/rtml/features/void.rb +30 -0
  149. data/app_generators/rtml/templates/rtml/components/rtml/widgets/card_parser_widget.rb +90 -0
  150. data/app_generators/rtml/templates/rtml/components/rtml/widgets/display_widget.rb +66 -0
  151. data/app_generators/rtml/templates/rtml/components/rtml/widgets/element_builder_widget.rb +123 -0
  152. data/app_generators/rtml/templates/rtml/components/rtml/widgets/emv_support_widget.rb +365 -0
  153. data/app_generators/rtml/templates/rtml/components/rtml/widgets/form_submit_widget.rb +65 -0
  154. data/app_generators/rtml/templates/rtml/components/rtml/widgets/get_transaction_variables_widget.rb +33 -0
  155. data/app_generators/rtml/templates/rtml/components/rtml/widgets/get_variable_widget.rb +39 -0
  156. data/app_generators/rtml/templates/rtml/components/rtml/widgets/receipt_widget.rb +66 -0
  157. data/app_generators/rtml/templates/rtml/components/rtml/widgets/screen_builder_widget.rb +49 -0
  158. data/app_generators/rtml/templates/rtml/db/migrate/20090825132217_create_rtml_states.rb +15 -0
  159. data/app_generators/rtml/templates/rtml/db/migrate/20090825132401_create_rtml_terminals.rb +16 -0
  160. data/app_generators/rtml/templates/rtml/db/migrate/20090825132530_create_rtml_transactions.rb +24 -0
  161. data/app_generators/rtml/templates/rtml/db/migrate/20090825134118_create_rtml_cards.rb +23 -0
  162. data/app_generators/rtml/templates/rtml/db/migrate/20090825134622_create_rtml_emv_card_data.rb +20 -0
  163. data/app_generators/rtml/templates/rtml/db/migrate/20090825134629_create_rtml_mag_card_data.rb +17 -0
  164. data/app_generators/rtml/templates/rtml/db/migrate/20090825135838_create_rtml_card_parsers.rb +19 -0
  165. data/app_generators/rtml/templates/rtml/db/migrate/20090826103509_create_reference_codes.rb +14 -0
  166. data/app_generators/rtml/templates/rtml/db/migrate/20090915030044_add_batch_to_rtml_transactions.rb +10 -0
  167. data/app_generators/rtml/templates/rtml/db/migrate/20090915031155_add_additional_data_to_rtml_transactions.rb +10 -0
  168. data/app_generators/rtml/templates/rtml/db/migrate/20090915031156_add_hidden_data_to_rtml_transactions.rb +10 -0
  169. data/app_generators/rtml/templates/rtml/db/migrate/20091016133313_create_rtml_card_avs.rb +16 -0
  170. data/app_generators/rtml/templates/rtml/db/migrate/20091016135800_create_rtml_card_cvvs.rb +16 -0
  171. data/app_generators/rtml/templates/rtml/db/migrate/20091016135810_create_rtml_card_pins.rb +16 -0
  172. data/app_generators/rtml/templates/rtml/db/migrate/20091016135820_reverse_card_transaction_relationship.rb +11 -0
  173. data/app_generators/rtml/templates/rtml/db/migrate/20100127115105_convert_rtml_migrations_to_rails_migrations.rb +31 -0
  174. data/app_generators/rtml/templates/rtml/generators/rtml_controller/USAGE +25 -0
  175. data/app_generators/rtml/templates/rtml/generators/rtml_controller/rtml_controller_generator.rb +49 -0
  176. data/app_generators/rtml/templates/rtml/generators/rtml_controller/templates/common_tml_helper.rb +20 -0
  177. data/app_generators/rtml/templates/rtml/generators/rtml_controller/templates/controller.rb +3 -0
  178. data/app_generators/rtml/templates/rtml/generators/rtml_controller/templates/css_color.css +37 -0
  179. data/app_generators/rtml/templates/rtml/generators/rtml_controller/templates/css_mono.css +12 -0
  180. data/app_generators/rtml/templates/rtml/generators/rtml_controller/templates/functional_test.rb +11 -0
  181. data/app_generators/rtml/templates/rtml/generators/rtml_controller/templates/helper.rb +2 -0
  182. data/app_generators/rtml/templates/rtml/generators/rtml_controller/templates/layout_color.rtml.erb +24 -0
  183. data/app_generators/rtml/templates/rtml/generators/rtml_controller/templates/layout_mono.rtml.erb +3 -0
  184. data/app_generators/rtml/templates/rtml/generators/rtml_controller/templates/tml_helper.rb +16 -0
  185. data/app_generators/rtml/templates/rtml/generators/rtml_controller/templates/view.html.erb +15 -0
  186. data/app_generators/rtml/templates/rtml/generators/rtml_controller/templates/view.rtml.erb +2 -0
  187. data/app_generators/rtml/templates/rtml/generators/rtml_document/USAGE +8 -0
  188. data/app_generators/rtml/templates/rtml/generators/rtml_document/rtml_document_generator.rb +45 -0
  189. data/app_generators/rtml/templates/rtml/generators/rtml_document/templates/controller.rb +7 -0
  190. data/app_generators/rtml/templates/rtml/generators/rtml_document/templates/functional_test.rb +10 -0
  191. data/app_generators/rtml/templates/rtml/generators/rtml_document/templates/helper.rb +2 -0
  192. data/app_generators/rtml/templates/rtml/generators/rtml_document/templates/view.rtml.erb +11 -0
  193. data/app_generators/rtml/templates/rtml/generators/rtml_widget/USAGE +8 -0
  194. data/app_generators/rtml/templates/rtml/generators/rtml_widget/rtml_widget_generator.rb +66 -0
  195. data/app_generators/rtml/templates/rtml/generators/rtml_widget/templates/basic_widget.rb +57 -0
  196. data/app_generators/rtml/templates/rtml/generators/rtml_widget/templates/basic_widget_no_help.rb +27 -0
  197. data/app_generators/rtml/templates/rtml/init.rb +40 -0
  198. data/app_generators/rtml/templates/rtml/install.rb +18 -0
  199. data/app_generators/rtml/templates/rtml/lib/environment.rb +61 -0
  200. data/app_generators/rtml/templates/rtml/lib/extensions/action_controller/request.rb +9 -0
  201. data/app_generators/rtml/templates/rtml/lib/extensions/action_controller/routing/route_set.rb +34 -0
  202. data/app_generators/rtml/templates/rtml/lib/extensions/action_view/base.rb +74 -0
  203. data/app_generators/rtml/templates/rtml/lib/extensions/action_view/partial_template.rb +24 -0
  204. data/app_generators/rtml/templates/rtml/lib/extensions/active_record.rb +13 -0
  205. data/app_generators/rtml/templates/rtml/lib/extensions/active_support/dependencies.rb +25 -0
  206. data/app_generators/rtml/templates/rtml/lib/extensions/array.rb +15 -0
  207. data/app_generators/rtml/templates/rtml/lib/extensions/attr_boolean.rb +10 -0
  208. data/app_generators/rtml/templates/rtml/lib/extensions/hash.rb +28 -0
  209. data/app_generators/rtml/templates/rtml/lib/extensions/nil_class.rb +20 -0
  210. data/app_generators/rtml/templates/rtml/lib/extensions/rake.rb +19 -0
  211. data/app_generators/rtml/templates/rtml/lib/extensions/regexp.rb +16 -0
  212. data/app_generators/rtml/templates/rtml/lib/extensions/string.rb +37 -0
  213. data/app_generators/rtml/templates/rtml/lib/other_plugins.rb +23 -0
  214. data/app_generators/rtml/templates/rtml/lib/other_plugins/before_render/MIT-LICENSE +20 -0
  215. data/app_generators/rtml/templates/rtml/lib/other_plugins/before_render/README +36 -0
  216. data/app_generators/rtml/templates/rtml/lib/other_plugins/before_render/Rakefile +44 -0
  217. data/app_generators/rtml/templates/rtml/lib/other_plugins/before_render/init.rb +25 -0
  218. data/app_generators/rtml/templates/rtml/lib/other_plugins/before_render/lib/action_controller/filters/before_render_filter.rb +30 -0
  219. data/app_generators/rtml/templates/rtml/lib/other_plugins/before_render/lib/before_render.rb +43 -0
  220. data/app_generators/rtml/templates/rtml/lib/other_plugins/before_render/lib/before_render_instance.rb +45 -0
  221. data/app_generators/rtml/templates/rtml/lib/other_plugins/before_render/lib/filter_chain_has_many_types_of_filters.rb +87 -0
  222. data/app_generators/rtml/templates/rtml/lib/other_plugins/before_render/lib/filter_has_before_render.rb +26 -0
  223. data/app_generators/rtml/templates/rtml/lib/other_plugins/before_render/tasks/before_render_tasks.rake +25 -0
  224. data/app_generators/rtml/templates/rtml/lib/other_plugins/before_render/test/before_render_test.rb +29 -0
  225. data/app_generators/rtml/templates/rtml/lib/other_plugins/before_render/test/test_helper.rb +24 -0
  226. data/app_generators/rtml/templates/rtml/lib/rtml.rb +77 -0
  227. data/app_generators/rtml/templates/rtml/lib/rtml/beryl/constants.rb +12 -0
  228. data/app_generators/rtml/templates/rtml/lib/rtml/beryl/version.rb +11 -0
  229. data/app_generators/rtml/templates/rtml/lib/rtml/common/renderable.rb +13 -0
  230. data/app_generators/rtml/templates/rtml/lib/rtml/core/include.rb +30 -0
  231. data/app_generators/rtml/templates/rtml/lib/rtml/core/layout.rb +59 -0
  232. data/app_generators/rtml/templates/rtml/lib/rtml/core/next.rb +188 -0
  233. data/app_generators/rtml/templates/rtml/lib/rtml/core/screen.rb +91 -0
  234. data/app_generators/rtml/templates/rtml/lib/rtml/core/screen/iterators.rb +63 -0
  235. data/app_generators/rtml/templates/rtml/lib/rtml/core/screen/next_screen_methods.rb +70 -0
  236. data/app_generators/rtml/templates/rtml/lib/rtml/core/screen/variable_methods.rb +73 -0
  237. data/app_generators/rtml/templates/rtml/lib/rtml/core/support/importer.rb +55 -0
  238. data/app_generators/rtml/templates/rtml/lib/rtml/core/tml_document.rb +318 -0
  239. data/app_generators/rtml/templates/rtml/lib/rtml/core/tml_document/screen_methods.rb +79 -0
  240. data/app_generators/rtml/templates/rtml/lib/rtml/core/tml_document/variable_methods.rb +83 -0
  241. data/app_generators/rtml/templates/rtml/lib/rtml/core/variable.rb +123 -0
  242. data/app_generators/rtml/templates/rtml/lib/rtml/debug/browser_emulator.rb +59 -0
  243. data/app_generators/rtml/templates/rtml/lib/rtml/debug/rtml_controller_test_case.rb +7 -0
  244. data/app_generators/rtml/templates/rtml/lib/rtml/debug/rtml_core_unit_test.rb +11 -0
  245. data/app_generators/rtml/templates/rtml/lib/rtml/debug/unit_test.rb +3 -0
  246. data/app_generators/rtml/templates/rtml/lib/rtml/delegation.rb +8 -0
  247. data/app_generators/rtml/templates/rtml/lib/rtml/doc.rb +12 -0
  248. data/app_generators/rtml/templates/rtml/lib/rtml/element.rb +75 -0
  249. data/app_generators/rtml/templates/rtml/lib/rtml/errors/widget_accessor_failure.rb +9 -0
  250. data/app_generators/rtml/templates/rtml/lib/rtml/events/event_handler.rb +79 -0
  251. data/app_generators/rtml/templates/rtml/lib/rtml/events/event_processor.rb +106 -0
  252. data/app_generators/rtml/templates/rtml/lib/rtml/events/processors.rb +10 -0
  253. data/app_generators/rtml/templates/rtml/lib/rtml/events/processors/defaults_processor.rb +18 -0
  254. data/app_generators/rtml/templates/rtml/lib/rtml/events/processors/key_processor.rb +21 -0
  255. data/app_generators/rtml/templates/rtml/lib/rtml/feature.rb +32 -0
  256. data/app_generators/rtml/templates/rtml/lib/rtml/feature_config.rb +195 -0
  257. data/app_generators/rtml/templates/rtml/lib/rtml/features.rb +18 -0
  258. data/app_generators/rtml/templates/rtml/lib/rtml/features/array_of_feature_instances.rb +17 -0
  259. data/app_generators/rtml/templates/rtml/lib/rtml/features/controller_class_methods.rb +30 -0
  260. data/app_generators/rtml/templates/rtml/lib/rtml/features/controller_instance_methods.rb +35 -0
  261. data/app_generators/rtml/templates/rtml/lib/rtml/helpers.rb +21 -0
  262. data/app_generators/rtml/templates/rtml/lib/rtml/helpers/controller_helpers.rb +59 -0
  263. data/app_generators/rtml/templates/rtml/lib/rtml/helpers/controller_helpers/menu_helpers.rb +193 -0
  264. data/app_generators/rtml/templates/rtml/lib/rtml/helpers/core_helpers/action_view_wrapper.rb +23 -0
  265. data/app_generators/rtml/templates/rtml/lib/rtml/helpers/core_helpers/event_helpers.rb +28 -0
  266. data/app_generators/rtml/templates/rtml/lib/rtml/helpers/core_helpers/layout_helpers.rb +47 -0
  267. data/app_generators/rtml/templates/rtml/lib/rtml/helpers/core_helpers/widget_support.rb +181 -0
  268. data/app_generators/rtml/templates/rtml/lib/rtml/helpers/core_helpers/widget_support/class_methods.rb +28 -0
  269. data/app_generators/rtml/templates/rtml/lib/rtml/helpers/core_helpers/yield_helpers.rb +33 -0
  270. data/app_generators/rtml/templates/rtml/lib/rtml/helpers/proxy_helpers/feature_helpers.rb +17 -0
  271. data/app_generators/rtml/templates/rtml/lib/rtml/helpers/render_helper.rb +71 -0
  272. data/app_generators/rtml/templates/rtml/lib/rtml/helpers/terminal_helpers.rb +21 -0
  273. data/app_generators/rtml/templates/rtml/lib/rtml/helpers/test_helpers.rb +6 -0
  274. data/app_generators/rtml/templates/rtml/lib/rtml/helpers/test_helpers/tml_validation_assertions.rb +10 -0
  275. data/app_generators/rtml/templates/rtml/lib/rtml/helpers/test_helpers/variable_assertions.rb +27 -0
  276. data/app_generators/rtml/templates/rtml/lib/rtml/helpers/view_helpers/form_helpers.rb +70 -0
  277. data/app_generators/rtml/templates/rtml/lib/rtml/helpers/view_helpers/rtml_form_builder.rb +174 -0
  278. data/app_generators/rtml/templates/rtml/lib/rtml/oe/btmlpa_constants.rb +48 -0
  279. data/app_generators/rtml/templates/rtml/lib/rtml/proxying/method_missing_methods.rb +14 -0
  280. data/app_generators/rtml/templates/rtml/lib/rtml/proxying/rtml_interface.rb +33 -0
  281. data/app_generators/rtml/templates/rtml/lib/rtml/proxying/sandbox.rb +18 -0
  282. data/app_generators/rtml/templates/rtml/lib/rtml/text_utils.rb +51 -0
  283. data/app_generators/rtml/templates/rtml/lib/rtml/tml_param_parser.rb +95 -0
  284. data/app_generators/rtml/templates/rtml/lib/rtml/validation/dom_rule_parser.rb +61 -0
  285. data/app_generators/rtml/templates/rtml/lib/rtml/validation/dom_tag.rb +52 -0
  286. data/app_generators/rtml/templates/rtml/lib/rtml/validation/predefined_variable_rule_parser.rb +97 -0
  287. data/app_generators/rtml/templates/rtml/lib/rtml/validation/tml_validator.rb +16 -0
  288. data/app_generators/rtml/templates/rtml/lib/rtml/version.rb +11 -0
  289. data/app_generators/rtml/templates/rtml/lib/rtml/widgets/property.rb +11 -0
  290. data/app_generators/rtml/templates/rtml/lib/rtml/widgets/property_accessors.rb +59 -0
  291. data/app_generators/rtml/templates/rtml/lib/rtml/widgets/widget.rb +251 -0
  292. data/app_generators/rtml/templates/rtml/lib/rtml/widgets/widget_class_methods.rb +213 -0
  293. data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/dot.gif +0 -0
  294. data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_can.gif +0 -0
  295. data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_cand.gif +0 -0
  296. data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_en.gif +0 -0
  297. data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_end.gif +0 -0
  298. data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_i.gif +0 -0
  299. data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_icd.gif +0 -0
  300. data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_icl.gif +0 -0
  301. data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_icr.gif +0 -0
  302. data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_ics.gif +0 -0
  303. data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_icsw.gif +0 -0
  304. data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_icv.gif +0 -0
  305. data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_int.gif +0 -0
  306. data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_int2.gif +0 -0
  307. data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_men.gif +0 -0
  308. data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_mend.gif +0 -0
  309. data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_next.gif +0 -0
  310. data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_no.gif +0 -0
  311. data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_nod.gif +0 -0
  312. data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_ok.gif +0 -0
  313. data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_okd.gif +0 -0
  314. data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_pic1.gif +0 -0
  315. data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_pic2.gif +0 -0
  316. data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_pic3.gif +0 -0
  317. data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_pic4.gif +0 -0
  318. data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_top.gif +0 -0
  319. data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_txn.gif +0 -0
  320. data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_yes.gif +0 -0
  321. data/app_generators/rtml/templates/rtml/public/images/rtml/oe/btmlpa/nbg_yesd.gif +0 -0
  322. data/app_generators/rtml/templates/rtml/public/images/rtml/oe/examples/btmlpa.gif +0 -0
  323. data/app_generators/rtml/templates/rtml/public/images/rtml/oe/examples/can_dn.gif +0 -0
  324. data/app_generators/rtml/templates/rtml/public/images/rtml/oe/examples/can_up.gif +0 -0
  325. data/app_generators/rtml/templates/rtml/public/images/rtml/oe/examples/conf.gif +0 -0
  326. data/app_generators/rtml/templates/rtml/public/images/rtml/oe/examples/iccemv.gif +0 -0
  327. data/app_generators/rtml/templates/rtml/public/images/rtml/oe/examples/images.lib +0 -0
  328. data/app_generators/rtml/templates/rtml/public/images/rtml/oe/examples/magcard.gif +0 -0
  329. data/app_generators/rtml/templates/rtml/public/images/rtml/oe/examples/no_dn.gif +0 -0
  330. data/app_generators/rtml/templates/rtml/public/images/rtml/oe/examples/no_up.gif +0 -0
  331. data/app_generators/rtml/templates/rtml/public/images/rtml/oe/examples/ok_dn.gif +0 -0
  332. data/app_generators/rtml/templates/rtml/public/images/rtml/oe/examples/ok_up.gif +0 -0
  333. data/app_generators/rtml/templates/rtml/public/images/rtml/oe/examples/top.gif +0 -0
  334. data/app_generators/rtml/templates/rtml/public/images/rtml/oe/examples/yes_dn.gif +0 -0
  335. data/app_generators/rtml/templates/rtml/public/images/rtml/oe/examples/yes_up.gif +0 -0
  336. data/app_generators/rtml/templates/rtml/public/stylesheets/rtml/beryl_color.css +37 -0
  337. data/app_generators/rtml/templates/rtml/public/stylesheets/rtml/beryl_mono.css +17 -0
  338. data/app_generators/rtml/templates/rtml/public/stylesheets/rtml/charts.css +0 -0
  339. data/app_generators/rtml/templates/rtml/public/stylesheets/rtml/oe/btmlpa/i5100.css +12 -0
  340. data/app_generators/rtml/templates/rtml/public/stylesheets/rtml/oe/btmlpa/i8550.css +37 -0
  341. data/app_generators/rtml/templates/rtml/public/stylesheets/rtml/oe/btmlpa/receipt.css +4 -0
  342. data/app_generators/rtml/templates/rtml/public/stylesheets/rtml/oe/examples/i5100.css +12 -0
  343. data/app_generators/rtml/templates/rtml/public/stylesheets/rtml/oe/examples/i8550.css +37 -0
  344. data/app_generators/rtml/templates/rtml/reporting/110409 +227 -0
  345. data/app_generators/rtml/templates/rtml/reporting/linecount.rb +42 -0
  346. data/app_generators/rtml/templates/rtml/rules/predefined_tml_variables.rb +63 -0
  347. data/app_generators/rtml/templates/rtml/rules/tml_document_structure.rb +84 -0
  348. data/app_generators/rtml/templates/rtml/rules/varns/audio.rb +30 -0
  349. data/app_generators/rtml/templates/rtml/rules/varns/card.rb +17 -0
  350. data/app_generators/rtml/templates/rtml/rules/varns/card/emv.rb +31 -0
  351. data/app_generators/rtml/templates/rtml/rules/varns/card/mag.rb +8 -0
  352. data/app_generators/rtml/templates/rtml/rules/varns/card/parser.rb +7 -0
  353. data/app_generators/rtml/templates/rtml/rules/varns/card/pin.rb +6 -0
  354. data/app_generators/rtml/templates/rtml/rules/varns/cfgm.rb +15 -0
  355. data/app_generators/rtml/templates/rtml/rules/varns/com.rb +9 -0
  356. data/app_generators/rtml/templates/rtml/rules/varns/err.rb +14 -0
  357. data/app_generators/rtml/templates/rtml/rules/varns/gma/event.rb +13 -0
  358. data/app_generators/rtml/templates/rtml/rules/varns/gprs.rb +8 -0
  359. data/app_generators/rtml/templates/rtml/rules/varns/imager.rb +8 -0
  360. data/app_generators/rtml/templates/rtml/rules/varns/ip.rb +15 -0
  361. data/app_generators/rtml/templates/rtml/rules/varns/oebr.rb +42 -0
  362. data/app_generators/rtml/templates/rtml/rules/varns/oebr/3rdparty.rb +7 -0
  363. data/app_generators/rtml/templates/rtml/rules/varns/oebr/backlight.rb +4 -0
  364. data/app_generators/rtml/templates/rtml/rules/varns/oebr/cache.rb +1 -0
  365. data/app_generators/rtml/templates/rtml/rules/varns/oebr/connect.rb +5 -0
  366. data/app_generators/rtml/templates/rtml/rules/varns/oebr/connection.rb +5 -0
  367. data/app_generators/rtml/templates/rtml/rules/varns/oebr/offline.rb +5 -0
  368. data/app_generators/rtml/templates/rtml/rules/varns/oegw.rb +12 -0
  369. data/app_generators/rtml/templates/rtml/rules/varns/payment.rb +21 -0
  370. data/app_generators/rtml/templates/rtml/rules/varns/ppp.rb +11 -0
  371. data/app_generators/rtml/templates/rtml/rules/varns/terminal.rb +29 -0
  372. data/app_generators/rtml/templates/rtml/tasks/rtml_tasks.rake +78 -0
  373. data/app_generators/rtml/templates/rtml/template.rb +64 -0
  374. data/app_generators/rtml/templates/rtml/test/core/element_test.rb +17 -0
  375. data/app_generators/rtml/templates/rtml/test/core/screen_test.rb +91 -0
  376. data/app_generators/rtml/templates/rtml/test/core/tml_document_test.rb +53 -0
  377. data/app_generators/rtml/templates/rtml/test/functional/beryl_controller_test.rb +13 -0
  378. data/app_generators/rtml/templates/rtml/test/functional/btmlpa_controller_test.rb +13 -0
  379. data/app_generators/rtml/templates/rtml/test/functional/magcard_demo_controller_test.rb +20 -0
  380. data/app_generators/rtml/templates/rtml/test/functional/rtml_app_controller_test.rb +9 -0
  381. data/app_generators/rtml/templates/rtml/test/functional/rtml_routing_test.rb +19 -0
  382. data/app_generators/rtml/templates/rtml/test/functional/tml_controller_params_test.rb +20 -0
  383. data/app_generators/rtml/templates/rtml/test/rtml_test_helper.rb +44 -0
  384. data/app_generators/rtml/templates/rtml/test/validation/predefined_variable_rule_parser_test.rb +11 -0
  385. data/app_generators/rtml/templates/rtml/uninstall.rb +1 -0
  386. data/app_generators/rtml/templates/rtml/update.rb +57 -0
  387. data/bin/rtml +36 -0
  388. data/lib/rtml.rb +4 -0
  389. data/script/console +10 -0
  390. data/script/destroy +14 -0
  391. data/script/generate +14 -0
  392. data/tasks/reglob.rake +28 -0
  393. data/test/test_generator_helper.rb +29 -0
  394. data/test/test_helper.rb +3 -0
  395. data/test/test_rtml.rb +11 -0
  396. data/test/test_rtml_generator.rb +43 -0
  397. metadata +516 -0
@@ -0,0 +1,252 @@
1
+ class Rtml::RtmlAppController < Rtml::TmlAppController
2
+ include Rtml::Helpers::ControllerHelpers::MenuHelpers
3
+
4
+ prepend_before_filter :force_rtml, :only => :uml
5
+ before_render :render_tml
6
+ around_filter :process_action_with_view_paths
7
+ hide_action :rtml_interface, :tml_document, :rtml_document, :tml_document=, :rtml_document=
8
+
9
+ # For creating UML diagrams of TML screens for the given action. Must be in this same controller.
10
+ def uml
11
+ helper = response.template
12
+
13
+ include_view_paths_for params[:id]
14
+ self.rtml_interface.fire_action(params[:id], self)
15
+ @screens = tml_document.screens
16
+ url = []
17
+ @screens.each do |scr|
18
+ map = {}
19
+ left = nil
20
+ scr.every_possible_variant do |cond, dest|
21
+ left = helper.uml_for_screen(scr)
22
+ right = helper.uml_for_screen(@screens.find(dest) || helper.format_for_uml(dest))
23
+ if cond == :default and not map[right] then cond = ""
24
+ else
25
+ cond = unless cond =~ /key=/ then cond.to_s.gsub(/(^|\s)..=['"]([^'"]*)['"]/, '\1\2')
26
+ else cond.to_s.gsub(/['"]/, '').gsub(/key=/, 'on key ')
27
+ end
28
+ end
29
+ if map[right] then map[right] << " | #{cond}"
30
+ else map[right] = cond
31
+ end
32
+ end
33
+ # we use the map to merge multiple conditions in order to point to a destination only once
34
+ map.each { |right, cond| url << "[#{left}]-#{cond}>[#{right}]" }
35
+ end
36
+ tml_document.reset!
37
+
38
+ data = helper.get_uml_image_data(url)
39
+ send_data data, :disposition => 'inline', :type => 'image/png', :file_name => "#{params[:id]}.png"
40
+ end
41
+
42
+ def self.inherited(base) #:nodoc:
43
+ super
44
+ # TODO: It may be important to leave base.controller_path in the view paths in order to
45
+ # handle overriding the tml_app views. Need to figure out if this is necessary or not.
46
+ # base.append_view_path(File.join("vendor", "plugins", "rtml", "app/views", base.controller_path))
47
+ base.send :include, "#{base.controller_path}_tml_helpers".camelize.constantize rescue nil
48
+ end
49
+
50
+ def self.rtml_interface #:nodoc:
51
+ if self.superclass.respond_to? :rtml_interface
52
+ @rtml_interface ||= Class.new(self.superclass.rtml_interface.class).new
53
+ else
54
+ @rtml_interface ||= Class.new(Rtml::Proxying::RtmlInterface).new
55
+ end
56
+ @rtml_interface
57
+ end
58
+
59
+ def self.add_rtml_actions(*actions) #:nodoc:
60
+ actions.flatten.each do |action|
61
+ raise ArgumentError.new("Action must be Symbol or String") unless action.kind_of? Symbol or action.kind_of? String
62
+ line = __LINE__ + 1
63
+ eval %Q`
64
+ def #{action}
65
+ set_rtml unless template_exists?(default_template_name)
66
+ if request.format == :rtml
67
+ self.rtml_interface.fire_action(#{action.inspect}, self)
68
+ end
69
+ end
70
+ `, binding, __FILE__, line
71
+ end
72
+ end
73
+
74
+ def rtml_interface #:nodoc:
75
+ self.class.rtml_interface
76
+ end
77
+
78
+ # Returns the TML document that is being constructed for this request.
79
+ def tml_document
80
+ @tml_document ||= Rtml::Core::TMLDocument.new(response.template)
81
+ end
82
+
83
+ # Overwrites the TML document, if any, with the specified target.
84
+ # The specified target document becomes the "active" target, and will
85
+ # be rendered in place of this one.
86
+ def tml_document=(target)
87
+ @tml_document = target
88
+ end
89
+
90
+ alias rtml_document= tml_document=
91
+ alias rtml_document tml_document
92
+
93
+ protected
94
+ include Rtml
95
+ include Rtml::Core
96
+ extend Rtml::TmlAppHelper
97
+ extend Rtml::Helpers::ControllerHelpers
98
+
99
+ # Adds the specified action's view paths to this action's view paths,
100
+ # which would allow you to render views and partials from the specified
101
+ # action. Note that if two actions specify the same view, the view path
102
+ # that is encountered first takes precedence. (This should be the current
103
+ # action, which is ideal, BUT it's Rails core functionality that I'm not
104
+ # going to vouch for. Basically, keep the names unique or use at your own
105
+ # risk.)
106
+ def include_view_paths_for(action)
107
+ add_instance_view_paths(action)
108
+ end
109
+
110
+ # Used for modifying the template files to be found in
111
+ # controller/action/screen_name.erb (instead of the Rails default
112
+ # controller/action.erb).
113
+ def default_template_name(action_name = self.action_name,
114
+ ext = response.template.template_format,
115
+ klass = self.class) #:nodoc:
116
+ s = super
117
+ return s if s
118
+ if action_name =~ /\//
119
+ return s
120
+ else
121
+ return super("#{params[:action]}/#{action_name}", ext, klass)
122
+ end
123
+ end
124
+
125
+ # We need the default rescue_action functionality, but we first
126
+ # need to reset the TML document that's being generated, or else
127
+ # we'll end up with a TML document that half represents what the
128
+ # user was constructing, half represents the error being reported,
129
+ # and is completely invalid TML!
130
+ def rescue_action(*a)
131
+ tml_document.reset!
132
+ super
133
+ end
134
+
135
+
136
+ private
137
+ # Adds default action-specific view paths to this controller, then
138
+ # calls the action, and finally removes the view paths.
139
+ def process_action_with_view_paths
140
+ include_view_paths_for params[:action]
141
+ yield
142
+ remove_instance_view_paths
143
+ end
144
+
145
+ # Adds all registered view paths for the specified action to the
146
+ # controller for this action. This is called by the around_filter
147
+ # before the action is called.
148
+ def add_instance_view_paths(action)
149
+ controller = self
150
+ @paths_to_delete = []
151
+ (controller.class.view_paths_for_actions.select do |a|
152
+ a[0].to_s.length == 0 || a[0].to_s == action.to_s
153
+ end).each do |a|
154
+ path = a[1]
155
+ add_instance_view_path path
156
+ end
157
+ end
158
+
159
+ # Adds the specified view path to the controller's view paths
160
+ # and also adds it to the list of paths to be deleted at the end
161
+ # of this action (so that they are not permanent in production).
162
+ def add_instance_view_path(path)
163
+ unless controller.class.view_paths.include? path
164
+ @paths_to_delete << path
165
+ controller.prepend_view_path path
166
+ end
167
+ end
168
+
169
+ # Removes all view paths that were not a part of the action-unspecific
170
+ # (global) array for this controller. This is called by the around_filter
171
+ # after content has been rendered.
172
+ def remove_instance_view_paths
173
+ controller = self
174
+ @paths_to_delete.each do |path|
175
+ controller.view_paths.delete path
176
+ end
177
+ end
178
+
179
+ def render_tml
180
+ headers_filter
181
+ return unless tml_document.modified? and not performed? and response.redirected_to.nil?
182
+
183
+ # The reason I don't check against request.format here is because I want to handle things like respond_to,
184
+ # which might look something like
185
+ # respond_to do |format|
186
+ # format.rtml
187
+ # format.html
188
+ # format.json { render :json => obj.to_json }
189
+ # format.xml { render :xml => obj.to_xml }
190
+ # end
191
+ #
192
+ # respond_to does not set request.format; it sets response.template.template_format. So that's what I need
193
+ # to check. Note that pretty much everywhere else, request.format should be checked, because pretty much
194
+ # everywhere else we want to know what the client is ASKING for.
195
+ #
196
+ if response.template.template_format == :rtml
197
+ tml = tml_document.to_tml
198
+ ### HACK!
199
+ # Having problems with the browser restarting the app when the visiting the full link with an anchor.
200
+ # Strange, it only happens once. But this should work around it.
201
+ tml.gsub!(/(["'])#{Regexp::escape url_for(:action => params[:action], :only_path => true)}\#/, '\1#')
202
+ logger.debug tml if self.class.rtml_debug_config[:dump_tml]
203
+ render_without_before_render_filter :text => tml
204
+ end
205
+ end
206
+
207
+ # Another method for forcing the user into an RTML format. See Rtml::TmlAppController#force_format
208
+ # and use with care. What this does, essentially, is check to see whether there are any RTML
209
+ # templates available, and if so, forces the user into RTML format. Only used in very rare
210
+ # circumstances, obviously, because this will ignore things like what browser is actually
211
+ # requesting the document. If you call this method, and the user is using Firefox or IE,
212
+ # tough luck: an RTML template exists, you've told RTML to use it unconditionally.
213
+ # No effect if no RTML ERB template exists. So for instance, if you are building a TML document
214
+ # via the tml_helpers, none of the above will happen.
215
+ def set_rtml
216
+ if self.class.action_methods.include? params[:action]
217
+ unless template_exists? default_template_name(params[:action]) and not tml_document.screen_defined? params[:action]
218
+ force_format :rtml
219
+ end
220
+ end
221
+ end
222
+
223
+ def force_rtml #:nodoc:
224
+ force_format :rtml
225
+ end
226
+
227
+ # Declare the specified action to require the specified path. This is used
228
+ # in the around_filter when constructing the default view paths for an action.
229
+ #
230
+ # If action is nil, this path will be added to all actions. (This may be useful
231
+ # if you want to add a view path to all instances of this controller without
232
+ # affecting the view paths of any other controllers.)
233
+ def self.append_view_path_for_action(action, path)
234
+ view_paths_for_actions << [ action.to_s, path ]
235
+ end
236
+
237
+ # Return the array of default paths. First argument is action name; second
238
+ # argument is the path itself.
239
+ def self.view_paths_for_actions
240
+ if @view_paths_for_actions.nil?
241
+ if self.superclass.respond_to? :view_paths_for_actions
242
+ @view_paths_for_actions = self.superclass.view_paths_for_actions.collect { |arr| arr.dup }
243
+ else
244
+ @view_paths_for_actions = []
245
+ end
246
+ end
247
+ @view_paths_for_actions
248
+ end
249
+
250
+ public
251
+ tml_helper :all
252
+ end
@@ -0,0 +1,418 @@
1
+ module Rtml
2
+ class TmlAppController < ApplicationController
3
+ include Rtml::Helpers::RenderHelper
4
+ include Rtml::Helpers::TerminalHelpers
5
+
6
+ #It's sad, but we have to skip the authenticity token, because OEGW doesn't support cookies
7
+ # and therefore has no clue what a Session object is. The Session is used to make sure
8
+ # authenticity tokens are valid and to generate new ones -- so what happens is, since
9
+ # the terminal doesn't maintain a session cookie, every request is considered a new "session"
10
+ # and the previous "session" token is invalidated. So POST data can't be processed because
11
+ # Rails thinks it's all fake! Until OpenEstate supports session cookies, it has to be disabled.
12
+ # FIXME: When session cookies are supported, re-enable authenticity verification. Or override
13
+ # Rails authenticity checking with something a little more TML-friendly...
14
+ skip_before_filter :verify_authenticity_token
15
+
16
+ before_filter :format_filter
17
+ #before_filter :headers_filter
18
+ before_filter :load_state
19
+
20
+ hide_action :embedded_app, :url_for
21
+
22
+ # 080609:
23
+ # save_state changed to a before_render filter because the user is more likely to change it
24
+ # in the TML helper than they are in the View, and after much research I had to take sides
25
+ # (RTML documents do a lot of render_or_redirect-ing, which halts the filter chain).
26
+ before_render :save_state
27
+ #after_filter :save_state
28
+
29
+ append_view_path File.join(PLUGIN_BASE, "app", "views", "rtml", "tml_app")
30
+
31
+ # Action reserved for retrieving TML state data. See
32
+ # app/views/rtml/tml_app/get_terminal_info.rtml.erb for customization.
33
+ # You can also override this view within your controller's views, if needed.
34
+ #
35
+ # Note that this file should be either a straight TML template (using ERB of course)
36
+ # or "document-level" RTML (essentially breaking the MVC rules and running the TML
37
+ # generation in the View). If you don't know what any of that means, then don't touch it.
38
+ def get_terminal_info
39
+ end
40
+
41
+ # Action reserved for redirect_to directives. This functionality will be removed
42
+ # when Incendo supports HTTP redirects, but until then, the only way to do it
43
+ # is in the terminal-side TML. See app/views/rtml/tml_app/do_tml_redirect.rtml.erb
44
+ # for customization.
45
+ # You can also override this view within your controller's views, if needed.
46
+ #
47
+ # Note that this file should be either a straight TML template (using ERB of course)
48
+ # or "document-level" RTML (essentially breaking the MVC rules and running the TML
49
+ # generation in the View). If you don't know what any of that means, then don't touch it.
50
+ def do_tml_redirect
51
+ end
52
+
53
+ def url_for(options = {})
54
+ super(options.reverse_merge(:format => params[:format]))
55
+ end
56
+
57
+ class << self
58
+ # Allows you to provide an expiration timeout. This must be done with a block so that it
59
+ # can be evaluated only when the expiration headers are being sent.
60
+ #
61
+ # Example:
62
+ # expires_at { 7.days.from_now }
63
+ # expires_at { |controller| controller.current_user.id == 1 ? Time.now : 3.days.from_now }
64
+ #
65
+ def expires_at(&block)
66
+ @expires_at_block = block if block_given?
67
+ return @expires_at_block
68
+ end
69
+ public :expires_at
70
+ end
71
+
72
+ # Allows you to provide an expiration timeout. This must be done with a block so that it
73
+ # can be evaluated only when the expiration headers are being sent.
74
+ #
75
+ # Example:
76
+ # expires_at { 7.days.from_now }
77
+ # expires_at { |controller| controller.current_user.id == 1 ? Time.now : 3.days.from_now }
78
+ #
79
+ def expires_at(&block)
80
+ @expires_at_block ||= self.class.expires_at
81
+ @expires_at_block = block if block_given?
82
+ return @expires_at_block
83
+ end
84
+
85
+ protected
86
+ # Overrides the set of defaults for when a Web browser (as opposed to a terminal browser)
87
+ # connects and requests this RTML resource.
88
+ #
89
+ # Example:
90
+ # class MyAppController < Rtml::RtmlAppController
91
+ # rtml_debug do |config|
92
+ # config[:model] = 5100
93
+ # end
94
+ # end
95
+ #
96
+ def self.rtml_debug(&blk)
97
+ yield self.rtml_debug_config
98
+ end
99
+
100
+ # Returns the hash of RTML debug options, for use when a Web browser (and not a terminal
101
+ # browser) requests this RTML resource.
102
+ def self.rtml_debug_config
103
+ @rtml_debug_config ||= HashWithIndifferentAccess.new({
104
+ :datetime_start => Date.parse('2006/01/01'),
105
+ :os => '03.27',
106
+ :itid => '111111111',
107
+ :model => 8550,
108
+ :datetime => Time.now,
109
+ :part_number => 'I8550_BROWSER',
110
+ :dump_tml => false
111
+ })
112
+ end
113
+
114
+ # Provides a tml_redirect method because Incendo won't understand the "Location"
115
+ # header that redirect_to produces. (Groupe has agreed to implement this missing
116
+ # functionality in an upcoming release.) This new redirect_to method will render the
117
+ # do_tml_redirect action instead, which results in a TML-based redirect.
118
+ # This is only done for the MicroBrowser. Any other browser gets the standard
119
+ # Rails functionality unless it passed in the .rtml extension to this request.
120
+ def redirect_to(a,&b)
121
+ if request.is_terminal? or params[:format] == 'rtml'
122
+ if a.kind_of? Hash
123
+ @redirect_to = url_for(a.merge(:only_path => true))
124
+ else
125
+ @redirect_to = url_for(:action => a)
126
+ end
127
+ render :action => 'do_tml_redirect'
128
+ else
129
+ super
130
+ end
131
+ end
132
+
133
+ # Forces the user to use the specified format, regardless of what was requested by the
134
+ # browser or detected by RTML. You should be very careful with this, because it can have
135
+ # unintended consequences such as feeding TML to a browser expecting HTML. In fact, it's
136
+ # generally better to leave the format handling for the RTML Core to worry about. You
137
+ # have been warned.
138
+ def force_format(fmt)
139
+ fmt = params[:format] || 'html' if fmt.nil?
140
+ request.format = fmt
141
+ format_filter
142
+ #headers_filter
143
+ end
144
+
145
+ # Allows you to toggle whether or not form data sent from a terminal via TMLPOST data should
146
+ # be available directly via the params object, or whether it should be isolated in params[:tml].
147
+ # For example, the "user_name" parameter would be stored in params[:user_name] if collect_params
148
+ # is false, or params[:tml][:user_name] if collect_params is true. By default, params are
149
+ # stored directly in the params hash (in other words, the default is "false") -- but if you
150
+ # call this method with no arguments, it will be set to TRUE.
151
+ #
152
+ # Example:
153
+ # class MyTmlController < Rtml::TmlAppController
154
+ # collect_params # => true
155
+ # collect_params false
156
+ # collect_params true
157
+ # . . .
158
+ # end
159
+ def self.collect_params(tf = true)
160
+ self.class_eval { def collect_params?; tf; end }
161
+ end
162
+
163
+ # Returns the terminal state hash. Raises an error if the state is not available (but this
164
+ # shouldn't happen unless you forgot to run rake rtml:setup). Note that you only need to run
165
+ # rake rtml:setup if you plan to actually make use of the state hash.
166
+ def state
167
+ @terminal_state.nil? ? (raise "State not available; run rake rtml:setup to enable it") :
168
+ @terminal_state#.state
169
+ end
170
+
171
+ # If true, TML params will be segregated into params[:tml]
172
+ # If false, default functionality is assumed, and params will be stored directly within the
173
+ # params hash. While you can override this if you wish, you're probably better off using
174
+ # the #collect_params method within your controller.
175
+ def collect_params?(); false; end
176
+
177
+ # This method is responsible for making view inheritance possible.
178
+ def default_template_name(action_name = self.action_name,
179
+ ext = response.template.template_format,
180
+ klass = self.class) #:nodoc:
181
+ if action_name && klass == self.class
182
+ action_name = action_name.to_s
183
+ if action_name.include?('/') && template_path_includes_controller?(action_name)
184
+ action_name = strip_out_controller(action_name)
185
+ end
186
+ end
187
+ if !klass.superclass.method_defined?(:controller_path)
188
+ return "#{self.controller_path}/#{action_name}"
189
+ end
190
+ template_name = "#{klass.controller_path}/#{action_name}"
191
+ if template_exists? template_name, ext
192
+ return template_name
193
+ else
194
+ return default_template_name(action_name, ext, klass.superclass)
195
+ end
196
+ end
197
+
198
+ # Checks to see if a template with the specified name and optional format exists.
199
+ unless ActionController::Base.private_instance_methods.include? 'template_exists?'
200
+ def template_exists?(template_name, fmt = response.template.template_format) #:nodoc:
201
+ self.view_paths.find_template(template_name, fmt)
202
+ rescue ActionView::MissingTemplate, Errno::ENOENT
203
+ false
204
+ end
205
+ end
206
+
207
+ # If a catastrophic error would otherwise result in a 500 Internal Server Error
208
+ # and the application server is running in PRODUCTION mode,
209
+ # this method will be called instead, and the terminal user will instead see a
210
+ # pretty error message. It's something generic like "Contact an administrator",
211
+ # and it can be overridden by creating a "rescue_action_in_public.rtml.erb" file
212
+ # somewhere in your view path. You can find the original at
213
+ # app/views/rtml/tml_app/rescue_action_in_public.rtml.erb.
214
+ #
215
+ # Note that this file should be either a straight TML template (using ERB of course)
216
+ # or "document-level" RTML (essentially breaking the MVC rules and running the TML
217
+ # generation in the View).
218
+ def rescue_action_in_public(exception) #:nodoc:
219
+ if request.is_terminal? or params[:error_mode] == 'rtml'
220
+ @exception = exception
221
+ render :action => 'rescue_action_in_public'
222
+ else
223
+ super
224
+ end
225
+ end
226
+
227
+ # If a catastrophic error would otherwise result in a 500 Internal Server Error
228
+ # and the application server is running in DEVELOPMENT mode,
229
+ # this method will be called instead, and the terminal user will instead see a
230
+ # detailed error report like the default ones that Rails generates for your
231
+ # Web browser.
232
+ # If you need to tweak the message, it can be overridden by creating a
233
+ # "rescue_action_locally.rtml.erb" file
234
+ # somewhere in your view path. You can find the original at
235
+ # app/views/rtml/tml_app/rescue_action_locally.rtml.erb.
236
+ #
237
+ # Note that this file should be either a straight TML template (using ERB of course)
238
+ # or "document-level" RTML (essentially breaking the MVC rules and running the TML
239
+ # generation in the View).
240
+ def rescue_action_locally(exception) #:nodoc:
241
+ if request.is_terminal? or params[:error_mode] == 'rtml'
242
+ @exception = exception
243
+ #if self.respond_to? :rtml_interface and rtml_interface
244
+ #rtml_interface.instance_variable_set("@exception", exception)
245
+ #end
246
+ render :action => 'rescue_action_locally'
247
+ else
248
+ super
249
+ end
250
+ end
251
+
252
+
253
+ private
254
+ # If params[:format] is specified as 'tml', it is changed to 'rtml' and the method returns.
255
+ # If it is set to any
256
+ # other non-nil value, nothing happens. If it is nil, then the following happens:
257
+ # If a template of the requested format exists, the method returns as no further action is
258
+ # necessary. (The matching template will be rendered unless you intervene.)
259
+ # If the requested format is 'tml', or the client is a terminal, the format is forced to 'rtml'.
260
+ # If the client is not a terminal and the requested format is not 'tml', nothing happens.
261
+ #
262
+ # This method also defines a singleton method for the request object called is_terminal? which
263
+ # returns true if the client for this request is a terminal (as opposed to a browser). Note that
264
+ # the is_terminal? method always tells the "truth" -- even if the browser is emulating a terminal
265
+ # for this request, it will still return false for a browser.
266
+ def format_filter
267
+ def request.is_terminal?
268
+ self.user_agent and (self.user_agent['OE MicroBrowser'] || self.user_agent['IO Browser'])
269
+ end
270
+
271
+ params[:format] = 'rtml' if params[:format] == 'tml'
272
+ return if params[:format] # Client-specified formats trump anything automatically assigned
273
+ return if template_exists? default_template_name(action_name, request.format)
274
+
275
+ fmt = request.format#response.template.template_format.to_s
276
+ fmt = 'rtml' if fmt == 'tml' or request.is_terminal?
277
+ request.format = fmt
278
+ # response.template.template_format = fmt # params[:format] = fmt
279
+ end
280
+
281
+ # Sets the content-type to XML instead of TML for anything but OEGW. This makes it viewable
282
+ # in a user's browser as an XML document. Also rebuilds the ETag header to be compatible with
283
+ # OpenEstate/Incendo Online. (Default Rails ETags are 1 character too long. Painful debugging,
284
+ # that.)
285
+ def headers_filter
286
+ if [:rtml, :tml].include? request.format.to_sym
287
+ headers['content-type'] = 'text/xml' unless request.is_terminal?
288
+ headers['content-type'] = 'text/tml' if request.is_terminal?
289
+ headers['Cache-Control'] = 'no-cache ' # trailing space is important!
290
+ headers['ETag'] = "W/\"329-#{Time.now.to_i}#{rand(9999)}\" "
291
+ headers['Expires'] =
292
+ if expires_at
293
+ expires_at.call(self)
294
+ else
295
+ Time.at(0) # always expired
296
+ end.strftime("%a, %d %b %Y %H:%M:%S GMT")
297
+ end
298
+ end
299
+
300
+ # Loads the terminal's (or browser's) state hash from the database.
301
+ # TODO: Use Rails.cache for the state whenever possible.
302
+ def load_state
303
+ if params[:tml]
304
+ term_params = params[:tml][:terminal]
305
+ else
306
+ term_params = params[:terminal]
307
+ end
308
+ fail = false # if true, the get_terminal_info TML page will be rendered.
309
+ repost = false # if true, the terminal data is out of date and needs to be refreshed.
310
+
311
+ headers = request.headers
312
+ unless request.is_terminal?
313
+ # Build some fake data if the user is viewing with a browser, for debugging
314
+ # Otherwise, user would just always see get_terminal_info. Epic debugfail.
315
+ p = params[:browser] || {}
316
+ headers = Rtml::Debug::BrowserEmulator.new(headers.merge(self.class.rtml_debug_config.merge(p)))
317
+ repost = true # always use current browser details. This enables debug configuration override.
318
+ end
319
+
320
+ itid = headers['ITID'] || headers['HTTP_ITID']
321
+ itsn = headers['ITSN'] || headers['HTTP_ITSN']
322
+ itpn = headers['ITPN'] || headers['HTTP_ITPN']
323
+
324
+ if itid && itsn && itpn or not request.is_terminal?
325
+ signature = "#{itsn}:#{itpn}:#{itid}"
326
+ @terminal_state = Rtml::State.find_by_signature(signature)
327
+ if @terminal_state.nil?
328
+ logger.debug "Terminal state for signature '#{signature}' not found; creating"
329
+ @terminal_state = Rtml::State.new(:signature => signature,
330
+ :terminal => Terminal.new(:itid => itid))
331
+ @terminal_state.state ||= HashWithIndifferentAccess.new
332
+ logger.debug "Saving empty state"
333
+ @terminal_state.save!
334
+ end
335
+
336
+ if @terminal_state.state.empty?
337
+ logger.debug "Terminal state needs populated."
338
+ repost = true
339
+ elsif @terminal_state.created_at < 1.day.ago
340
+ logger.debug "Terminal state is outdated (#{@terminal_state.created_at} < #{1.day.ago}) and will be repopulated."
341
+ repost = true
342
+ end
343
+
344
+ if repost
345
+ p = term_params
346
+ p = headers if headers.kind_of? Rtml::Debug::BrowserEmulator
347
+
348
+ if p
349
+ logger.debug "Found terminal information in headers."
350
+ @terminal_state.state.merge! p
351
+ @terminal_state.state[:signature] = @terminal_state.signature
352
+ @terminal_state.created_at = Time.now
353
+ # State is saved as a part of the before_render filter.
354
+ # @terminal_state.save!
355
+
356
+ if term_params
357
+ # FIXME: First I need to remember what this was designed to do (dumb me and no comments),
358
+ # and then I need to make it work. Whatever it was, it was causing an infinite loop when
359
+ # redirect_to resulted in reposting state data.
360
+ #
361
+ #params.delete :terminal
362
+ #params[:tml].delete :terminal if params[:tml]
363
+ #redirect_to params
364
+ end
365
+ return true
366
+ else
367
+ logger.debug "Could not find terminal information in headers; triggering a data post"
368
+ logger.debug "term_params: #{term_params.inspect}"
369
+ logger.debug "params: #{params.inspect}"
370
+ fail = true
371
+ end
372
+ end
373
+ else
374
+ raise "Could not find TID header!" unless itid
375
+ raise "Could not find SN header!" unless itsn
376
+ raise "Could not find PN header!" unless itpn
377
+ raise "Unknown error -- something to do with the TID/SN/PN headers!"
378
+ end
379
+ return true unless fail
380
+
381
+ unless request.post? # don't want to interfere with POSTing
382
+ force_format :rtml
383
+ # FIXME: It may be preferable to use redirect_to instead of render
384
+ # because if the terminal hits an error in get_terminal_info (or
385
+ # more likely, after it posts the data get_terminal_info is asking
386
+ # for), the user is going to be somewhat confused by an error message
387
+ # blaming HIS action, not the get_terminal_info action.
388
+ # However, also need to be sure that when the user hits get_terminal_info,
389
+ # he'll be sent back to the current action.
390
+ #redirect_to :action => 'get_terminal_info'
391
+
392
+ render :action => 'get_terminal_info'
393
+ headers_filter
394
+ return false
395
+ end
396
+
397
+ # If we get an ActiveRecord error, it's probably because RTML state has not been initialized.
398
+ # Fail silently. Then, if the user tries to access state, they'll get the "rake first"
399
+ # error via the #rtml_state method (above).
400
+ rescue ActiveRecord::StatementInvalid
401
+ true
402
+ end
403
+
404
+ # Saves the terminal's (or browser's) state hash to the database.
405
+ # TODO: Use Rails.cache for the state (as opposed to the database) whenever possible.
406
+ def save_state
407
+ if @terminal_state
408
+ begin
409
+ @terminal_state.save
410
+ rescue #save_state
411
+ logger.error $!
412
+ logger.error $!.backtrace.join("\n\t")
413
+ end
414
+ end
415
+ true
416
+ end
417
+ end
418
+ end