MINT-core 1.0.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (214) hide show
  1. data/Gemfile +22 -3
  2. data/Gemfile.lock +98 -22
  3. data/History.txt +262 -0
  4. data/LICENSE +30 -0
  5. data/MINT-core.gemspec +25 -80
  6. data/Manifest.txt +145 -30
  7. data/README.rdoc +6 -163
  8. data/Rakefile +16 -17
  9. data/bin/mint-aui +3 -3
  10. data/bin/mint-cui-gfx +3 -2
  11. data/bin/mint-juggernaut.sh +0 -0
  12. data/bin/mint-tuplespace +0 -0
  13. data/lib/MINT-core.rb +53 -15
  14. data/lib/MINT-core/agent/agent.rb +1 -1
  15. data/lib/MINT-core/agent/aui.rb +0 -14
  16. data/lib/MINT-core/agent/auicontrol.rb +91 -38
  17. data/lib/MINT-core/agent/cui-gfx.rb +3 -3
  18. data/lib/MINT-core/agent/cuicontrol.rb +94 -24
  19. data/lib/MINT-core/connector/redis_connector.rb +16 -0
  20. data/lib/MINT-core/manager/mapping_manager.rb +101 -0
  21. data/lib/MINT-core/manager/mapping_parser.rb +89 -0
  22. data/lib/MINT-core/manager/mapping_server.rb +99 -0
  23. data/lib/MINT-core/manager/position_updater.rb +33 -0
  24. data/lib/MINT-core/manager/scxml_client.rb +118 -0
  25. data/lib/MINT-core/manager/scxml_server.rb +86 -0
  26. data/lib/MINT-core/mapping/action/action.rb +32 -0
  27. data/lib/MINT-core/mapping/action/backend_action.rb +32 -0
  28. data/lib/MINT-core/mapping/action/bind_action.rb +88 -0
  29. data/lib/MINT-core/mapping/action/event_action.rb +40 -0
  30. data/lib/MINT-core/mapping/complementary_mapping.rb +31 -0
  31. data/lib/MINT-core/mapping/mapping.rb +170 -34
  32. data/lib/MINT-core/mapping/observation/negation_observation.rb +64 -0
  33. data/lib/MINT-core/mapping/observation/observation.rb +219 -0
  34. data/lib/MINT-core/mapping/sequential.rb +1 -2
  35. data/lib/MINT-core/mapping/sequential_mapping.rb +60 -0
  36. data/lib/MINT-core/model/aui/AIChoiceElement.rb +17 -0
  37. data/lib/MINT-core/model/aui/AICommand.rb +7 -0
  38. data/lib/MINT-core/model/aui/AIContainer.rb +73 -0
  39. data/lib/MINT-core/model/aui/AIContext.rb +12 -0
  40. data/lib/MINT-core/model/aui/AIIN.rb +8 -0
  41. data/lib/MINT-core/model/aui/AIINContinuous.rb +56 -0
  42. data/lib/MINT-core/model/aui/AIINDiscrete.rb +8 -0
  43. data/lib/MINT-core/model/aui/AIMultiChoice.rb +1 -2
  44. data/lib/MINT-core/model/aui/AIMultiChoiceElement.rb +4 -51
  45. data/lib/MINT-core/model/aui/AIO.rb +76 -123
  46. data/lib/MINT-core/model/aui/AIOUT.rb +8 -0
  47. data/lib/MINT-core/model/aui/AIOUTContinuous.rb +61 -0
  48. data/lib/MINT-core/model/aui/AIReference.rb +16 -0
  49. data/lib/MINT-core/model/aui/AISingleChoice.rb +18 -1
  50. data/lib/MINT-core/model/aui/AISingleChoiceElement.rb +10 -56
  51. data/lib/MINT-core/model/aui/AISinglePresence.rb +39 -71
  52. data/lib/MINT-core/model/aui/aicommand.scxml +47 -0
  53. data/lib/MINT-core/model/aui/aicontainer.scxml +41 -0
  54. data/lib/MINT-core/model/aui/aicontext.scxml +34 -0
  55. data/lib/MINT-core/model/aui/aiincontinuous.scxml +59 -0
  56. data/lib/MINT-core/model/aui/aiinrange.scxml +86 -0
  57. data/lib/MINT-core/model/aui/aimultichoice.scxml +67 -0
  58. data/lib/MINT-core/model/aui/aimultichoiceelement.scxml +51 -0
  59. data/lib/MINT-core/model/aui/aio.scxml +18 -27
  60. data/lib/MINT-core/model/aui/aioutcontinuous.scxml +66 -0
  61. data/lib/MINT-core/model/aui/aireference.scxml +28 -0
  62. data/lib/MINT-core/model/aui/aisinglechoice.scxml +60 -0
  63. data/lib/MINT-core/model/aui/aisinglechoiceelement.scxml +45 -60
  64. data/lib/MINT-core/model/aui/aisinglepresence.scxml +15 -24
  65. data/lib/MINT-core/model/aui/model.rb +15 -38
  66. data/lib/MINT-core/model/cui/gfx/CIC.rb +34 -10
  67. data/lib/MINT-core/model/cui/gfx/CIO.rb +66 -115
  68. data/lib/MINT-core/model/cui/gfx/CarouFredSel.scxml +58 -0
  69. data/lib/MINT-core/model/cui/gfx/MarkableRadioButton.rb +8 -0
  70. data/lib/MINT-core/model/cui/gfx/RadioButton.rb +8 -0
  71. data/lib/MINT-core/model/cui/gfx/RadioButtonGroup.rb +6 -0
  72. data/lib/MINT-core/model/cui/gfx/button.rb +16 -0
  73. data/lib/MINT-core/model/cui/gfx/button.scxml +58 -0
  74. data/lib/MINT-core/model/cui/gfx/caroufredsel.rb +48 -0
  75. data/lib/MINT-core/model/cui/gfx/cic.scxml +57 -0
  76. data/lib/MINT-core/model/cui/gfx/cio.scxml +54 -0
  77. data/lib/MINT-core/model/cui/gfx/markableradiobutton.scxml +67 -0
  78. data/lib/MINT-core/model/cui/gfx/model.rb +39 -176
  79. data/lib/MINT-core/model/cui/gfx/radiobutton.scxml +59 -0
  80. data/lib/MINT-core/model/interactor.rb +167 -46
  81. data/lib/MINT-core/model/interactor.scxml +3 -0
  82. data/lib/MINT-core/model/interactor_helpers.rb +25 -0
  83. data/lib/MINT-core/model/ir/body/OneHandPoseNavigation.rb +15 -0
  84. data/lib/MINT-core/model/ir/body/body.rb +5 -0
  85. data/lib/MINT-core/model/ir/body/fingertip.rb +114 -0
  86. data/lib/MINT-core/model/ir/body/fingertip.scxml +43 -0
  87. data/lib/MINT-core/model/{body → ir/body}/gesture_button.rb +0 -0
  88. data/lib/MINT-core/model/ir/body/hand.rb +5 -0
  89. data/lib/MINT-core/model/ir/body/head.rb +102 -0
  90. data/lib/MINT-core/model/ir/body/head.scxml +92 -0
  91. data/lib/MINT-core/model/ir/body/onehandposenavigation.scxml +53 -0
  92. data/lib/MINT-core/model/ir/body/pose.rb +99 -0
  93. data/lib/MINT-core/model/ir/browserscreen.rb +27 -0
  94. data/lib/MINT-core/model/ir/browserscreen.scxml +14 -0
  95. data/lib/MINT-core/model/{device → ir}/button.rb +1 -1
  96. data/lib/MINT-core/model/ir/ir.rb +5 -0
  97. data/lib/MINT-core/model/ir/irmedia.rb +5 -0
  98. data/lib/MINT-core/model/ir/irmode.rb +5 -0
  99. data/lib/MINT-core/model/{device → ir}/joypad.rb +1 -1
  100. data/lib/MINT-core/model/ir/mouse.rb +44 -0
  101. data/lib/MINT-core/model/ir/mouse.scxml +35 -0
  102. data/lib/MINT-core/model/{device/mouse.rb → ir/mouse_old.rb} +2 -2
  103. data/lib/MINT-core/model/{device → ir}/pointer.rb +20 -22
  104. data/lib/MINT-core/model/ir/pointer.scxml +19 -0
  105. data/lib/MINT-core/model/ir/screen.rb +5 -0
  106. data/lib/MINT-core/model/{device → ir}/wheel.rb +1 -1
  107. data/lib/MINT-core/model/mim/aicommand_activate_to_button_press.xml +13 -0
  108. data/lib/MINT-core/model/mim/aicommand_deactivate_to_button_release.xml +13 -0
  109. data/lib/MINT-core/model/mim/aio_defocus_to_cio_unhighlight.xml +13 -0
  110. data/lib/MINT-core/model/mim/aio_focus_to_cio_highlight.xml +14 -0
  111. data/lib/MINT-core/model/mim/aio_present_to_cio_display.xml +14 -0
  112. data/lib/MINT-core/model/mim/aio_suspend_to_cio_hide.xml +13 -0
  113. data/lib/MINT-core/model/mim/aisinglechoice_present_to_child_present.xml +14 -0
  114. data/lib/MINT-core/model/mim/aisinglechoiceelement_chosen_to_radiobutton_select.xml +13 -0
  115. data/lib/MINT-core/model/mim/aisinglechoiceelement_unchosen_to_radiobutton_unselect.xml +13 -0
  116. data/lib/MINT-core/model/mim/aisinglepresence_children_finished_to_caroufredsel_init_js.xml +14 -0
  117. data/lib/MINT-core/model/mim/aisinglepresence_present_to_child_present.xml +15 -0
  118. data/lib/MINT-core/model/mim/browserscreen_reload_to_cuicontrol_refresh_all.xml +12 -0
  119. data/lib/MINT-core/model/mim/button_press_to_aicommand_activate.xml +12 -0
  120. data/lib/MINT-core/model/mim/button_release_to_aicommand_deactivate.xml +12 -0
  121. data/lib/MINT-core/model/mim/caroufredsel_refreshing_to_caroufredsel_init_js.xml +14 -0
  122. data/lib/MINT-core/model/mim/cio_display_to_aio_defocus.xml +13 -0
  123. data/lib/MINT-core/model/mim/cio_display_to_aio_present.xml +12 -0
  124. data/lib/MINT-core/model/mim/cio_display_to_cio_display_cache_add.xml +11 -0
  125. data/lib/MINT-core/model/mim/cio_hide_to_aio_suspend.xml +12 -0
  126. data/lib/MINT-core/model/mim/cio_hide_to_cio_display_cache_remove.xml +12 -0
  127. data/lib/MINT-core/model/mim/cio_highlight_to_aio_focus.xml +13 -0
  128. data/lib/MINT-core/model/mim/head_looking_left_to_aisinglepresence_prev.xml +14 -0
  129. data/lib/MINT-core/model/mim/head_looking_right_to_aisinglepresence_next.xml +15 -0
  130. data/lib/MINT-core/model/mim/head_nodding_to_aisinglepresence_next.xml +15 -0
  131. data/lib/MINT-core/model/mim/head_tilting_left_to_aisinglepresence_prev.xml +14 -0
  132. data/lib/MINT-core/model/mim/head_tilting_right_to_aisinglepresence_next.xml +15 -0
  133. data/lib/MINT-core/model/mim/left_button_aisinglepresence_enter.xml +15 -0
  134. data/lib/MINT-core/model/mim/left_button_aisinglepresence_next.xml +15 -0
  135. data/lib/MINT-core/model/mim/mim_default.xml +52 -0
  136. data/lib/MINT-core/model/mim/mint-mappings.xsd +127 -0
  137. data/lib/MINT-core/model/mim/mouse_press_to_aicommand_activate.xml +17 -0
  138. data/lib/MINT-core/model/mim/mouse_press_to_aisinglechoiceelement_choose.xml +17 -0
  139. data/lib/MINT-core/model/mim/mouse_press_to_aisinglechoiceelement_unchoose.xml +17 -0
  140. data/lib/MINT-core/model/mim/mouse_release_to_aicommand_deactivate.xml +16 -0
  141. data/lib/MINT-core/model/mim/mouse_stop_to_cio_highlight.xml +13 -0
  142. data/lib/MINT-core/model/mim/onehandposnav_confirm_to_aichoiceelement_choose.xml +14 -0
  143. data/lib/MINT-core/model/mim/onehandposnav_next_to_aio_next.xml +14 -0
  144. data/lib/MINT-core/model/mim/onehandposnav_previous_to_aio_prev.xml +14 -0
  145. data/lib/MINT-core/model/mim/radiobutton_selected_to_aisinglechoiceelement_choose.xml +13 -0
  146. data/lib/MINT-core/model/mim/radiobutton_unselected_to_aisinglechoiceelement_unchoose.xml +13 -0
  147. data/lib/MINT-core/model/mim/right_button_aisinglepresence_prev.xml +15 -0
  148. data/lib/MINT-core/model/task.rb +6 -6
  149. data/script/console +0 -0
  150. data/script/destroy +0 -0
  151. data/script/generate +0 -0
  152. data/spec/AICommand_spec.rb +20 -0
  153. data/spec/AIContainer_spec.rb +161 -0
  154. data/spec/AIINContinuous_spec.rb +92 -0
  155. data/spec/AIOUTContinuous_spec.rb +93 -0
  156. data/spec/AIO_spec.rb +73 -0
  157. data/spec/AIReference_spec.rb +105 -0
  158. data/spec/AISinglePresence_spec.rb +204 -60
  159. data/spec/Button_spec.rb +114 -0
  160. data/spec/CIO_spec.rb +145 -0
  161. data/spec/Interactor_spec.rb +95 -0
  162. data/spec/MappingManager_spec.rb +126 -0
  163. data/spec/Spontaneous_spec.rb +53 -0
  164. data/spec/aio_agent_spec.rb +215 -186
  165. data/spec/aisinglechoice_spec.rb +147 -88
  166. data/spec/aisinglechoiceelement_spec.rb +154 -70
  167. data/spec/complementary_mapping_spec.rb +158 -0
  168. data/spec/core_spec.rb +27 -15
  169. data/spec/cui_helper.rb +100 -0
  170. data/spec/examples/browserscreen_reload_to_cuicontrol_refresh_all.xml +12 -0
  171. data/spec/examples/mim_streaming_example.xml +9 -0
  172. data/spec/examples/mouse_highlight.xml +22 -0
  173. data/spec/examples/performance_mapping.xml +15 -0
  174. data/spec/examples/reset_click.xml +24 -0
  175. data/spec/interactor_test.scxml +32 -0
  176. data/spec/interactor_test_2.scxml +16 -0
  177. data/spec/mapping_performance_spec.rb +118 -0
  178. data/spec/mapping_server_spec.rb +161 -0
  179. data/spec/mapping_spec.rb +307 -0
  180. data/spec/music_spec.rb +301 -135
  181. data/spec/performance_counter.scxml +9 -0
  182. data/spec/sequential_mappings_spec.rb +69 -0
  183. data/spec/shared/aio_shared.rb +144 -0
  184. data/spec/spec_helper.rb +22 -3
  185. data/spec/spontaneous.scxml +11 -0
  186. data/spec/support/connection_helper.rb +19 -0
  187. data/spec/support/redis_connector_monkey_patch.rb +1 -0
  188. data/spec/support/statemachine_helper.rb +84 -0
  189. data/spec/sync_mappings_spec.rb +96 -0
  190. metadata +219 -354
  191. data/lib/MINT-core/mapping/complementary.rb +0 -100
  192. data/lib/MINT-core/mapping/on_state_change.rb +0 -65
  193. data/lib/MINT-core/model/aui/AIC.rb +0 -86
  194. data/lib/MINT-core/model/aui/AIChoice.rb +0 -65
  195. data/lib/MINT-core/model/aui/AIINChoose.rb +0 -54
  196. data/lib/MINT-core/model/aui/AIOUTDiscrete.rb +0 -43
  197. data/lib/MINT-core/model/aui/aic.png +0 -0
  198. data/lib/MINT-core/model/aui/aic.scxml +0 -50
  199. data/lib/MINT-core/model/aui/aichoice.png +0 -0
  200. data/lib/MINT-core/model/aui/aichoice.scxml +0 -60
  201. data/lib/MINT-core/model/aui/aio.png +0 -0
  202. data/lib/MINT-core/model/aui/aisinglechoiceelement.png +0 -0
  203. data/lib/MINT-core/model/aui/aisinglepresence.png +0 -0
  204. data/lib/MINT-core/model/body/handgesture.rb +0 -279
  205. data/lib/MINT-core/model/body/head.png +0 -0
  206. data/lib/MINT-core/model/body/head.rb +0 -51
  207. data/lib/MINT-core/model/body/head.scxml +0 -28
  208. data/lib/MINT-core/model/cui/gfx/screen.rb +0 -18
  209. data/lib/MINT-core/overrides/rinda.rb +0 -34
  210. data/spec/AIC_spec.rb +0 -69
  211. data/spec/MINT-core_spec.rb +0 -11
  212. data/spec/aio_spec.rb +0 -144
  213. data/spec/cio_spec.rb +0 -369
  214. data/tasks/rspec.rake +0 -21
