controll 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (174) hide show
  1. data/README.md +253 -93
  2. data/Rakefile +1 -1
  3. data/VERSION +1 -1
  4. data/controll.gemspec +121 -84
  5. data/lib/controll/assistant/param_assistant.rb +23 -0
  6. data/lib/controll/assistant/session_assistant.rb +23 -0
  7. data/lib/controll/assistant.rb +9 -7
  8. data/lib/controll/commander.rb +16 -3
  9. data/lib/controll/enabler/macros.rb +75 -0
  10. data/lib/controll/enabler/maps.rb +15 -0
  11. data/lib/controll/enabler/notify.rb +43 -0
  12. data/lib/controll/enabler/path_handler.rb +49 -0
  13. data/lib/controll/enabler/path_resolver.rb +47 -0
  14. data/lib/controll/enabler.rb +49 -0
  15. data/lib/controll/engine.rb +9 -0
  16. data/lib/controll/errors.rb +4 -1
  17. data/lib/controll/event/helper.rb +20 -0
  18. data/lib/controll/{helper/event_matcher.rb → event/matcher.rb} +3 -3
  19. data/lib/controll/event.rb +60 -0
  20. data/lib/controll/events.rb +48 -0
  21. data/lib/controll/executor/base.rb +3 -7
  22. data/lib/controll/executor/controlled.rb +36 -0
  23. data/lib/controll/executor/delegator.rb +6 -0
  24. data/lib/controll/executor.rb +8 -1
  25. data/lib/controll/flow/action/base.rb +30 -0
  26. data/lib/controll/flow/action/fallback.rb +25 -0
  27. data/lib/controll/flow/action/path_action.rb +24 -0
  28. data/lib/controll/flow/action.rb +7 -0
  29. data/lib/controll/flow/action_mapper/base.rb +13 -0
  30. data/lib/controll/flow/action_mapper/complex.rb +52 -0
  31. data/lib/controll/flow/action_mapper/simple.rb +54 -0
  32. data/lib/controll/flow/action_mapper.rb +7 -0
  33. data/lib/controll/flow/errors.rb +16 -0
  34. data/lib/controll/flow/event_mapper/path_finder.rb +36 -0
  35. data/lib/controll/flow/event_mapper/util.rb +43 -0
  36. data/lib/controll/flow/event_mapper.rb +6 -0
  37. data/lib/controll/flow/master/executor.rb +57 -0
  38. data/lib/controll/flow/master/macros.rb +66 -0
  39. data/lib/controll/flow/master.rb +70 -0
  40. data/lib/controll/flow.rb +15 -0
  41. data/lib/controll/focused/enabler.rb +31 -0
  42. data/lib/controll/helper.rb +0 -94
  43. data/lib/controll/macros.rb +12 -0
  44. data/lib/controll/notify/base.rb +22 -43
  45. data/lib/controll/notify/flash.rb +3 -3
  46. data/lib/controll/notify/macros.rb +57 -0
  47. data/lib/controll/notify/message/handler.rb +36 -0
  48. data/lib/controll/notify/message/resolver.rb +28 -0
  49. data/lib/controll/notify/message/translator.rb +45 -0
  50. data/lib/controll/notify/message.rb +25 -0
  51. data/lib/controll/notify/typed.rb +13 -22
  52. data/lib/controll/notify.rb +11 -4
  53. data/lib/controll.rb +8 -2
  54. data/lib/generators/controll/assistant_generator.rb +27 -0
  55. data/lib/generators/controll/executor_generator.rb +23 -0
  56. data/lib/generators/controll/flow_handler_generator.rb +21 -0
  57. data/lib/generators/controll/notifier_generator.rb +21 -0
  58. data/lib/generators/controll/setup_generator.rb +37 -0
  59. data/lib/generators/controll/templates/assistant.tt +10 -0
  60. data/lib/generators/controll/templates/commander.tt +15 -0
  61. data/lib/generators/controll/templates/executor.tt +14 -0
  62. data/lib/generators/controll/templates/flow_handler.tt +26 -0
  63. data/lib/generators/controll/templates/notifier.tt +31 -0
  64. data/spec/acceptance/app_test.rb +1 -1
  65. data/spec/controll/assistant/param_assistant_spec.rb +31 -0
  66. data/spec/controll/assistant/session_assistant_spec.rb +31 -0
  67. data/spec/controll/assistant_spec.rb +26 -0
  68. data/spec/controll/command_spec.rb +4 -4
  69. data/spec/controll/enabler/macros_spec.rb +76 -0
  70. data/spec/controll/enabler/maps_spec.rb +31 -0
  71. data/spec/controll/{helper → enabler}/notify_spec.rb +7 -17
  72. data/spec/controll/enabler/path_handler_spec.rb +24 -0
  73. data/spec/controll/enabler/path_resolver_spec.rb +87 -0
  74. data/spec/controll/enabler_spec.rb +30 -0
  75. data/spec/controll/event/helper_spec.rb +33 -0
  76. data/spec/controll/{helper/event_matcher_spec.rb → event/matcher_spec.rb} +4 -3
  77. data/spec/controll/event_spec.rb +66 -0
  78. data/spec/controll/events_spec.rb +23 -0
  79. data/spec/controll/executor/controlled_spec.rb +36 -0
  80. data/spec/controll/executor/{notificator_spec.rb → delegator_spec.rb} +4 -4
  81. data/spec/controll/flow/action_mapper/complex_spec.rb +102 -0
  82. data/spec/controll/flow/action_mapper/fallback_spec.rb +34 -0
  83. data/spec/controll/{flow_handler/render_spec.rb → flow/action_mapper/simple_spec.rb} +25 -22
  84. data/spec/controll/{flow_handler/redirect/action_spec.rb → flow/event_mapper/path_finder_spec.rb} +10 -10
  85. data/spec/controll/{flow_handler/redirect/mapper_spec.rb → flow/event_mapper/util_spec.rb} +9 -9
  86. data/spec/controll/flow/master/executor_spec.rb +56 -0
  87. data/spec/{app/app/models/.gitkeep → controll/flow/master/macros_spec.rb} +0 -0
  88. data/spec/controll/flow/master_spec.rb +157 -0
  89. data/spec/controll/notify/base_spec.rb +6 -12
  90. data/spec/controll/notify/message/handler_spec.rb +27 -0
  91. data/spec/controll/notify/message/resolver_spec.rb +53 -0
  92. data/spec/controll/notify/message/translator_spec.rb +46 -0
  93. data/spec/controll/notify/message_spec.rb +4 -0
  94. data/spec/controll/notify/{message_handler.rb → services_notifier.rb} +3 -5
  95. data/spec/controll/notify/typed_spec.rb +2 -2
  96. data/spec/{app → controll_app}/.gitignore +0 -0
  97. data/spec/{app → controll_app}/Gemfile +0 -0
  98. data/spec/{app → controll_app}/Gemfile.lock +0 -0
  99. data/spec/{app → controll_app}/README.rdoc +0 -0
  100. data/spec/{app → controll_app}/Rakefile +0 -0
  101. data/spec/controll_app/app/controll/commanders/services_commander.rb +5 -0
  102. data/spec/controll_app/app/controll/executors/services_executor.rb +4 -0
  103. data/spec/controll_app/app/controll/flows/create_services.rb +9 -0
  104. data/spec/controll_app/app/controll/notifiers/services_notifier.rb +9 -0
  105. data/spec/{app → controll_app}/app/controllers/application_controller.rb +0 -1
  106. data/spec/controll_app/app/controllers/services_controller.rb +8 -0
  107. data/spec/{app/lib/assets → controll_app/app/models}/.gitkeep +0 -0
  108. data/spec/{app → controll_app}/app/models/post.rb +0 -0
  109. data/spec/{app → controll_app}/app/views/layouts/application.html.erb +0 -0
  110. data/spec/{app → controll_app}/app/views/posts/_form.html.erb +0 -0
  111. data/spec/{app → controll_app}/app/views/posts/edit.html.erb +0 -0
  112. data/spec/{app → controll_app}/app/views/posts/index.html.erb +0 -0
  113. data/spec/{app → controll_app}/app/views/posts/new.html.erb +0 -0
  114. data/spec/{app → controll_app}/app/views/posts/show.html.erb +0 -0
  115. data/spec/{app → controll_app}/config/application.rb +1 -1
  116. data/spec/{app → controll_app}/config/boot.rb +0 -0
  117. data/spec/{app → controll_app}/config/environment.rb +0 -0
  118. data/spec/{app → controll_app}/config/environments/development.rb +0 -0
  119. data/spec/{app → controll_app}/config/environments/test.rb +0 -0
  120. data/spec/{app → controll_app}/config/initializers/backtrace_silencers.rb +0 -0
  121. data/spec/{app → controll_app}/config/initializers/inflections.rb +0 -0
  122. data/spec/{app → controll_app}/config/initializers/mime_types.rb +0 -0
  123. data/spec/{app → controll_app}/config/initializers/secret_token.rb +0 -0
  124. data/spec/{app → controll_app}/config/initializers/session_store.rb +0 -0
  125. data/spec/{app → controll_app}/config/locales/en.yml +0 -0
  126. data/spec/controll_app/config/routes.rb +5 -0
  127. data/spec/{app → controll_app}/config.ru +0 -0
  128. data/spec/{app → controll_app}/db/seeds.rb +0 -0
  129. data/spec/{app/lib/tasks → controll_app/log}/.gitkeep +0 -0
  130. data/spec/{app → controll_app}/public/404.html +0 -0
  131. data/spec/{app → controll_app}/public/422.html +0 -0
  132. data/spec/{app → controll_app}/public/500.html +0 -0
  133. data/spec/{app → controll_app}/public/favicon.ico +0 -0
  134. data/spec/{app → controll_app}/public/index.html +0 -0
  135. data/spec/{app → controll_app}/public/javascripts/application.js +0 -0
  136. data/spec/{app → controll_app}/public/robots.txt +0 -0
  137. data/spec/{app → controll_app}/public/stylesheets/application.css +0 -0
  138. metadata +122 -85
  139. data/lib/controll/executor/notificator.rb +0 -12
  140. data/lib/controll/flow_handler/base.rb +0 -19
  141. data/lib/controll/flow_handler/control.rb +0 -85
  142. data/lib/controll/flow_handler/errors.rb +0 -5
  143. data/lib/controll/flow_handler/event_helper.rb +0 -18
  144. data/lib/controll/flow_handler/redirect/action.rb +0 -45
  145. data/lib/controll/flow_handler/redirect/mapper.rb +0 -41
  146. data/lib/controll/flow_handler/redirect.rb +0 -51
  147. data/lib/controll/flow_handler/render.rb +0 -51
  148. data/lib/controll/flow_handler.rb +0 -11
  149. data/lib/controll/helper/notify.rb +0 -74
  150. data/lib/controll/helper/path_resolver.rb +0 -45
  151. data/spec/app/app/controllers/posts_controller.rb +0 -52
  152. data/spec/app/config/routes.rb +0 -62
  153. data/spec/app/log/.gitkeep +0 -0
  154. data/spec/app/script/rails +0 -6
  155. data/spec/app/spec/controllers/posts_controller_spec.rb +0 -59
  156. data/spec/app/spec/isolated_spec_helper.rb +0 -6
  157. data/spec/app/spec/spec_helper.rb +0 -5
  158. data/spec/app/spec/unit/controllers/posts_controller_isolated_spec.rb +0 -63
  159. data/spec/app/spec/unit/controllers/posts_controller_spec.rb +0 -59
  160. data/spec/app/test/functional/.gitkeep +0 -0
  161. data/spec/app/test/functional/posts_controller_test.rb +0 -67
  162. data/spec/app/test/isolated_test_helper.rb +0 -7
  163. data/spec/app/test/test_helper.rb +0 -6
  164. data/spec/app/test/unit/.gitkeep +0 -0
  165. data/spec/app/test/unit/controllers/posts_controller_isolated_test.rb +0 -71
  166. data/spec/app/test/unit/controllers/posts_controller_test.rb +0 -67
  167. data/spec/app/vendor/assets/javascripts/.gitkeep +0 -0
  168. data/spec/app/vendor/assets/stylesheets/.gitkeep +0 -0
  169. data/spec/app/vendor/plugins/.gitkeep +0 -0
  170. data/spec/controll/asssistant_spec.rb +0 -5
  171. data/spec/controll/flow_handler/control_spec.rb +0 -159
  172. data/spec/controll/flow_handler/redirect_spec.rb +0 -93
  173. data/spec/controll/helper/path_resolver_spec.rb +0 -49
  174. data/spec/controll/helper_spec.rb +0 -108
