quby 4.0.4 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (182) hide show
  1. checksums.yaml +4 -4
  2. data/README.markdown +0 -1
  3. data/lib/quby.rb +2 -10
  4. data/lib/quby/answers/entities/answer.rb +4 -2
  5. data/lib/quby/answers/services/score_calculator.rb +1 -3
  6. data/lib/quby/engine.rb +0 -1
  7. data/lib/quby/questionnaires.rb +1 -0
  8. data/lib/quby/questionnaires/api.rb +5 -1
  9. data/lib/quby/questionnaires/deserializer.rb +441 -0
  10. data/lib/quby/questionnaires/dsl.rb +12 -15
  11. data/lib/quby/questionnaires/entities.rb +1 -0
  12. data/lib/quby/questionnaires/entities/charting/line_chart.rb +23 -0
  13. data/lib/quby/questionnaires/entities/charting/overview_chart.rb +3 -1
  14. data/lib/quby/questionnaires/entities/definition.rb +3 -5
  15. data/lib/quby/questionnaires/entities/fields.rb +0 -15
  16. data/lib/quby/questionnaires/entities/question.rb +9 -32
  17. data/lib/quby/questionnaires/entities/questionnaire.rb +4 -15
  18. data/lib/quby/questionnaires/entities/questions/checkbox_question.rb +0 -24
  19. data/lib/quby/questionnaires/entities/questions/date_question.rb +0 -8
  20. data/lib/quby/questionnaires/entities/score_calculation.rb +40 -3
  21. data/lib/quby/questionnaires/repos.rb +1 -0
  22. data/lib/quby/questionnaires/repos/bundle_disk_repo.rb +51 -0
  23. data/lib/quby/table_backend/range_tree.rb +0 -51
  24. data/lib/quby/version.rb +1 -1
  25. data/spec/features/tables_spec.rb +40 -0
  26. data/spec/fixtures/score_test.rb +4 -0
  27. data/spec/internal/log/test-events.log +183 -0
  28. data/spec/internal/log/test.log +5522 -0
  29. data/spec/internal/tmp/cache/assets/sprockets/v3.0/00/00nglkSepN01iGiDa7URmJtWQP-xSWffZb9wJgBqUr4.cache +2 -0
  30. data/spec/internal/tmp/cache/assets/sprockets/v3.0/1V/1VQnRlqKBL0MybpMmC3EVtA2s6-ZX-GSGs2Cza3g3kI.cache +1 -0
  31. data/spec/internal/tmp/cache/assets/sprockets/v3.0/1_/1_J_3havMjJDCz3iAQXAXXBh6tBQRJ3OpdWm3W46ss8.cache +1 -0
  32. data/spec/internal/tmp/cache/assets/sprockets/v3.0/4G/4gcYvPHmPX3fZw9xr6plMl5Hfbo2xTWwcD7T7lIlD4Y.cache +2 -0
  33. data/spec/internal/tmp/cache/assets/sprockets/v3.0/4_/4_FK6PMcF1eyIQx7RtVQ5t8c6X7smPQmJWNN5YTImVc.cache +1 -0
  34. data/spec/internal/tmp/cache/assets/sprockets/v3.0/4d/4Dd15Upcg8_kiEsx_5wpQNrjM1sCk0tGTtWGhtmCKpg.cache +1 -0
  35. data/spec/internal/tmp/cache/assets/sprockets/v3.0/4h/4hd8RzwlWb2IEeLLZN0s-3_sdJXtw6nu2k5baLb9vNs.cache +0 -0
  36. data/spec/internal/tmp/cache/assets/sprockets/v3.0/5X/5xFJleOz2sGyE9gbs8KPkToDiv3s9bwFzroBRcjPELY.cache +0 -0
  37. data/spec/internal/tmp/cache/assets/sprockets/v3.0/6Y/6y1tV_fKJP9YIQn-dF847aZ9kza1O7iyTEUht42D7nc.cache +0 -0
  38. data/spec/internal/tmp/cache/assets/sprockets/v3.0/6d/6dfYZY_DkQe892FZVDUbBbrINslzVUkLZePdnVxO3Ps.cache +1 -0
  39. data/spec/internal/tmp/cache/assets/sprockets/v3.0/6w/6WcYsWQCgw0z_URAWGhOsbiKXcqVxZ--ImazY5S-2Gk.cache +2 -0
  40. data/spec/internal/tmp/cache/assets/sprockets/v3.0/77/77EJjFGVCRzLbhJy6KZZUYe5w0LxsqZQcmFcHAbxKeQ.cache +1 -0
  41. data/spec/internal/tmp/cache/assets/sprockets/v3.0/7f/7fvhJnfiJknq6sA-MPtumXlL5qB-rfH__Heye13NyHc.cache +1 -0
  42. data/spec/internal/tmp/cache/assets/sprockets/v3.0/8W/8W6AwDwFqo6egmWyt6Cs0vf_XJbT2YxPs2sqbo0Q9kk.cache +2 -0
  43. data/spec/internal/tmp/cache/assets/sprockets/v3.0/8c/8cQ8uBhUhrouKwor0Z87dDCxyPbqbLvK8KEFEgjHxqM.cache +0 -0
  44. data/spec/internal/tmp/cache/assets/sprockets/v3.0/9L/9LJo1U9wQdfWrrn3HkNZTgIZc6jeHvWbGk8tJ4m_Qec.cache +1 -0
  45. data/spec/internal/tmp/cache/assets/sprockets/v3.0/9o/9oXJXZnA6F49i4EflydD0Ivx6dhSxGGDD69G-N5NSCg.cache +0 -0
  46. data/spec/internal/tmp/cache/assets/sprockets/v3.0/A1/a1jgtYtDHIb04Og07H6_XNmhXppaAnFiO88kgq80edQ.cache +1 -0
  47. data/spec/internal/tmp/cache/assets/sprockets/v3.0/AC/ACV6t4unw39Kpn2DnbBtHeJYLoAHyyBN1DTRXs6a2ik.cache +1 -0
  48. data/spec/internal/tmp/cache/assets/sprockets/v3.0/BO/BoVO8e1GTTGHfnJTOByDxMlvVi9fNGyOdSubqCbBITI.cache +2 -0
  49. data/spec/internal/tmp/cache/assets/sprockets/v3.0/Ba/babjk3aW-jBoEw_ERhmT5ZQprEqilJCWmImrvVskWk8.cache +0 -0
  50. data/spec/internal/tmp/cache/assets/sprockets/v3.0/Cg/cgb1vvOogMD0V1lqQ5k_mny7Z38rbqBdIumlGh5sZ_E.cache +0 -0
  51. data/spec/internal/tmp/cache/assets/sprockets/v3.0/Cw/CwjNk_RYiC93RW8vRs7fWsHcwKTg7uE9OLifRm3Y6WA.cache +2 -0
  52. data/spec/internal/tmp/cache/assets/sprockets/v3.0/DY/Dy1qsY0W-eyFR6RVKSCCli-XsitpaXD4DwTjXL86t2M.cache +1 -0
  53. data/spec/internal/tmp/cache/assets/sprockets/v3.0/Dk/DkGOwkJNeDdljv4b8QbwtPVrsghwYuA6EOxx1goEQg0.cache +1 -0
  54. data/spec/internal/tmp/cache/assets/sprockets/v3.0/FG/fGmVSU-v7aZV9-CLG5U2OmteGgWTuAotlFcwFyx4Eqs.cache +1 -0
  55. data/spec/internal/tmp/cache/assets/sprockets/v3.0/Fd/fDidWZjSZsPN4uAEyVYABV2WFCSR7AZE0l8U-9XOw7U.cache +0 -0
  56. data/spec/internal/tmp/cache/assets/sprockets/v3.0/G1/G1RRwpldS5MGQ5x-WHyPWzXJWDOd2qyWMMFumuU4-Ms.cache +1 -0
  57. data/spec/internal/tmp/cache/assets/sprockets/v3.0/GG/ggGfy_gZryUPmYwgenN3A4jv0q-buxyjCGdLB6wfHxQ.cache +1 -0
  58. data/spec/internal/tmp/cache/assets/sprockets/v3.0/GY/gYwYoJrifknCG-a0FXlM1NU6tUj1JXxm27s-a0uP_IE.cache +1 -0
  59. data/spec/internal/tmp/cache/assets/sprockets/v3.0/I6/i64Ysik0cyoTrYF0-O63B7sN3AdIgeoJ7zLh9pMC2u4.cache +0 -0
  60. data/spec/internal/tmp/cache/assets/sprockets/v3.0/Ic/ICKeOd4yOff3JGsfU1XliLgXfJtTPKSbXsqNVZAb1-Y.cache +1 -0
  61. data/spec/internal/tmp/cache/assets/sprockets/v3.0/J7/J75M1l--IMcCn-Wy7uWv17SWaj0DFaGiiwac63pENPQ.cache +1 -0
  62. data/spec/internal/tmp/cache/assets/sprockets/v3.0/Jh/JHPqsKZsrkvQg23ukphinYoViiIw3askwCMP8VrHTMk.cache +1 -0
  63. data/spec/internal/tmp/cache/assets/sprockets/v3.0/K9/k9tOCRdX5tsxa5LImq7MZk0WzC692t8tx5LzLln0l4Q.cache +0 -0
  64. data/spec/internal/tmp/cache/assets/sprockets/v3.0/LY/ly4TNAIbW9ghgXz8mxfmskR_6AkuiMiG-RIFGhewgQ0.cache +1 -0
  65. data/spec/internal/tmp/cache/assets/sprockets/v3.0/Lq/LQ9fP0wIqVc5s-AtP3ESWJr0qpkDe-VpTxpgYl-9FfU.cache +1 -0
  66. data/spec/internal/tmp/cache/assets/sprockets/v3.0/MO/MOmnpcaRW98Ke-zTOOCSZ0ODnnQntKhQr0vFc_un1_A.cache +1 -0
  67. data/spec/internal/tmp/cache/assets/sprockets/v3.0/OX/OxOBsUA5EpScoZgEt_UhsHzhu-GGmxKnHpCwnhbTwiM.cache +1 -0
  68. data/spec/internal/tmp/cache/assets/sprockets/v3.0/Ot/oTVAc3-iuSlg7XAM-YIAhw3cdc5yhgL2-tK3N7sfOfU.cache +0 -0
  69. data/spec/internal/tmp/cache/assets/sprockets/v3.0/PK/pKNcBOgAbCyIwsWIvnlmiPiFxrw6nUo_nTz7wWFDr80.cache +1 -0
  70. data/spec/internal/tmp/cache/assets/sprockets/v3.0/QB/QBMvSW7SYbYcm5lSjybgO7fhHDFIQjJWOvefH0MQC-A.cache +0 -0
  71. data/spec/internal/tmp/cache/assets/sprockets/v3.0/Qs/QSbtm1y8JKPV0MQkpiC0hEisaSjKZ3tp2AWHSrhO30Y.cache +1 -0
  72. data/spec/internal/tmp/cache/assets/sprockets/v3.0/Sp/SpyGDguFy3tp0sim1miZOehEDpE97oueO7wl3oUFYcE.cache +1 -0
  73. data/spec/internal/tmp/cache/assets/sprockets/v3.0/TW/TwtJPRSE9lmwTuSP0lezWSRSBp2u43zuF196FQcHY-c.cache +1 -0
  74. data/spec/internal/tmp/cache/assets/sprockets/v3.0/VX/Vxn9zv60MCKUBfRhrjefo-MEzFej81PPEutxTPQ4VLQ.cache +0 -0
  75. data/spec/internal/tmp/cache/assets/sprockets/v3.0/Vr/vrqPEzlsuORocHY0EbtGdFomRmrcoAa6wWSDMx642-Q.cache +2 -0
  76. data/spec/internal/tmp/cache/assets/sprockets/v3.0/WH/WHVQ0GBe51hbYqv2g7YYo7EIw9PSzt9-RqU7hKP2dc4.cache +1 -0
  77. data/spec/internal/tmp/cache/assets/sprockets/v3.0/_B/_B796ezRHfk7H8YKj7zr3-gRy6Mw2IVn2NbHu-k20ug.cache +1 -0
  78. data/spec/internal/tmp/cache/assets/sprockets/v3.0/_W/_Wh-7b1t-Xm19wg3KPtkXq7DOpohaL5OhnLggzJLpj4.cache +0 -0
  79. data/spec/internal/tmp/cache/assets/sprockets/v3.0/b2/B2y-2qTbQYKRm6_sCQ6qfUeVfl9rKXUvotTDm56w4bs.cache +1 -0
  80. data/spec/internal/tmp/cache/assets/sprockets/v3.0/bw/bwFR2MLpvJvPSAPJzSLWk6TUDCw5TlBFUUuq7z_Y9vg.cache +1 -0
  81. data/spec/internal/tmp/cache/assets/sprockets/v3.0/c7/c7ubvrHhbhAYh-K4srvM9EqwWdbWTLrsLMgjG5XQDbY.cache +1 -0
  82. data/spec/internal/tmp/cache/assets/sprockets/v3.0/cX/CXpMzZYfJy6HIOVXN0IyYilvy6J4CDgFZIwqKm8OQEU.cache +1 -0
  83. data/spec/internal/tmp/cache/assets/sprockets/v3.0/eN/EN0enu5dkKEnIz-DVCpbhkfeph7wImeXnlqb7SXMrjE.cache +1 -0
  84. data/spec/internal/tmp/cache/assets/sprockets/v3.0/fu/fuP9zP6C6rj650HLkypoTfYN2KD1ecB9HdtlbhbA2cg.cache +1 -0
  85. data/spec/internal/tmp/cache/assets/sprockets/v3.0/gr/gRPXI3EsVPwysy9YKW_6yDxaqRRr4Idxtexf7zCHECw.cache +1 -0
  86. data/spec/internal/tmp/cache/assets/sprockets/v3.0/h0/h0P63ZZdlSbtztDOe0V9r7jtCoy0L2bAf_iDNKLJ0nk.cache +1 -0
  87. data/spec/internal/tmp/cache/assets/sprockets/v3.0/i-/i-Or0Xuxbbm3-HdE_xGIf6sAx2vhUa3eVMpbT37lyEo.cache +1 -0
  88. data/spec/internal/tmp/cache/assets/sprockets/v3.0/iF/iFP67If98izMEAAMKnAFi2dWAb8TNlHNayZKNjXdAMs.cache +1 -0
  89. data/spec/internal/tmp/cache/assets/sprockets/v3.0/iH/Ih2svq5ul-xibfRUfd1fxigouli6U19Rf80FrTSoMak.cache +1 -0
  90. data/spec/internal/tmp/cache/assets/sprockets/v3.0/ka/Ka_YEbZNQxpS8XAA7xZturgPr2vLYQq60KK1uwou4Lo.cache +1 -0
  91. data/spec/internal/tmp/cache/assets/sprockets/v3.0/kq/KqkIGfAdJjTcr53lFl1aDAMUeqhhKdXGyTlHVlCz0R4.cache +1 -0
  92. data/spec/internal/tmp/cache/assets/sprockets/v3.0/mR/mRDPkwomGSfjpIWEKtPPBSx5cBHssvH8v0gCSI33P3Y.cache +1 -0
  93. data/spec/internal/tmp/cache/assets/sprockets/v3.0/n4/n4qaNjjNvKB0VAbVJlP_BjFlcLf70TsBzcIMc7VO9dw.cache +2 -0
  94. data/spec/internal/tmp/cache/assets/sprockets/v3.0/nY/nykt5oy2ExUYa8g1phLCDRqwb55BuUot5ZBbRdNuCCw.cache +2 -0
  95. data/spec/internal/tmp/cache/assets/sprockets/v3.0/nv/nvmgm4bOtxCbD6EA14ZIwDcYO8fxXOoEk_s7V-uRMMM.cache +1 -0
  96. data/spec/internal/tmp/cache/assets/sprockets/v3.0/oG/og5ypFjbFAX_nH7oxK6Bn5Ejh81BMDBSMxbGcL5ZbQs.cache +1 -0
  97. data/spec/internal/tmp/cache/assets/sprockets/v3.0/oO/oO4iBwOm5E7uLH39zeR8zun4eBM-WxZKvEMpIYKx6SU.cache +1 -0
  98. data/spec/internal/tmp/cache/assets/sprockets/v3.0/pN/PnQ-dEclV6jTDE4kkqw4G9dBpHArAgUnATOpRrQAsGc.cache +1 -0
  99. data/spec/internal/tmp/cache/assets/sprockets/v3.0/pe/pet4fFbc2Cm2SD_ZBO_s83Gey29EXE26u-7lwn2O8gM.cache +1 -0
  100. data/spec/internal/tmp/cache/assets/sprockets/v3.0/qo/Qoqb-JjTe1BiY4rICKHm5e6bsPt-DHXZc4ADXESjw2I.cache +1 -0
  101. data/spec/internal/tmp/cache/assets/sprockets/v3.0/qx/QXICLj9xx1EI9rBeXLXpKOeHGll_LBWHRWlpb1DK424.cache +1 -0
  102. data/spec/internal/tmp/cache/assets/sprockets/v3.0/rM/rMF4Y2UGkmBABLlC1eSSqb6y6g_Z3uUCLBtFvz_LoyI.cache +1 -0
  103. data/spec/internal/tmp/cache/assets/sprockets/v3.0/ty/ty1qAnpL07anYdhIJoiPYLcsWKejuzy6JaxU9mI7egw.cache +1 -0
  104. data/spec/internal/tmp/cache/assets/sprockets/v3.0/uH/UHs9nE45XS7v4QlMjSjhwHbqYIKC06FsEjMSMIfKanU.cache +1 -0
  105. data/spec/internal/tmp/cache/assets/sprockets/v3.0/v8/v8VXJ3AQom-JqxBYAB7tOjV-tt4IdDb6YyFEzlsWV8c.cache +1 -0
  106. data/spec/internal/tmp/cache/assets/sprockets/v3.0/vD/VDI2CxkTg7-DuMcLmofLvch0yukSl88oI_AjGgN-hQ8.cache +1 -0
  107. data/spec/internal/tmp/cache/assets/sprockets/v3.0/wq/wqhk46aZc1Bbb8gTCOZKxTvwTV0ANLSz8VdQYACo03E.cache +1 -0
  108. data/spec/internal/tmp/cache/assets/sprockets/v3.0/xy/Xy8Yk--iYZNupHMjUtYX1AQ0BppsvThCh_ZAizblCb0.cache +1 -0
  109. data/spec/internal/tmp/cache/assets/sprockets/v3.0/zu/zUCfHRTHprn06F5WxH6wp_BLs9-yhs-foc0j0Y7BYbg.cache +1 -0
  110. data/spec/internal/tmp/cache/assets/sprockets/v3.0/zx/ZX2IY3eKQjBy93tlH7_Xg7zGZKYuaQ-E8YPvtPT_4vM.cache +1 -0
  111. data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-35.705.html +1 -0
  112. data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-35.705.png +0 -0
  113. data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-36.005.html +1 -0
  114. data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-36.005.png +0 -0
  115. data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-36.276.html +1 -0
  116. data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-36.276.png +0 -0
  117. data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-36.556.html +1 -0
  118. data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-36.556.png +0 -0
  119. data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-36.818.html +1 -0
  120. data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-36.818.png +0 -0
  121. data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-37.083.html +1 -0
  122. data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-37.083.png +0 -0
  123. data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-37.350.html +1 -0
  124. data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-37.350.png +0 -0
  125. data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-37.620.html +1 -0
  126. data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-37.620.png +0 -0
  127. data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-37.885.html +1 -0
  128. data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-37.885.png +0 -0
  129. data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-38.152.html +1 -0
  130. data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-38.152.png +0 -0
  131. data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-28-14.063.html +207 -0
  132. data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-28-14.063.png +0 -0
  133. data/spec/quby/answers/entities/score_spec.rb +4 -0
  134. data/spec/quby/answers/services/answer_validations_spec.rb +8 -8
  135. data/spec/quby/answers/services/score_calculator_spec.rb +4 -14
  136. data/spec/quby/questionnaires/deserializer/questionnaire_spec.rb +237 -0
  137. data/spec/quby/questionnaires/dsl_spec.rb +0 -9
  138. data/spec/quby/questionnaires/entities/fields_spec.rb +3 -3
  139. data/spec/quby/questionnaires/entities/question_spec.rb +0 -8
  140. data/spec/quby/questionnaires/entities/questionnaire_spec.rb +2 -26
  141. data/spec/quby/table_backend/range_tree_spec.rb +46 -13
  142. data/spec/spec_helper.rb +1 -1
  143. metadata +230 -53
  144. data/lib/quby/lookup_table.rb +0 -29
  145. data/lib/quby/lookup_table_repo.rb +0 -24
  146. data/lib/quby/questionnaires/dsl/base.rb +0 -20
  147. data/lib/quby/questionnaires/dsl/calls_custom_methods.rb +0 -29
  148. data/lib/quby/questionnaires/dsl/charting/bar_chart_builder.rb +0 -18
  149. data/lib/quby/questionnaires/dsl/charting/chart_builder.rb +0 -91
  150. data/lib/quby/questionnaires/dsl/charting/line_chart_builder.rb +0 -57
  151. data/lib/quby/questionnaires/dsl/charting/overview_chart_builder.rb +0 -31
  152. data/lib/quby/questionnaires/dsl/charting/radar_chart_builder.rb +0 -18
  153. data/lib/quby/questionnaires/dsl/helpers.rb +0 -51
  154. data/lib/quby/questionnaires/dsl/panel_builder.rb +0 -80
  155. data/lib/quby/questionnaires/dsl/question_builder.rb +0 -40
  156. data/lib/quby/questionnaires/dsl/questionnaire_builder.rb +0 -260
  157. data/lib/quby/questionnaires/dsl/questions/base.rb +0 -179
  158. data/lib/quby/questionnaires/dsl/questions/checkbox_question_builder.rb +0 -20
  159. data/lib/quby/questionnaires/dsl/questions/date_question_builder.rb +0 -18
  160. data/lib/quby/questionnaires/dsl/questions/deprecated_question_builder.rb +0 -18
  161. data/lib/quby/questionnaires/dsl/questions/float_question_builder.rb +0 -21
  162. data/lib/quby/questionnaires/dsl/questions/integer_question_builder.rb +0 -21
  163. data/lib/quby/questionnaires/dsl/questions/radio_question_builder.rb +0 -20
  164. data/lib/quby/questionnaires/dsl/questions/select_question_builder.rb +0 -18
  165. data/lib/quby/questionnaires/dsl/questions/string_question_builder.rb +0 -20
  166. data/lib/quby/questionnaires/dsl/questions/text_question_builder.rb +0 -22
  167. data/lib/quby/questionnaires/dsl/score_builder.rb +0 -22
  168. data/lib/quby/questionnaires/dsl/standardized_panel_generators.rb +0 -33
  169. data/lib/quby/questionnaires/dsl/table_builder.rb +0 -48
  170. data/lib/quby/questionnaires/services/definition_validator.rb +0 -298
  171. data/spec/benchmarks/load_normscore_csv.rb +0 -18
  172. data/spec/quby/lookup_table_repo_spec.rb +0 -20
  173. data/spec/quby/lookup_table_spec.rb +0 -38
  174. data/spec/quby/questionnaires/dsl/calls_custom_methods_spec.rb +0 -38
  175. data/spec/quby/questionnaires/dsl/charting/bar_chart_builder_spec.rb +0 -41
  176. data/spec/quby/questionnaires/dsl/charting/chart_builder_spec.rb +0 -127
  177. data/spec/quby/questionnaires/dsl/charting/line_chart_builder_spec.rb +0 -66
  178. data/spec/quby/questionnaires/dsl/charting/radar_chart_builder_spec.rb +0 -41
  179. data/spec/quby/questionnaires/dsl/helpers_spec.rb +0 -80
  180. data/spec/quby/questionnaires/dsl/questionnaire_builder_spec.rb +0 -480
  181. data/spec/quby/questionnaires/services/definition_validator_spec.rb +0 -793
  182. data/spec/support/examples_for_chart_builders.rb +0 -59
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'quby/questionnaires/entities'
4
-
5
- require 'quby/questionnaires/dsl/questions/base'
6
- require 'quby/questionnaires/dsl/questions/checkbox_question_builder'
7
- require 'quby/questionnaires/dsl/questions/date_question_builder'
8
- require 'quby/questionnaires/dsl/questions/deprecated_question_builder'
9
- require 'quby/questionnaires/dsl/questions/float_question_builder'
10
- require 'quby/questionnaires/dsl/questions/integer_question_builder'
11
- require 'quby/questionnaires/dsl/questions/radio_question_builder'
12
- require 'quby/questionnaires/dsl/questions/select_question_builder'
13
- require 'quby/questionnaires/dsl/questions/string_question_builder'
14
- require 'quby/questionnaires/dsl/questions/text_question_builder'
15
-
16
- module Quby
17
- module Questionnaires
18
- module DSL
19
- module QuestionBuilder
20
- include Helpers
21
- BUILDERS = {
22
- 'string' => Questions::StringQuestionBuilder,
23
- 'textarea' => Questions::TextQuestionBuilder,
24
- 'integer' => Questions::IntegerQuestionBuilder,
25
- 'float' => Questions::FloatQuestionBuilder,
26
- 'radio' => Questions::RadioQuestionBuilder,
27
- 'scale' => Questions::RadioQuestionBuilder,
28
- 'select' => Questions::SelectQuestionBuilder,
29
- 'check_box' => Questions::CheckboxQuestionBuilder,
30
- 'date' => Questions::DateQuestionBuilder,
31
- 'hidden' => Questions::DeprecatedQuestionBuilder
32
- }
33
-
34
- def self.build(key, options = {}, &block)
35
- BUILDERS.fetch(options.fetch(:type).to_s).build(key, options, &block)
36
- end
37
- end
38
- end
39
- end
40
- end
@@ -1,260 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'quby/questionnaires/dsl/panel_builder'
4
- require 'quby/questionnaires/dsl/table_builder'
5
- require 'quby/questionnaires/dsl/question_builder'
6
- require 'quby/questionnaires/dsl/score_builder'
7
- require 'quby/questionnaires/dsl/charting/line_chart_builder'
8
- require 'quby/questionnaires/dsl/charting/radar_chart_builder'
9
- require 'quby/questionnaires/dsl/charting/bar_chart_builder'
10
- require 'quby/questionnaires/dsl/charting/overview_chart_builder'
11
-
12
- require_relative 'standardized_panel_generators'
13
-
14
- module Quby
15
- module Questionnaires
16
- module DSL
17
- class QuestionnaireBuilder
18
- prepend CallsCustomMethods
19
- include StandardizedPanelGenerators
20
- include Helpers
21
-
22
- def initialize(target_instance)
23
- @questionnaire = target_instance
24
- @default_question_options = {}
25
- @custom_methods = {}
26
- end
27
-
28
- def leave_page_alert(text)
29
- @questionnaire.leave_page_alert = text
30
- end
31
-
32
- def key(key)
33
- # no-op, key is now passed in to Questionnaire constructor
34
- end
35
-
36
- def roqua_keys(*keys)
37
- @questionnaire.roqua_keys = keys
38
- end
39
-
40
- def do_not_check_key_clashes
41
- @questionnaire.check_key_clashes = false
42
- end
43
-
44
- def do_not_check_score_keys_consistency
45
- @questionnaire.check_score_keys_consistency = false
46
- end
47
-
48
- def do_not_validate_html
49
- @questionnaire.validate_html = false
50
- end
51
-
52
- def title(title)
53
- @questionnaire.title = title
54
- end
55
-
56
- def description(description)
57
- @questionnaire.description = description
58
- end
59
-
60
- def outcome_description(description)
61
- @questionnaire.outcome_description = description
62
- end
63
-
64
- def short_description(description)
65
- @questionnaire.short_description = description
66
- end
67
-
68
- def version(key, notes)
69
- # nothing, for forward compatibility with v5 (quby-compiler)
70
- end
71
-
72
- def sbg_key(sbg_key)
73
- @questionnaire.sbg_key = sbg_key
74
- end
75
-
76
- def sbg_domain(sbg_code, outcome:, from: nil, till: nil, sbg_key: nil, primary: false)
77
- @questionnaire.sbg_domains << {
78
- sbg_code: sbg_code,
79
- from: from,
80
- till: till,
81
- outcome: outcome,
82
- sbg_key: sbg_key || @questionnaire.sbg_key,
83
- primary: primary
84
- }
85
- end
86
-
87
- def abortable
88
- @questionnaire.abortable = true
89
- end
90
-
91
- def allow_hotkeys(type = :all)
92
- @questionnaire.allow_hotkeys = type
93
- end
94
-
95
- def license(type, licensor: nil)
96
- @questionnaire.license = type
97
- @questionnaire.licensor = licensor
98
- end
99
-
100
- def language(language)
101
- @questionnaire.language = language
102
- end
103
-
104
- def respondent_types(*respondent_types)
105
- @questionnaire.respondent_types = respondent_types
106
- end
107
-
108
- def tags(*tags)
109
- @questionnaire.tags = tags
110
- end
111
-
112
- def outcome_regeneration_requested_at(timestamp)
113
- @questionnaire.outcome_regeneration_requested_at = timestamp
114
- end
115
-
116
- def deactivate_answers_requested_at(timestamp)
117
- @questionnaire.deactivate_answers_requested_at = timestamp
118
- end
119
-
120
- def enable_previous_questionnaire_button
121
- @questionnaire.enable_previous_questionnaire_button = true
122
- end
123
-
124
- def renderer_version(version)
125
- @questionnaire.renderer_version = version
126
- end
127
-
128
- def css(value)
129
- @questionnaire.extra_css += value
130
- end
131
-
132
- def allow_switch_to_bulk(value=true)
133
- @questionnaire.allow_switch_to_bulk = value
134
- end
135
-
136
- def default_answer_value(value)
137
- @questionnaire.default_answer_value = value
138
- end
139
-
140
- def panel(title = nil, options = {}, &block)
141
- panel = PanelBuilder.build(title, options.merge(default_panel_options), &block)
142
- @questionnaire.add_panel(panel)
143
- end
144
-
145
- def custom_method(key, &block)
146
- if PanelBuilder.new(nil, custom_methods: @custom_methods).respond_to? key
147
- fail 'Custom method trying to override existing method'
148
- end
149
- @custom_methods[key] = block
150
- end
151
-
152
- def import_lookup_tree(key)
153
- # nothing, for forwards compatibility with v5 (quby-compiler)
154
- end
155
-
156
- def add_lookup_tree(key, levels:, tree:)
157
- @questionnaire.lookup_tables[key] = Quby::TableBackend::RangeTree.new(levels: levels, tree: tree)
158
- end
159
-
160
- def default_question_options(options = {})
161
- @default_question_options.merge!(options)
162
- end
163
-
164
- # Short-circuit the question command to perform an implicit panel
165
- def question(key, options = {}, &block)
166
- panel(nil, default_panel_options) do
167
- question(key, @default_question_options.merge(options).merge(questionnaire: @questionnaire), &block)
168
- end
169
- end
170
-
171
- # Short-circuit the text command to perform an implicit panel
172
- def text(value, options = {})
173
- panel(nil, default_panel_options) do
174
- text(value, options)
175
- end
176
- end
177
-
178
- # Short-circuit the table command to perform an implicit panel
179
- def table(options = {}, &block)
180
- panel(nil, default_panel_options) do
181
- table(options, &block)
182
- end
183
- end
184
-
185
- # variable :totaal do
186
- # # Plain old Ruby code here, executed in the scope of the answer
187
- # # variables are private to the score calculation
188
- # q01 + q02 + q03
189
- # end
190
- def variable(key, options = {}, &block)
191
- s = ScoreBuilder.new(key, options, &block)
192
- @questionnaire.add_score_calculation s.build
193
- end
194
-
195
- def score(key, options = {}, &block)
196
- @questionnaire.errors.add "Score #{key}", 'misses label in score call' if options[:label].blank?
197
- schema = options.delete(:schema)
198
- @questionnaire.add_score_schema(key, options[:label], schema) if schema.present?
199
- variable(key, options.reverse_merge(score: true), &block)
200
- end
201
-
202
- def score_schema(key, label, options)
203
- @questionnaire.add_score_schema(key, label, options)
204
- end
205
-
206
- def attention(options = {}, &block)
207
- variable(:attention, options.reverse_merge(action: true), &block)
208
- end
209
-
210
- def alarm(options = {}, &block)
211
- variable(:alarm, options.reverse_merge(action: true), &block)
212
- end
213
-
214
- def completion(options = {}, &block)
215
- variable(:completion, options.reverse_merge(completion: true), &block)
216
- end
217
-
218
- def overview_chart(*args, &block)
219
- raise "Cannot define more than one overview chart" if @questionnaire.charts.overview.present?
220
- builder = OverviewChartBuilder.new(@questionnaire, *args)
221
- @questionnaire.charts.overview = builder.build(&block)
222
- end
223
-
224
- def line_chart(*args, &block)
225
- builder = LineChartBuilder.new(@questionnaire, *args)
226
- @questionnaire.add_chart(builder.build(&block))
227
- end
228
-
229
- def bar_chart(*args, &block)
230
- builder = BarChartBuilder.new(@questionnaire, *args)
231
- @questionnaire.add_chart(builder.build(&block))
232
- end
233
-
234
- def radar_chart(*args, &block)
235
- builder = RadarChartBuilder.new(@questionnaire, *args)
236
- @questionnaire.add_chart(builder.build(&block))
237
- end
238
-
239
- def flag(flag_options)
240
- @questionnaire.add_flag flag_options
241
- end
242
-
243
- def textvar(textvar_options)
244
- @questionnaire.add_textvar textvar_options
245
- end
246
-
247
- def outcome_table(table_options)
248
- @questionnaire.add_outcome_table table_options
249
- end
250
-
251
- private
252
-
253
- def default_panel_options
254
- {questionnaire: @questionnaire, default_question_options: @default_question_options,
255
- custom_methods: @custom_methods}
256
- end
257
- end
258
- end
259
- end
260
- end
@@ -1,179 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Quby
4
- module Questionnaires
5
- module DSL
6
- module Questions
7
- class Base < ::Quby::Questionnaires::DSL::Base
8
- attr_reader :key
9
- attr_reader :title
10
- attr_reader :type
11
- attr_reader :questionnaire
12
-
13
- def initialize(key, options = {})
14
- @questionnaire = options[:questionnaire]
15
- end
16
-
17
- def build
18
- @question
19
- end
20
-
21
- def title(value)
22
- @question.title = value
23
- end
24
-
25
- def context_free_title(value)
26
- @question.context_free_title = value
27
- end
28
-
29
- def description(value)
30
- @question.description = value
31
- end
32
-
33
- def presentation(value)
34
- @question.presentation = value
35
- end
36
-
37
- def hidden(value = true)
38
- @question.hidden = value
39
- end
40
-
41
- def depends_on(keys)
42
- @question.set_depends_on(keys)
43
- end
44
-
45
- def default_position(value)
46
- @question.default_position = value
47
- end
48
-
49
- def validates_presence_of_answer(options = {})
50
- @question.validations ||= []
51
- @question.validations << {type: :requires_answer}.reverse_merge(options)
52
- end
53
- end
54
-
55
- module RegexpValidations
56
- def validates_format_with(regexp, options = {})
57
- @question.validations ||= []
58
- @question.validations << {type: :regexp, matcher: regexp}.reverse_merge(options)
59
- end
60
- end
61
-
62
- module MinMaxValidations
63
- def validates_minimum(value, options = {})
64
- subtype = @question.type == :date ? :date : :number
65
- @question.validations ||= []
66
- @question.validations << {type: :minimum, value: value, subtype: subtype}.reverse_merge(options)
67
- end
68
-
69
- def validates_maximum(value, options = {})
70
- subtype = @question.type == :date ? :date : :number
71
- @question.validations ||= []
72
- @question.validations << {type: :maximum, value: value, subtype: subtype}.reverse_merge(options)
73
- end
74
-
75
- def validates_in_range(range, options = {})
76
- subtype = @question.type == :date ? :date : :number
77
- @question.validations ||= []
78
- @question.validations << {type: :minimum, value: range.first, subtype: subtype}.reverse_merge(options)
79
- @question.validations << {type: :maximum, value: range.last, subtype: subtype}.reverse_merge(options)
80
- end
81
- end
82
-
83
- module Labeling
84
- def label(value)
85
- @question.labels << value
86
- end
87
-
88
- # deprecated
89
- def left_label(value)
90
- @question.labels.unshift(value)
91
- end
92
-
93
- # deprecated
94
- def right_label(value)
95
- @question.labels << value
96
- end
97
- end
98
-
99
- module MultipleChoice
100
- def option(key, options = {}, &block)
101
- question_option = Entities::QuestionOption.new(key, @question, options)
102
- if @questionnaire.key_in_use?(question_option.input_key) || @question.key_in_use?(question_option.input_key)
103
- fail "#{questionnaire.key}:#{@question.key}:#{question_option.key}: " \
104
- "A question or option with input key #{question_option.input_key} is already defined."
105
- end
106
-
107
- @question.options << question_option
108
- instance_eval(&block) if block
109
- end
110
- end
111
-
112
- module Subquestions
113
- def initialize(key, options = {}, &block)
114
- super
115
- @default_question_options = options[:default_question_options] || {}
116
- @title_question = nil
117
- end
118
-
119
- def build
120
- if @title_question
121
- @question.options.last.questions << @title_question
122
- @title_question = nil
123
- end
124
-
125
- super
126
- end
127
-
128
- def title_question(key, options = {}, &block)
129
- options = @default_question_options.merge({depends_on: @question.key,
130
- questionnaire: @questionnaire,
131
- parent: @question,
132
- presentation: :next_to_title,
133
- allow_blank_titles: @question.allow_blank_titles}.merge(options))
134
-
135
- check_question_keys_uniqueness key, options, @questionnaire
136
-
137
- question = QuestionBuilder.build(key, options, &block)
138
-
139
- @questionnaire.register_question(question)
140
- @title_question = question
141
- end
142
-
143
- def question(key, options = {}, &block)
144
- options = @default_question_options.merge(options)
145
- .merge(questionnaire: @questionnaire,
146
- parent: @question,
147
- parent_option_key: @question.options.last.key)
148
-
149
- check_question_keys_uniqueness key, options, @questionnaire
150
-
151
- question = QuestionBuilder.build(key, options, &block)
152
-
153
- @questionnaire.register_question(question)
154
- @question.options.last.questions << question
155
- end
156
- end
157
-
158
- module InnerTitles
159
- def inner_title(value)
160
- question_option = Entities::QuestionOption.new(nil, @question, inner_title: true, description: value)
161
- @question.options << question_option
162
- end
163
- end
164
-
165
- module Units
166
- def unit(value)
167
- @question.unit = value
168
- end
169
- end
170
-
171
- module Sizes
172
- def size(value)
173
- @question.size = value
174
- end
175
- end
176
- end
177
- end
178
- end
179
- end