@@ -0,0 +1,53 @@
1
+ require "spec_helper"
2
+
3
+ require "em-spec/rspec"
4
+
5
+
6
+ describe 'Spontaneous' do
7
+ include EventMachine::SpecHelper
8
+
9
+ before :all do
10
+
11
+ connection_options = { :adapter => "redis"}
12
+ DataMapper.setup(:default, connection_options)
13
+
14
+ connect do |redis|
15
+ require "MINT-core"
16
+ require "support/redis_connector_monkey_patch" # TODO dirty patch for a bug that i have not found :(
17
+
18
+ class Spontaneous < MINT::Interactor
19
+ def getSCXML
20
+ "#{File.dirname(__FILE__)}/spontaneous.scxml"
21
+ end
22
+ end
23
+
24
+ DataMapper.finalize
25
+ DataMapper::Model.raise_on_save_failure = true
26
+ end
27
+ end
28
+
29
+ describe 'synchronized with RedisDB' do
30
+
31
+ it 'should do the spontaneous transition to positioned' do
32
+ connect do |redis|
33
+ @a = Spontaneous.create(:name => "test")
34
+ @a.process_event(:position)
35
+ @a.new_states.should == [:positioned, :superstate]
36
+ end
37
+ end
38
+ end
39
+ describe 'synchronized with Redis-PubSub' do
40
+ it 'should do the spontaneous transition to positioned and publish passing of positioning state ' do
41
+ connect true do |redis|
42
+
43
+ test_state_flow redis,"Interactor.Spontaneous.test" ,["initialized",["superstate", "positioning"],"positioned"] do
44
+
45
+ @a = Spontaneous.create(:name => "test")
46
+ @a.process_event(:position)
47
+
48
+ end
49
+ end
50
+
51
+ end
52
+ end
53
+ end
@@ -1,234 +1,263 @@
1
- require "spec"
2
1
  require "spec_helper"