data/controll.gemspec CHANGED
@@ -5,12 +5,12 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "controll"
8
- s.version = "0.2.0"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kristian Mandrup"]
12
- s.date = "2012-08-16"
13
- s.description = "FlowHandler, Executor, Notifier and more, all tied together tool pack"
12
+ s.date = "2012-09-17"
13
+ s.description = "Flow, Executor, Notifier and more, all tied together tool pack"
14
14
  s.email = "kmandrup@gmail.com"
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE.txt",
@@ -28,109 +28,146 @@ Gem::Specification.new do |s|
28
28
  "controll.gemspec",
29
29
  "lib/controll.rb",
30
30
  "lib/controll/assistant.rb",
31
+ "lib/controll/assistant/param_assistant.rb",
32
+ "lib/controll/assistant/session_assistant.rb",
31
33
  "lib/controll/command.rb",
32
34
  "lib/controll/commander.rb",
35
+ "lib/controll/enabler.rb",
36
+ "lib/controll/enabler/macros.rb",
37
+ "lib/controll/enabler/maps.rb",
38
+ "lib/controll/enabler/notify.rb",
39
+ "lib/controll/enabler/path_handler.rb",
40
+ "lib/controll/enabler/path_resolver.rb",
41
+ "lib/controll/engine.rb",
33
42
  "lib/controll/errors.rb",
43
+ "lib/controll/event.rb",
44
+ "lib/controll/event/helper.rb",
45
+ "lib/controll/event/matcher.rb",
46
+ "lib/controll/events.rb",
34
47
  "lib/controll/executor.rb",
35
48
  "lib/controll/executor/base.rb",
36
- "lib/controll/executor/notificator.rb",
37
- "lib/controll/flow_handler.rb",
38
- "lib/controll/flow_handler/base.rb",
39
- "lib/controll/flow_handler/control.rb",
40
- "lib/controll/flow_handler/errors.rb",
41
- "lib/controll/flow_handler/event_helper.rb",
42
- "lib/controll/flow_handler/redirect.rb",
43
- "lib/controll/flow_handler/redirect/action.rb",
44
- "lib/controll/flow_handler/redirect/mapper.rb",
45
- "lib/controll/flow_handler/render.rb",
49
+ "lib/controll/executor/controlled.rb",
50
+ "lib/controll/executor/delegator.rb",
51
+ "lib/controll/flow.rb",
52
+ "lib/controll/flow/action.rb",
53
+ "lib/controll/flow/action/base.rb",
54
+ "lib/controll/flow/action/fallback.rb",
55
+ "lib/controll/flow/action/path_action.rb",
56
+ "lib/controll/flow/action_mapper.rb",
57
+ "lib/controll/flow/action_mapper/base.rb",
58
+ "lib/controll/flow/action_mapper/complex.rb",
59
+ "lib/controll/flow/action_mapper/simple.rb",
60
+ "lib/controll/flow/errors.rb",
61
+ "lib/controll/flow/event_mapper.rb",
62
+ "lib/controll/flow/event_mapper/path_finder.rb",
63
+ "lib/controll/flow/event_mapper/util.rb",
64
+ "lib/controll/flow/master.rb",
65
+ "lib/controll/flow/master/executor.rb",
66
+ "lib/controll/flow/master/macros.rb",
67
+ "lib/controll/focused/enabler.rb",
46
68
  "lib/controll/helper.rb",