2
+ require "em-spec/rspec"
3
+
4
+ def create_scenario
5
+ include MINT
6
+
7
+ @aui = MINT::AIContainer.create(:name=>"RecipeFinder",
8
+ :children => "RecipeFinder_label|RecipeFinder_description|RecipeFilter|RecipeSelection")
9
+ MINT::AIReference.create(:name=>"RecipeFinder_label",:parent =>"RecipeFinder",:text=>"Willkommen")
10
+ MINT::AIContext.create(:name=>"RecipeFinder_description",:parent =>"RecipeFinder",:text=>"Willkommen beim 4 Sterne Koch Assistenten.")
11
+ MINT::AIContainer.create(:name=>"RecipeFilter",:parent =>"RecipeFinder",
12
+ :children => "RecipeFilter_label|RecipeFilter_description|RecipeCuisine|RecipeCategory|RecipeCalories")
13
+ MINT::AIReference.create(:name=>"RecipeFilter_label",:parent =>"RecipeFilter",:text=>"Suchkriterien")
14
+ MINT::AIContext.create(:name=>"RecipeFilter_description",:parent =>"RecipeFilter",:text=>"In diesem Feld koennen Sie mit genauen Angaben zu Ihrem Gericht-Wunsch die Suche nach Ihrem Rezeptvorschlag eingrenzen.")
15
+ MINT::AIContainer.create(:name=>"RecipeCuisine",:parent =>"RecipeFilter",
16
+ :children => "RecipeCuisine_label|RecipeCuisine_description|RecipeCuisine_choice")
17
+ MINT::AIReference.create(:name=>"RecipeCuisine_label",:parent =>"RecipeCuisine",:text=>"Nationale Kueche")
18
+ MINT::AIContext.create(:name=>"RecipeCuisine_description",:parent =>"RecipeCuisine",:text=>"Welche nationale Kueche waehlen Sie? ")
19
+ MINT::AIMultiChoice.create(:name=>"RecipeCuisine_choice",:parent =>"RecipeCuisine",
20
+ :children => "French|German|Italian|Chinese")
21
+ MINT::AIChoiceElement.create(:name => "French", :parent =>"RecipeCuisine_choice",:text =>"Franzoesisch")
22
+ MINT::AIChoiceElement.create(:name => "German",:parent =>"RecipeCuisine_choice",:text =>"Deutsch")
23
+ MINT::AIChoiceElement.create(:name => "Italian",:parent =>"RecipeCuisine_choice",:text =>"Italienisch")
24
+ MINT::AIChoiceElement.create(:name => "Chinese",:parent =>"RecipeCuisine_choice",:text =>"Chinesisch")
25
+
26
+ MINT::AIContainer.create(:name=>"RecipeCategory",:parent =>"RecipeFilter",
27
+ :children => "RecipeCategory_label|RecipeCategory_description|RecipeCategory_choice")
28
+ MINT::AIReference.create(:name=>"RecipeCategory_label",:parent =>"RecipeCategory",:text=>"Menueart ")
29
+ MINT::AIContext.create(:name=>"RecipeCategory_description",:parent =>"RecipeCategory",:text=>" Welche Menueart moechten Sie kochen? ")
30
+ MINT::AIMultiChoice.create(:name=>"RecipeCategory_choice",:parent =>"RecipeCategory",
31
+ :children => "Main|Pastry|Dessert|Starter")
32
+ MINT::AIChoiceElement.create(:name => "Main", :parent =>"RecipeCategory_choice",:text =>"Hauptgericht")
33
+ MINT::AIChoiceElement.create(:name => "Pastry",:parent =>"RecipeCategory_choice",:text =>"Gebaeck")
34
+ MINT::AIChoiceElement.create(:name => "Dessert",:parent =>"RecipeCategory_choice",:text =>"Nachtisch")
35
+ MINT::AIChoiceElement.create(:name => "Starter",:parent =>"RecipeCategory_choice",:text =>"Vorspeise")
36
+
37
+ MINT::AIContainer.create(:name=>"RecipeCalories",:parent =>"RecipeFilter",
38
+ :children => "RecipeCalories_label|RecipeCalories_description|RecipeCalories_choice")
39
+ MINT::AIReference.create(:name=>"RecipeCalories_label",:parent =>"RecipeCalories",:text=>"gesundheitsbewusst ")
40
+ MINT::AIContext.create(:name=>"RecipeCalories_description",:parent =>"RecipeCalories",:text=>" Wollen Sie gesundheitsbewusst kochen? ")
41
+ MINT::AISingleChoice.create(:name=>"RecipeCalories_choice",:parent =>"RecipeCalories",
42
+ :children => "Diet|LowFat|NotRelevant")
43
+ MINT::AIChoiceElement.create(:name => "Diet", :text =>"Hauptgericht",:parent =>"RecipeCalories_choice")
44
+ MINT::AIChoiceElement.create(:name => "LowFat",:text =>"Gebaeck",:parent =>"RecipeCalories_choice")
45
+ MINT::AIChoiceElement.create(:name => "NotRelevant",:text =>"Nachtisch",:parent =>"RecipeCalories_choice")
46
+
47
+
48
+ MINT::AIContainer.create(:name =>"RecipeSelection",:parent =>"RecipeFinder",
49
+ :children => "RecipeSelection_label|RecipeSelection_description|FoundRecipes|Start")
50
+ MINT::AIReference.create(:name=>"RecipeSelection_label",:text=>"Rezeptdetails",:parent =>"RecipeSelection")
51
+ MINT::AIContext.create(:name=>"RecipeSelection_description",:parent =>"RecipeSelection",:text=>"Hier werden Ihre Rezeptvorschlaege mit den Details angezeigt und Sie koennen bestimmen, fuer wieviele Personen das Rezept berechnet werden soll.")
52
+ MINT::AISingleChoice.create(:name=>"FoundRecipes",:parent =>"RecipeSelection",
53
+ :children => "Schweinebraten|Lammkotletts|Spagetti")
54
+ MINT::AIChoiceElement.create(:name => "Schweinebraten", :text =>"Schweinebraten",:parent =>"FoundRecipes")
55
+ MINT::AIChoiceElement.create(:name => "Lammkotletts",:text =>"Lammkotletts",:parent =>"FoundRecipes")
56
+ MINT::AIChoiceElement.create(:name => "Spagetti",:text =>"Spagetti",:parent =>"FoundRecipes")
57
+ MINT::AICommand.create(:name=>"Start",:text=>"Kochassistent starten",:parent =>"RecipeSelection")
58
+
59
+ end
3
60
 
4
61
  describe 'AUI-Agent' do
5
- before :each do
6
- connection_options = { :adapter => "in_memory"}
7
- DataMapper.setup(:default, connection_options)
8
- # DataMapper.setup(:default, { :adapter => "rinda", :host =>"localhost",:port=>4000})
9
- # ,:local =>Rinda::TupleSpace.new})
10
- # DataMapper::Logger.new("data.log", :debug)
11
- @aui = AIC.new(:name=>"RecipeFinder",
12
- :childs =>[
13
- AIINReference.new(:name=>"RecipeFinder_label",:label=>"Willkommen"),
14
- AIOUTContext.new(:name=>"RecipeFinder_description",:text=>"Willkommen beim 4 Sterne Koch Assistenten."),
15
- AIC.new(:name=>"RecipeFilter",
16
- :childs => [
17
- AIINReference.new(:name=>"RecipeFilter_label",:label=>"Suchkriterien"),
18
- AIOUTContext.new(:name=>"RecipeFilter_description",:text=>"In diesem Feld können Sie mit genauen Angaben zu Ihrem Gericht-Wunsch die Suche nach Ihrem Rezeptvorschlag eingrenzen."),
19
- AIC.new(:name=>"RecipeCuisine",
20
- :childs=>[
21
- AIINReference.new(:name=>"RecipeCuisine_label",:label=>"Nationale Küche"),
22
- AIOUTContext.new(:name=>"RecipeCuisine_description",:text=>"Welche nationale Küche wählen Sie? "),
23
- AIMultiChoice.new(:name=>"RecipeCuisine_choice",
24
- :childs =>[
25
- AIINChoose.new(:name => "French", :label =>"Französisch"),
26
- AIINChoose.new(:name => "German",:label =>"Deutsch"),
27
- AIINChoose.new(:name => "Italian",:label =>"Italienisch"),
28
- AIINChoose.new(:name => "Chinese",:label =>"Chinesisch")
29
- ]
30
- )
31
- ]),
32
- AIC.new(:name=>"RecipeCategory",
33
- :childs=>[
34
- AIINReference.new(:name=>"RecipeCategory_label",:label=>"Menǘart "),
35
- AIOUTContext.new(:name=>"RecipeCategory_description",:text=>" Welche Menǘart möchten Sie kochen? "),
36
- AIMultiChoice.new(:name=>"RecipeCategory_choice",
37
- :childs =>[
38
- AIINChoose.new(:name => "Main", :label =>"Hauptgericht"),
39
- AIINChoose.new(:name => "Pastry",:label =>"Gebäck"),
40
- AIINChoose.new(:name => "Dessert",:label =>"Nachtisch"),
41
- AIINChoose.new(:name => "Starter",:label =>"Vorspeise")
42
- ]
43
- )
44
- ]),
45
- AIC.new(:name=>"RecipeCalories",
46
- :childs=>[
47
- AIINReference.new(:name=>"RecipeCalories_label",:label=>"gesundheitsbewusst "),
48
- AIOUTContext.new(:name=>"RecipeCalories_description",:text=>" Wollen Sie gesundheitsbewusst kochen? "),
49
- AISingleChoice.new(:name=>"RecipeCalories_choice",
50
- :childs =>[
51
- AIINChoose.new(:name => "Diet", :label =>"Hauptgericht"),
52
- AIINChoose.new(:name => "Low fat",:label =>"Gebäck"),
53
- AIINChoose.new(:name => "Not Relevant",:label =>"Nachtisch"),
54
- ]
55
- )
56
- ]),
57
- ]),
58
- AIC.new(:name =>"RecipeSelection",
59
- :childs => [
60
- AIINReference.new(:name=>"RecipeSelection_label",:label=>"Rezeptdetails"),
61
- AIOUTContext.new(:name=>"RecipeSelection_description",:text=>"Hier werden Ihre Rezeptvorschläge mit den Details angezeigt und Sie können bestimmen, für wieviele Personen das Rezept berechnet werden soll."),
62
- AISingleChoice.new(:name=>"FoundRecipes",
63
- :childs =>[
64
- AIINChoose.new(:name => "Schweinebraten", :label =>"Schweinebraten"),
65
- AIINChoose.new(:name => "Lamkotletts",:label =>"Lammkotletts"),
66
- AIINChoose.new(:name => "Spagetti",:label =>"Spagetti"),
67
- ]
68
- ),
69
- AICommand.new(:name=>"Start",:label=>"Kochassistent starten",:description=>"Hier können Sie den Kochassistenten starten.")
70
- ])
71
- ])
72
- @aui.save!
73
62
 