47
- "lib/controll/helper/event_matcher.rb",
48
69
  "lib/controll/helper/hash_access.rb",
49
- "lib/controll/helper/notify.rb",
50
70
  "lib/controll/helper/params.rb",
51
- "lib/controll/helper/path_resolver.rb",
52
71
  "lib/controll/helper/session.rb",
72
+ "lib/controll/macros.rb",
53
73
  "lib/controll/notify.rb",
54
74
  "lib/controll/notify/base.rb",
55
75
  "lib/controll/notify/flash.rb",
76
+ "lib/controll/notify/macros.rb",
77
+ "lib/controll/notify/message.rb",
78
+ "lib/controll/notify/message/handler.rb",
79
+ "lib/controll/notify/message/resolver.rb",
80
+ "lib/controll/notify/message/translator.rb",
56
81
  "lib/controll/notify/typed.rb",
82
+ "lib/generators/controll/assistant_generator.rb",
83
+ "lib/generators/controll/executor_generator.rb",
84
+ "lib/generators/controll/flow_handler_generator.rb",
85
+ "lib/generators/controll/notifier_generator.rb",
86
+ "lib/generators/controll/setup_generator.rb",
87
+ "lib/generators/controll/templates/assistant.tt",
88
+ "lib/generators/controll/templates/commander.tt",
89
+ "lib/generators/controll/templates/executor.tt",
90
+ "lib/generators/controll/templates/flow_handler.tt",
91
+ "lib/generators/controll/templates/notifier.tt",
57
92
  "spec/acceptance/app_test.rb",