63
+ include EventMachine::SpecHelper
64
+
65
+ before :all do
66
+ connection_options = { :adapter => "redis"}
67
+ DataMapper.setup(:default, connection_options)
68
+
69
+ connect do |redis|
70
+ require "MINT-core"
71
+
72
+ DataMapper.finalize
73
+ DataMapper::Model.raise_on_save_failure = true
74
+ end
74
75
  end
75
-
76
+
76
77
  describe 'organizing' do
77
-
78
+
78
79
  it 'should save correctly' do
79
- class P <Element
80
-
80
+ pending "no longer needed "
81
+ class P < MINT::Interactor
82
+
81
83
  # belongs_to :c
82
84
  belongs_to :parent, 'C',
83
- :parent_key => [ :id ], # in the remote model (Blog)
84
- :child_key => [ :c_id ], # local to this model (Post)
85
- :required => true
86
-
85
+ :parent_key => [ :id ], # in the remote model (Blog)
86
+ :child_key => [ :c_id ], # local to this model (Post)
87
+ :required => true
88
+
87
89
  has 1, :next, P
88
90
  has 1, :previous, P
89
91
  end
90
-
91
- class C < P
92
- has n, :childs, 'P',
93
- :parent_key => [ :id ], # local to this model (Blog)
94
- :child_key => [ :c_id ] # in the remote model (Post)
95
-
96
- end
97
-
92
+
93
+ class C < P
94
+ has n, :children, 'P',
95
+ :parent_key => [ :id ], # local to this model (Blog)
96
+ :child_key => [ :c_id ] # in the remote model (Post)
97
+
98
+ end
99
+
98
100
  t2 = P.new(:name=>"Test2")
99
- t1 = C.new(:name=>"Test1", :childs =>[t2],:next=>t2)
101
+ t1 = C.new(:name=>"Test1", :childs =>[t2],:next=>t2)
100
102
  t2.previous = t1
101
-
103
+
102
104
  t1.childs[0].parent.name.should =="Test1"
103
-
105
+
104
106
  t1.save!
105
-
106
-
107
+
108
+
107
109
  P.first(:name=>"Test2").parent.name.should == "Test1"
108
110
  P.first(:name=>"Test2").previous.name.should == "Test1"
109
111
  C.first(:name=>"Test1").next.name.should == "Test2"
110
112
  end
111
-
113
+
112
114
  it "should organize parental relations correctly" do
113
- aic = AIC.new(:name =>"AIC", :childs=>[AIO.new(:name=>"AIO")])
114
- aic.save!
115
-
116
- AIO.first(:name=>"AIO").parent.name.should == "AIC"
115
+ connect do |redis|
116
+ aic = MINT::AIContainer.create(:name =>"AIContainer", :children => "AIO")
117
+ MINT::AIO.create(:name=>"AIO",:parent =>"AIContainer")
118
+ aic.save!
119
+
120
+ MINT::AIO.first(:name=>"AIO").parent.name.should == "AIContainer"
121
+ end
117
122
  end