58
- "spec/app/.gitignore",
59
- "spec/app/Gemfile",
60
- "spec/app/Gemfile.lock",
61
- "spec/app/README.rdoc",
62
- "spec/app/Rakefile",
63
- "spec/app/app/controllers/application_controller.rb",
64
- "spec/app/app/controllers/posts_controller.rb",
65
- "spec/app/app/models/.gitkeep",
66
- "spec/app/app/models/post.rb",
67
- "spec/app/app/views/layouts/application.html.erb",
68
- "spec/app/app/views/posts/_form.html.erb",
69
- "spec/app/app/views/posts/edit.html.erb",
70
- "spec/app/app/views/posts/index.html.erb",
71
- "spec/app/app/views/posts/new.html.erb",
72
- "spec/app/app/views/posts/show.html.erb",
73
- "spec/app/config.ru",
74
- "spec/app/config/application.rb",
75
- "spec/app/config/boot.rb",
76
- "spec/app/config/environment.rb",
77
- "spec/app/config/environments/development.rb",
78
- "spec/app/config/environments/test.rb",
79
- "spec/app/config/initializers/backtrace_silencers.rb",
80
- "spec/app/config/initializers/inflections.rb",
81
- "spec/app/config/initializers/mime_types.rb",
82
- "spec/app/config/initializers/secret_token.rb",
83
- "spec/app/config/initializers/session_store.rb",
84
- "spec/app/config/locales/en.yml",
85
- "spec/app/config/routes.rb",
86
- "spec/app/db/seeds.rb",
87
- "spec/app/lib/assets/.gitkeep",
88
- "spec/app/lib/tasks/.gitkeep",
89
- "spec/app/log/.gitkeep",
90
- "spec/app/public/404.html",
91
- "spec/app/public/422.html",
92
- "spec/app/public/500.html",
93
- "spec/app/public/favicon.ico",
94
- "spec/app/public/index.html",
95
- "spec/app/public/javascripts/application.js",
96
- "spec/app/public/robots.txt",
97
- "spec/app/public/stylesheets/application.css",
98
- "spec/app/script/rails",
99
- "spec/app/spec/controllers/posts_controller_spec.rb",
100
- "spec/app/spec/isolated_spec_helper.rb",
101
- "spec/app/spec/spec_helper.rb",
102
- "spec/app/spec/unit/controllers/posts_controller_isolated_spec.rb",
103
- "spec/app/spec/unit/controllers/posts_controller_spec.rb",
104
- "spec/app/test/functional/.gitkeep",
105
- "spec/app/test/functional/posts_controller_test.rb",
106
- "spec/app/test/isolated_test_helper.rb",
107
- "spec/app/test/test_helper.rb",
108
- "spec/app/test/unit/.gitkeep",
109
- "spec/app/test/unit/controllers/posts_controller_isolated_test.rb",
110
- "spec/app/test/unit/controllers/posts_controller_test.rb",
111
- "spec/app/vendor/assets/javascripts/.gitkeep",
112
- "spec/app/vendor/assets/stylesheets/.gitkeep",
113
- "spec/app/vendor/plugins/.gitkeep",
114
- "spec/controll/asssistant_spec.rb",
93
+ "spec/controll/assistant/param_assistant_spec.rb",
94
+ "spec/controll/assistant/session_assistant_spec.rb",
95
+ "spec/controll/assistant_spec.rb",
115
96
  "spec/controll/command_spec.rb",
116
97
  "spec/controll/commander_spec.rb",
117
- "spec/controll/executor/notificator_spec.rb",
118
- "spec/controll/flow_handler/control_spec.rb",
119
- "spec/controll/flow_handler/redirect/action_spec.rb",
120
- "spec/controll/flow_handler/redirect/mapper_spec.rb",
121
- "spec/controll/flow_handler/redirect_spec.rb",
122
- "spec/controll/flow_handler/render_spec.rb",
123
- "spec/controll/helper/event_matcher_spec.rb",
98
+ "spec/controll/enabler/macros_spec.rb",
99
+ "spec/controll/enabler/maps_spec.rb",
100
+ "spec/controll/enabler/notify_spec.rb",
101
+ "spec/controll/enabler/path_handler_spec.rb",
102
+ "spec/controll/enabler/path_resolver_spec.rb",
103
+ "spec/controll/enabler_spec.rb",
104
+ "spec/controll/event/helper_spec.rb",
105
+ "spec/controll/event/matcher_spec.rb",
106
+ "spec/controll/event_spec.rb",
107
+ "spec/controll/events_spec.rb",
108
+ "spec/controll/executor/controlled_spec.rb",
109
+ "spec/controll/executor/delegator_spec.rb",
110
+ "spec/controll/flow/action_mapper/complex_spec.rb",
111
+ "spec/controll/flow/action_mapper/fallback_spec.rb",
112
+ "spec/controll/flow/action_mapper/simple_spec.rb",
113
+ "spec/controll/flow/event_mapper/path_finder_spec.rb",
114
+ "spec/controll/flow/event_mapper/util_spec.rb",
115
+ "spec/controll/flow/master/executor_spec.rb",
116
+ "spec/controll/flow/master/macros_spec.rb",
117
+ "spec/controll/flow/master_spec.rb",
124
118
  "spec/controll/helper/hash_access_spec.rb",
125
- "spec/controll/helper/notify_spec.rb",
126
119
  "spec/controll/helper/params_spec.rb",
127
- "spec/controll/helper/path_resolver_spec.rb",
128
120
  "spec/controll/helper/session_spec.rb",
129
- "spec/controll/helper_spec.rb",
130
121
  "spec/controll/notify/base_spec.rb",
131
122
  "spec/controll/notify/flash_spec.rb",
132
- "spec/controll/notify/message_handler.rb",
123
+ "spec/controll/notify/message/handler_spec.rb",
124
+ "spec/controll/notify/message/resolver_spec.rb",
125
+ "spec/controll/notify/message/translator_spec.rb",
126
+ "spec/controll/notify/message_spec.rb",
127
+ "spec/controll/notify/services_notifier.rb",
133
128
  "spec/controll/notify/typed_spec.rb",