118
-
123
+
119
124
  it "should organize parental relations correctly 2" do
120
- AIC.new(:name=>"RecipeFinder",
121
- :childs =>[
122
- AIINReference.new(:name=>"RecipeFinder_label",:label=>"Willkommen")]).save!
123
-
124
- AIO.first(:name=>"RecipeFinder_label").parent.name.should == "RecipeFinder"
125
+ connect do |redis|
126
+ MINT::AIContainer.create(:name=>"RecipeFinder",
127
+ :children => "RecipeFinder_label")
128
+ MINT::AIReference.create(:name=>"RecipeFinder_label",:parent =>"RecipeFinder",:text=>"Willkommen")
129
+
130
+ MINT::AIO.first(:name=>"RecipeFinder_label").parent.name.should == "RecipeFinder"
131
+ end
125
132
  end
126
-
133
+
127
134
  it "should organize parental relations correctly 3" do
128
- AIO.first(:name=>"RecipeFinder_label").parent.name.should == "RecipeFinder"
135
+ connect do |redis|
136
+ create_scenario
137
+ MINT::AIO.first(:name=>"RecipeFinder_label").parent.name.should == "RecipeFinder"
129
138
  end
130
-
139
+ end
140
+
131
141
  it 'should organize with parental relationships 4' do
132
- AIINChoose.first(:name => "Main").parent.name.should == "RecipeCategory_choice"
142
+ connect do |redis|
143
+ create_scenario
144
+ MINT::AIChoiceElement.first(:name => "Main").parent.name.should == "RecipeCategory_choice"
145
+ end
133
146
  end
134
-
147
+
135
148
  it 'should support next navigation' do
136
- pending("get the organize function working")
137
- AUIControl.organize(@aui)
138
- @aui.save!#.should==true
139
- @aui.next.name.should=="RecipeFinder_label"
140
- @aui.next.next.next.next.name.should=="RecipeFilter_label"
141
-
142
-
143
- n = AIO.first(:name => "RecipeFinder")
144
- 10.times {n=n.next}
145
- n.name.should=="French"
146
- 12.times {n=n.next}
147
- n.name.should=="RecipeCalories"
148
- 14.times {n=n.next}
149
- n.name.should=="Start"
150
- end
151
-
149
+ connect do |redis|
150
+ create_scenario
151
+ AUIControl.organize(@aui)
152
+ @aui.save!#.should==true
153
+ @aui.next.name.should=="RecipeFinder_description" # a label does forward the navigation
154
+ @aui.next.next.next.next.name.should=="RecipeCuisine"
155
+
156
+
157
+ n = MINT::AIO.first(:name => "RecipeFinder")
158
+ 10.times {n=n.next}
159
+ n.name.should=="Chinese"
160
+ 12.times {n=n.next}
161
+ n.name.should=="LowFat"
162
+ 8.times {n=n.next}
163
+ n.name.should=="Start"
164
+ end end
165
+
152
166
  it "should support previous navigation" do
153
-
154
- AUIControl.organize(@aui)
155
-
156
- @aui.save! # there is still a bug, because save results in false!!
157
- #.should==true
158
-
159
- n = AIO.first(:name => "Start")
160
- # n = @aui #
161
- # 36.times {n=n.next}
162
- #n.name.should=="Start"
163
-
164
- 10.times {n=n.previous}
165
- n.name.should=="Diet"
166
- 4.times {n=n.previous}
167
- n.name.should=="RecipeCalories"
168
- 22.times {n=n.previous}
169
- n.name.should=="RecipeFinder"
170
- end
167
+ connect do |redis|
168
+ create_scenario
169
+ AUIControl.organize(@aui)
170
+ @aui.save!
171
+
172
+ n = MINT::AIO.first(:name => "Start")
173
+ # n = @aui #
174
+ # 36.times {n=n.next}
175
+ #n.name.should=="Start"
176
+
177
+ 10.times {n=n.previous}
178
+ n.name.should=="RecipeCalories_choice"
179
+ 4.times {n=n.previous}
180
+ n.name.should=="Dessert"
181
+ 16.times {n=n.previous}
182
+ n.name.should=="RecipeFinder"
183
+ end end
171
184
 