129
+ "spec/controll_app/.gitignore",
130
+ "spec/controll_app/Gemfile",
131
+ "spec/controll_app/Gemfile.lock",
132
+ "spec/controll_app/README.rdoc",
133
+ "spec/controll_app/Rakefile",
134
+ "spec/controll_app/app/controll/commanders/services_commander.rb",
135
+ "spec/controll_app/app/controll/executors/services_executor.rb",
136
+ "spec/controll_app/app/controll/flows/create_services.rb",
137
+ "spec/controll_app/app/controll/notifiers/services_notifier.rb",
138
+ "spec/controll_app/app/controllers/application_controller.rb",
139
+ "spec/controll_app/app/controllers/services_controller.rb",
140
+ "spec/controll_app/app/models/.gitkeep",
141
+ "spec/controll_app/app/models/post.rb",
142
+ "spec/controll_app/app/views/layouts/application.html.erb",
143
+ "spec/controll_app/app/views/posts/_form.html.erb",
144
+ "spec/controll_app/app/views/posts/edit.html.erb",
145
+ "spec/controll_app/app/views/posts/index.html.erb",
146
+ "spec/controll_app/app/views/posts/new.html.erb",
147
+ "spec/controll_app/app/views/posts/show.html.erb",
148
+ "spec/controll_app/config.ru",
149
+ "spec/controll_app/config/application.rb",
150
+ "spec/controll_app/config/boot.rb",
151
+ "spec/controll_app/config/environment.rb",
152
+ "spec/controll_app/config/environments/development.rb",
153
+ "spec/controll_app/config/environments/test.rb",
154
+ "spec/controll_app/config/initializers/backtrace_silencers.rb",
155
+ "spec/controll_app/config/initializers/inflections.rb",
156
+ "spec/controll_app/config/initializers/mime_types.rb",
157
+ "spec/controll_app/config/initializers/secret_token.rb",
158
+ "spec/controll_app/config/initializers/session_store.rb",
159
+ "spec/controll_app/config/locales/en.yml",
160
+ "spec/controll_app/config/routes.rb",
161
+ "spec/controll_app/db/seeds.rb",
162
+ "spec/controll_app/log/.gitkeep",
163
+ "spec/controll_app/public/404.html",
164
+ "spec/controll_app/public/422.html",
165
+ "spec/controll_app/public/500.html",
166
+ "spec/controll_app/public/favicon.ico",
167
+ "spec/controll_app/public/index.html",
168
+ "spec/controll_app/public/javascripts/application.js",
169
+ "spec/controll_app/public/robots.txt",
170
+ "spec/controll_app/public/stylesheets/application.css",
134
171
  "spec/functional_test_helper.rb",
135
172
  "spec/helper.rb",
136
173
  "spec/rspec_controller_class.rb",
@@ -0,0 +1,23 @@
1
+ module Controll
2
+ class ParamAssistant < Assistant
3
+ include Controll::Helper::Params
4
+
5
+ controller_methods :params
6
+
7
+ module Helper
8
+ extend ActiveSupport::Concern
9
+
10
+ def param name
11
+ param_assistant.send(name)
12
+ end
13
+
14
+ module ClassMethods
15
+ def param_assistant clazz
16
+ define_method :param_assistant do
17
+ @param_assistant ||= clazz.new self
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ module Controll
2
+ class SessionAssistant < Assistant
3
+ include Controll::Helper::Session
4
+
5
+ controller_methods :session
6
+
7
+ module Helper
8
+ extend ActiveSupport::Concern
9
+
10
+ def sess name
11
+ session_assistant.send(name)
12
+ end
13
+
14
+ module ClassMethods
15
+ def session_assistant clazz
16
+ define_method :session_assistant do
17
+ @session_assistant ||= clazz.new self
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,4 +1,7 @@
1
1
  module Controll
2
+ autoload :SessionAssistant, 'controll/assistant/session_assistant'
3
+ autoload :ParamAssistant, 'controll/assistant/param_assistant'
4
+
2
5
  class Assistant
3
6
  attr_reader :controller, :options
4
7
 
@@ -6,14 +9,13 @@ module Controll
6
9
  @controller = controller
7
10
  @options = options
8
11
  end
9
- end
10
- end
11
12
 
12
- module Controll
13
- class DelegateAssistant < Assistant
14
- def method_missing(meth, *args, &block)
15
- controller.send(meth, *args, &block)
16
- end
13
+ def self.controller_methods *names
14
+ delegate *names, to: :controller
15
+ end
17
16
  end
18
17
  end
19
18
 
19
+ module Assistants
20
+ Assistant = Controll::Assistant
21
+ end
@@ -4,10 +4,10 @@ module Controll
4
4
  # makes #command_method available