172
- it 'should support next navigation in organize 2' do
173
- pending("get the organize2 function working")
174
- AUIControl.organize2(@aui)
175
- # @aui.save#.should==true
176
- # @aui.next.name.should=="RecipeFinder"
177
- # @aui.next.next.next.next.name.should=="RecipeFinder"
185
+ it 'should support next navigation in organize 2' do
186
+ pending "currently only one mode is supported"
187
+ connect do |redis|
188
+ create_scenario
189
+ AUIControl.organize2(@aui)
190
+ # @aui.save#.should==true
191
+ # @aui.next.name.should=="RecipeFinder"
192
+ # @aui.next.next.next.next.name.should=="RecipeFinder"
178
193
 
179
-
180
- n = AIO.first(:name => "RecipeFinder_label")
181
- 3.times {n=n.next}
182
- n.name.should=="RecipeSelection"
183
194
 
184
- n = AIO.first(:name => "RecipeCalories_label")
185
- 2.times {n=n.next}
186
- n.name.should=="RecipeCalories_choice"
195
+ n = MINT::AIO.first(:name => "RecipeFinder_label")
196
+ 3.times {n=n.next}
197
+ n.name.should=="RecipeSelection"
198
+
199
+ n = MINT::AIO.first(:name => "RecipeCalories_label")
200
+ 2.times {n=n.next}
201
+ n.name.should=="RecipeCalories_choice"
187
202
 
188
203
  # n = AIO.first(:name => "Start")
189
204
  # 7.times {n=n.next}
190
205
  # n.name.should=="FoundRecipes"
191
- end
192
-
206
+ end end
207
+
193
208
  it "should support previous navigation in organize 2" do
194
-
195
- AUIControl.organize2(@aui)
196
-
197
- @aui.save # there is still a bug, because save results in false!!
198
- #.should==true
199
-
200
- n = AIO.first(:name => "Start")
201
- # n = @aui #
202
- # 36.times {n=n.next}
203
- #n.name.should=="Start"
204
-
205
- 3.times {n=n.previous}
206
- n.name.should=="RecipeSelection_label"
207
-
208
- n = AIO.first(:name => "RecipeCalories")
209
- 2.times {n=n.previous}
210
- n.name.should=="RecipeCuisine"
209
+ pending "currently only one mode is supported"
210
+
211
+ connect do |redis|
212
+ create_scenario
213
+ AUIControl.organize2(@aui)
214
+
215
+ @aui.save # there is still a bug, because save results in false!!
216
+ #.should==true
217
+
218
+ n = MINT::AIO.first(:name => "Start")
219
+ # n = @aui #
220
+ # 36.times {n=n.next}
221
+ #n.name.should=="Start"
222
+
223
+ 3.times {n=n.previous}
224
+ n.name.should=="RecipeSelection_label"
225
+
226
+ n = MINT::AIO.first(:name => "RecipeCalories")
227
+ 2.times {n=n.previous}
228
+ n.name.should=="RecipeCuisine"
211
229
 
212
230
  # n = AIO.first(:name => "RecipeFinder")
213
231
  # 3.times {n=n.previous}
214
- # n.name.should=="RecipeFinder"
232
+ # n.name.should=="RecipeFinder"
233
+ end
215
234
  end
216
-
235
+
217
236
  it "should find the correct common aic for only one task in ETS" do
218
- AUIControl.find_common(["Start"]).should=="Start"
237
+ connect do |redis|
238
+ create_scenario
239
+ AUIControl.find_common(["Start"]).should=="Start"
240
+ end
219
241
  end
220
-
242
+
221
243
  it "should find the correct common aic for a given ETS" do
222
- AUIControl.find_common(["RecipeCuisine","RecipeCategory"]).should=="RecipeFilter"
223
- AUIControl.find_common(["Schweinebraten","RecipeSelection_description"]).should=="RecipeSelection"
224
- AUIControl.find_common(["Italian","Starter"]).should=="RecipeFilter"
225
- AUIControl.find_common(["RecipeFinder_label","RecipeFinder_description"]).should=="RecipeFinder"
226
- AUIControl.find_common(["Schweinebraten","RecipeCalories_choice","RecipeFinder_description"]).should=="RecipeFinder"
244
+ connect do |redis|
245
+ create_scenario
246
+ AUIControl.find_common(["RecipeCuisine","RecipeCategory"]).should=="RecipeFilter"
247
+ AUIControl.find_common(["Schweinebraten","RecipeSelection_description"]).should=="RecipeSelection"
248
+ AUIControl.find_common(["Italian","Starter"]).should=="RecipeFilter"
249
+ AUIControl.find_common(["RecipeFinder_label","RecipeFinder_description"]).should=="RecipeFinder"
250
+ AUIControl.find_common(["Schweinebraten","RecipeCalories_choice","RecipeFinder_description"]).should=="RecipeFinder"
251
+ end
227
252
  end
228
-
229
- it "should find the correct common AIC for a given ETS 2" do
230
- AUIControl.find_common(["RecipeCategory","Start", "FoundRecipes"]).should=="RecipeFinder"
231
- AUIControl.find_common(["RecipeCategory", "Start", "FoundRecipes", "RecipeCuisine", "RecipeCalories"]).should=="RecipeFinder"
253
+
254
+ it "should find the correct common AIContainer for a given ETS 2" do
255
+ connect do |redis|
256
+ create_scenario
257
+ AUIControl.find_common(["RecipeCategory","Start", "FoundRecipes"]).should=="RecipeFinder"
258
+
259
+ AUIControl.find_common(["RecipeCategory", "Start", "FoundRecipes", "RecipeCuisine", "RecipeCalories"]).should=="RecipeFinder"
260
+ end
232
261
  end
233
262
  end
234
- end
263
+ end