5
5
  extend Imperator::Command::MethodFactory
6
6
 
7
- attr_reader :controller, :options
7
+ attr_reader :initiator, :options
8
8
 
9
- def initialize controller, options = {}
10
- @controller = controller
9
+ def initialize initiator, options = {}
10
+ @initiator = initiator
11
11
  @options = options
12
12
  end
13
13
 
@@ -20,5 +20,18 @@ module Controll
20
20
  end
21
21
  alias_method :use_command, :command!
22
22
  alias_method :perform_command, :command!
23
+
24
+ alias_method :controller, :initiator
25
+
26
+ class << self
27
+ def initiator_methods *names
28
+ delegate names, to: :initiator
29
+ end
30
+ alias_method :controller_methods, :initiator_methods
31
+ end
23
32
  end
33
+ end
34
+
35
+ module Commanders
36
+ Commander = Controll::Commander
24
37
  end
@@ -0,0 +1,75 @@
1
+ module Controll
2
+ module Enabler
3
+ module Macros
4
+ extend ActiveSupport::Concern
5
+
6
+ module ClassMethods
7
+
8
+ # on Controller:
9
+ # - fx Admin::ServicesController -> :services
10
+ # On Focused Controller action:
11
+ # - fx Admin::ServicesController::Update -> :update_services
12
+ def controll *artifacts
13
+ def name_of clazz
14
+ clazz = clazz.to_s
15
+ if clazz =~ /Controller$/
16
+ clazz.sub(/Controller$/, '').split('::').last.underscore
17
+ else
18
+ parts = clazz.sub(/Controller/, '').split('::')
19
+ (parts.pop << parts.last).underscore
20
+ end
21
+ end
22
+
23
+ options = artifacts.extract_options!
24
+ name = name_of self.class
25
+ artifacts.each do |artifact|
26
+ send(artifact, name, options)
27
+ end
28
+ end
29
+
30
+ # TODO: refactor - all use exactly the same pattern - can be generated!
31
+ def commander name, options = {}
32
+ define_method :commander do
33
+ instance_variable_get("@commander") || begin
34
+ clazz = "Commanders::#{name.to_s.camelize}".constantize
35
+ instance_variable_set "@commander", clazz.new(self, options)
36
+ end
37
+ end
38
+ end
39
+
40
+ def notifier name, options = {}
41
+ define_method :notifier do
42
+ instance_variable_get("@notifier") || begin
43
+ clazz = "Notifiers::#{name.to_s.camelize}".constantize
44
+ instance_variable_set "@notifier", clazz.new(self, options)
45
+ end
46
+ end
47
+ end
48
+
49
+ def flow name, options = {}
50
+ define_method :flow do
51
+ unless instance_variable_get("@flow")
52
+ clazz = "Flows::#{name.to_s.camelize}".constantize
53
+ instance_variable_set "@flow", clazz.new(self, options)
54
+ end
55
+ end
56
+ end
57
+
58
+ def assistant name, options = {}
59
+ define_method :assistant do
60
+ unless instance_variable_get("@assistant")
61
+ clazz = "Assistants::#{name.to_s.camelize}".constantize
62
+ instance_variable_set "@assistant", clazz.new(self, options)
63
+ end
64
+ end
65
+ end
66
+
67
+ def assistant_methods *names
68
+ options = names.extract_options!
69
+ assistant = options[:to] || :assistant
70
+ delegate names, to: assistant
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,15 @@
1
+ module Controll::Enabler
2
+ module Maps
3
+ extend ActiveSupport::Concern
4
+
5
+ module ClassMethods
6
+ def redirect_map map = {}
7
+ @redirect_map ||= map
8
+ end
9
+
10
+ def render_map map = {}
11
+ @render_map ||= map
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,43 @@
1
+ module Controll
2
+ module Enabler
3
+ module Notify
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ Controll::Event.valid_types.each do |type|
8
+ meth = "create_#{type}"
9
+ define_method meth do |*args|
10
+ return create_event type, type if args.empty?
11
+ create_event args.first, type, args[1..-1]
12
+ end
13
+ alias_method type, meth
14
+ end
15
+ end
16
+
17
+ include Controll::Event::Helper
18
+
19
+ def notify event, *args
20
+ events << normalize(event, *args)
21
+ self # enable method chaining on controller
22
+ end
23
+
24
+ # event stack
25
+ def events
26
+ @events ||= Controll::Events.new
27
+ end
28
+
29
+ def main_event
30
+ events.last || create_success
31
+ end
32
+
33
+ protected
34
+
35
+ def process_events notifier = nil
36
+ notifier ||= self.notifier
37
+ events.each do |event|
38
+ notifier.send(event.type).notify event.name, event.options
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,49 @@
1
+ module Controll::Enabler
2
+ class PathHandler
3
+ attr_reader :controller, :type, :options, :path
4
+
5
+ def initialize controller, type
6
+ @controller, @type = [controller, type]
7
+ end
8
+
9
+ def self.renderer controller, map
10
+ self.new controller, map, :render
11
+ end
12
+
13
+ def self.redirecter controller, map
14
+ self.new controller, map, :redirect
15
+ end
16
+
17
+ def execute *args
18
+ extract! *args
19
+ process_notifications
20
+ path ? handle_path : fallback
21
+ end
22
+
23
+ protected
24
+
25
+ def map
26
+ @map ||= controller.class.send("#{type}_map")
27
+ end
28
+
29
+ alias_method :control_action, :type
30
+
31
+ def handle_path
32
+ controller.send control_action, path, options
33
+ end
34
+
35
+ def fallback
36
+ controller.do_fallback action
37
+ end
38
+
39
+ def extract! *args
40
+ @options = args.extract_options!
41
+ action = args.first
42
+ @path = path_resolver(map).resolve action
43
+ end
44
+
45
+ def path_resolver map
46
+ @path_resolver ||= PathResolver.new controller, map
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,47 @@
1
+ module Controll::Enabler
2
+ class PathResolver
3
+ attr_reader :caller, :event_map
4
+
5
+ ActionMapper = Controll::Flow::ActionMapper
6
+ Action = Controll::Flow::Action
7
+
8
+ def initialize caller, event_map
9
+ @caller = caller
10
+ @event_map = event_map
11
+ end
12
+
13
+ def resolve action = nil
14
+ @path ||= handle action
15
+ end
16
+
17
+ protected
18
+
19
+ alias_method :controller, :caller
20
+
21
+ delegate :notify, :main_event, to: :caller
22
+
23
+ def handle action
24
+ case action
25
+ when Action::Fallback
26
+ nil
27
+ when Action::PathAction
28
+ action.resolved_path
29
+ when Symbol, Controll::Event
30
+ resolve_event action
31
+ else
32
+ resolve_event
33
+ end
34
+ rescue Controll::Flow::PathActionError
35
+ nil
36
+ end
37
+
38
+ def resolve_event event = nil
39
+ notify event if event
40
+ mapper.map_event
41
+ end
42
+
43
+ def mapper
44
+ @mapper ||= Controll::Flow::EventMapper::Util.new main_event, event_map
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,49 @@
1
+ module Controll
2
+ module Enabler
3
+ autoload :Macros, 'controll/enabler/macros'
4
+ autoload :Notify, 'controll/enabler/notify'
5
+ autoload :PathResolver, 'controll/enabler/path_resolver'
6
+ autoload :PathHandler, 'controll/enabler/path_handler'
7
+ autoload :Maps, 'controll/enabler/maps'
8
+
9
+ extend ActiveSupport::Concern
10
+
11
+ included do
12
+ include Controll::Helper::Params
13
+ include Controll::Helper::Session
14
+
15
+ include Notify
16
+ include Macros
17
+ include Maps
18
+
19
+ delegate :command, :command!, :use_command, to: :commander
20
+ end
21
+
22
+ # override this for custom Controller specific fallback action
23
+ def do_fallback action
24
+ do_redirect fallback_path
25
+ end
26
+
27
+ def do_redirect *args
28
+ redirecter.execute *args
29
+ end
30
+
31
+ def do_render *args
32
+ renderer.execute *args
33
+ end
34
+
35
+ protected
36
+
37
+ def fallback_path
38
+ root_url
39
+ end
40
+
41
+ def renderer
42
+ @renderer||= PathHandler.new self, :render
43
+ end
44
+
45
+ def redirecter
46
+ @redirecter ||= PathHandler.new self, :redirect
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,9 @@
1
+ module Controll
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ initializer 'setup controll' do
5
+ config.autoload_paths += Dir[Rails.root.join('app', 'controll')]
6
+ end
7
+ end
8
+ end
9
+ end
@@ -1 +1,4 @@
1
- class Controll::InvalidEvent < StandardError; end
1
+ module Controll
2
+ class NotEnabled < StandardError; end
3
+ class InvalidEvent < StandardError; end
4
+ end
@@ -0,0 +1,20 @@
1
+ module Controll
2
+ module Event::Helper
3
+ def normalize event, *args
4
+ case event
5
+ when Controll::Event
6
+ event
7
+ when Symbol, String
8
+ create_event event.to_sym, *args
9
+ when Hash, Hashie::Mash
10
+ create_event event.delete(:name), event
11
+ else
12
+ raise Controll::Event::InvalidError, "Event: #{event} could not be normalized, must be a Hash, String or Symbol"
13
+ end
14
+ end
15
+
16
+ def create_event name, *args
17
+ Controll::Event.new name, *args
18
+ end
19
+ end
20
+ end