know_more 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (161) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +130 -0
  4. data/Rakefile +26 -0
  5. data/app/assets/config/know_more_manifest.js +2 -0
  6. data/app/assets/javascripts/know_more/application.js +13 -0
  7. data/app/assets/stylesheets/know_more/application.css +15 -0
  8. data/app/controllers/know_more/application_controller.rb +5 -0
  9. data/app/controllers/know_more/controller_helpers.rb +14 -0
  10. data/app/controllers/know_more/questionnaire_controller.rb +55 -0
  11. data/app/helpers/know_more/application_helper.rb +4 -0
  12. data/app/jobs/know_more/application_job.rb +4 -0
  13. data/app/mailers/know_more/application_mailer.rb +6 -0
  14. data/app/models/concerns/know_more/application_record.rb +5 -0
  15. data/app/models/concerns/know_more/questionnaire.rb +7 -0
  16. data/app/views/layouts/know_more/application.html.erb +14 -0
  17. data/config/routes.rb +7 -0
  18. data/lib/generators/know_more/init_generator.rb +13 -0
  19. data/lib/generators/know_more/install_generator.rb +45 -0
  20. data/lib/generators/know_more/templates/concerns.rb.erb +23 -0
  21. data/lib/generators/know_more/templates/erb/page_template.erb +39 -0
  22. data/lib/generators/know_more/templates/haml/page_template.erb +32 -0
  23. data/lib/generators/know_more/templates/initializer.rb.erb +4 -0
  24. data/lib/generators/know_more/templates/models/migration.rb.erb +9 -0
  25. data/lib/generators/know_more/templates/models/model.rb.erb +3 -0
  26. data/lib/know_more.rb +6 -0
  27. data/lib/know_more/base.rb +24 -0
  28. data/lib/know_more/configuration.rb +9 -0
  29. data/lib/know_more/engine.rb +16 -0
  30. data/lib/know_more/version.rb +3 -0
  31. data/lib/tasks/know_more_tasks.rake +4 -0
  32. data/spec/rails_helper.rb +57 -0
  33. data/spec/spec_helper.rb +99 -0
  34. data/spec/test_app/Rakefile +6 -0
  35. data/spec/test_app/app/assets/config/manifest.js +5 -0
  36. data/spec/test_app/app/assets/javascripts/application.js +15 -0
  37. data/spec/test_app/app/assets/javascripts/cable.js +13 -0
  38. data/spec/test_app/app/assets/stylesheets/application.css +15 -0
  39. data/spec/test_app/app/channels/application_cable/channel.rb +4 -0
  40. data/spec/test_app/app/channels/application_cable/connection.rb +4 -0
  41. data/spec/test_app/app/controllers/application_controller.rb +8 -0
  42. data/spec/test_app/app/controllers/concerns/know_more/questionnaire_controller_concerns.rb +42 -0
  43. data/spec/test_app/app/controllers/welcome_controller.rb +5 -0
  44. data/spec/test_app/app/helpers/application_helper.rb +2 -0
  45. data/spec/test_app/app/jobs/application_job.rb +2 -0
  46. data/spec/test_app/app/mailers/application_mailer.rb +4 -0
  47. data/spec/test_app/app/models/application_record.rb +3 -0
  48. data/spec/test_app/app/models/questionnaire.rb +3 -0
  49. data/spec/test_app/app/views/know_more/questionnaire/step1.html.haml +29 -0
  50. data/spec/test_app/app/views/know_more/questionnaire/step2.html.haml +31 -0
  51. data/spec/test_app/app/views/know_more/questionnaire/step3.html.haml +30 -0
  52. data/spec/test_app/app/views/layouts/application.html.erb +14 -0
  53. data/spec/test_app/app/views/layouts/mailer.html.erb +13 -0
  54. data/spec/test_app/app/views/layouts/mailer.text.erb +1 -0
  55. data/spec/test_app/app/views/welcome/hello.html.erb +1 -0
  56. data/spec/test_app/bin/bundle +3 -0
  57. data/spec/test_app/bin/rails +4 -0
  58. data/spec/test_app/bin/rake +4 -0
  59. data/spec/test_app/bin/setup +34 -0
  60. data/spec/test_app/bin/update +29 -0
  61. data/spec/test_app/config.ru +5 -0
  62. data/spec/test_app/config/application.rb +23 -0
  63. data/spec/test_app/config/boot.rb +5 -0
  64. data/spec/test_app/config/cable.yml +9 -0
  65. data/spec/test_app/config/database.yml +25 -0
  66. data/spec/test_app/config/environment.rb +5 -0
  67. data/spec/test_app/config/environments/development.rb +54 -0
  68. data/spec/test_app/config/environments/production.rb +86 -0
  69. data/spec/test_app/config/environments/test.rb +42 -0
  70. data/spec/test_app/config/initializers/application_controller_renderer.rb +6 -0
  71. data/spec/test_app/config/initializers/assets.rb +11 -0
  72. data/spec/test_app/config/initializers/backtrace_silencers.rb +7 -0
  73. data/spec/test_app/config/initializers/cookies_serializer.rb +5 -0
  74. data/spec/test_app/config/initializers/filter_parameter_logging.rb +4 -0
  75. data/spec/test_app/config/initializers/inflections.rb +16 -0
  76. data/spec/test_app/config/initializers/know_more.rb +4 -0
  77. data/spec/test_app/config/initializers/mime_types.rb +4 -0
  78. data/spec/test_app/config/initializers/new_framework_defaults.rb +24 -0
  79. data/spec/test_app/config/initializers/session_store.rb +3 -0
  80. data/spec/test_app/config/initializers/wrap_parameters.rb +14 -0
  81. data/spec/test_app/config/locales/en.yml +23 -0
  82. data/spec/test_app/config/puma.rb +47 -0
  83. data/spec/test_app/config/routes.rb +5 -0
  84. data/spec/test_app/config/secrets.yml +22 -0
  85. data/spec/test_app/config/spring.rb +6 -0
  86. data/spec/test_app/db/development.sqlite3 +0 -0
  87. data/spec/test_app/db/migrate/20161027141359_create_questionnaire.rb +12 -0
  88. data/spec/test_app/db/schema.rb +24 -0
  89. data/spec/test_app/lib/know_more/questionnaire_controller_concerns.rb +21 -0
  90. data/spec/test_app/log/development.log +3813 -0
  91. data/spec/test_app/public/404.html +67 -0
  92. data/spec/test_app/public/422.html +67 -0
  93. data/spec/test_app/public/500.html +66 -0
  94. data/spec/test_app/public/apple-touch-icon-precomposed.png +0 -0
  95. data/spec/test_app/public/apple-touch-icon.png +0 -0
  96. data/spec/test_app/public/favicon.ico +0 -0
  97. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/-M/-Mhn0x6IA3ei53dCjTNB4QapIeIWnhFjjvWlObqhWxY.cache +1 -0
  98. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/-h/-hPQhUvmVonbzE86tGolE7GRuNFFf3NsKvt1mwHwIg0.cache +0 -0
  99. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/0S/0SvZGDW10EU46QZko9M15Exl1RDa9Ud5osSt660CuzQ.cache +0 -0
  100. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/24/24PpPX2bi_nuVnh3Bx8Nqj-UO3-1dbdgtFa6v7iPaLo.cache +1 -0
  101. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/6P/6PoXC3inbHQs_iJ8sp-AEYUgrRllcZHE8stF6_FuI2s.cache +3 -0
  102. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/8M/8M6Y8ZU8aBj7dfklYKmqgzKWfv5nIDcx4jR-cMu9Hgc.cache +0 -0
  103. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/Ao/Ao0OdzieB2BHIS0J1OX5-CzoMHHagT-hWe_ospTLEz4.cache +1 -0
  104. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/Ca/Ca7J7u8QQVfncKxGfYDjkhl4ezOotD2PbJTwmY88R08.cache +0 -0
  105. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/D7/D7JZQRMd7o6Oa3O8XYxxcWv4NGy5XUHEBQjbTtTIw0w.cache +1 -0
  106. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/Df/DfqHLjOcuVNA6fgR3rrM8D7q4VveBYvUn9OaxdDb2aI.cache +2 -0
  107. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/E8/E869Vssa93t7BK-iyJUAbuMcVw65khT8ZkFTdkgPoNA.cache +1 -0
  108. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/Eu/EuUPUxyK1i0O9kRow6J2gQlEgannj8ele8bYrOH0WkE.cache +0 -0
  109. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/F5/F5aTSXaWVMd07oSPX3KS5DuFnGw2SlYAYvIl2rt3xKU.cache +2 -0
  110. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/F6/F69NGMZogprXR3htKJ6d0kVkFS9EgtSIrMd_Rv4lQo4.cache +1 -0
  111. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/FW/FWd91hU2C6pptRvlqp8-fMKs0Pgd_JfiT3TPiYXBGoc.cache +1 -0
  112. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/FW/FWlz-VvryvvUjDXSLRDM06krdCHZ6jb2HNM8n2lYvno.cache +1 -0
  113. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/Fh/FhoIJOA98Fe9tpfSEnFORkI01I9KVpmYAx_mXC4gQYo.cache +2 -0
  114. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/G4/G4f_wqyGuSDH5PqO-cG6noP4D5EK3Kylzj3yOte-Z3E.cache +3 -0
  115. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/Jj/Jj08SeolaHESqwfZBGZ0tcinAfB1oMbMugBODKZGtmk.cache +1 -0
  116. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/KU/KUHCmze6iHkktV-xkd_pe8zKkrea7B0GA0AyNzPi8VI.cache +2 -0
  117. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/Ky/KyLnrp_TTwObMeq3b1zzPd9lvWbGgM05pRhE6K26DSw.cache +1 -0
  118. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/LZ/LZodg9A2YVhhIboloe0zr_qCYE_SsB41W42B9a16AvQ.cache +0 -0
  119. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/M6/M66hYfGZ7alPDFVsvZX20gGKa3hoXU4ZX57eWmf-8Q0.cache +1 -0
  120. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/Mb/MbA44Lqly0ejzpXgTsIIH7tnssjDcn_I4grw6t_PNFs.cache +1 -0
  121. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/Nh/Nhqfo87al4XtybNfUPjhR8idEE6eKcbsVOuQtiPqaz8.cache +1 -0
  122. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/On/OnToO1iuSf982Y8PilnSN969yImwD-JWuEdGGU0r4SA.cache +1 -0
  123. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/Q7/Q7Dl2on4OdmHONyXUohOukBoSZQfxX7CBNaiLRxrn14.cache +0 -0
  124. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/QC/QCkY9HlLiOM3vpgoGX8oJvozZ0Cq6p0b6WD2lcwZT5k.cache +0 -0
  125. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/QD/QDMAHR127EpeGWrWbzn7QnNqnYZtH2UUV6ntkBhiUMQ.cache +1 -0
  126. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/Qr/QrbG3GcCwmKIApW0fC5o0iM8upyezEp0NrzhSENYwcs.cache +0 -0
  127. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/Qx/Qx8y8tq3IiNr7Ot7JGhxnFwDma3Bf6LfjWyVxcYpTzk.cache +1 -0
  128. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/S2/S2XG29YYvgWCmY1ULahjx-TNWdzenEHf2EpX5LK_--w.cache +1 -0
  129. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/SH/SHPuXI1rKYgLVra3KoGrRjevUg0nzNAxzNU_v_dPb6U.cache +0 -0
  130. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/Sa/Saez4IhtZGelgfIYfe8FAkCBAh9dUeKVGEmFBTITnmI.cache +0 -0
  131. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/Sx/Sx94HsfcuxHDyseiRaSVTRLw-adn2lGZ8TnytfXZhl8.cache +0 -0
  132. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/W1/W1FyFe4zmJy2UId1DPKUFLtCO2T6Vq5RuBrUMwa5pXQ.cache +1 -0
  133. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/WV/WVC-q51wcBaLCMfUdFscQNqh4o2O9YDD0irl3pEEHII.cache +1 -0
  134. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/XL/XL3leJ5pQba8fRAqDA-mBiHbcBIBiHf9jeJ3xWfrlz8.cache +2 -0
  135. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/Y2/Y2K6yjpdhJfMIKPU5YceGshr_gR1QQG8qmT6gRut14U.cache +2 -0
  136. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/bD/bDD6X4R7ftAQlH7K_0T5HKcaToTfjQ6kSpZZRYBWQmk.cache +3 -0
  137. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/dA/dAosGjt-VaAhIfQVDjUoRM6eI9QUSh1E5X3gnrHu8Ww.cache +0 -0
  138. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/dR/dRYE4MTApQWxIGfHaTh_uT0mmSKhlas_eGk6v3IjScA.cache +1 -0
  139. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/eI/eIEIza6BGcz1akXfzNqRW2GEIb_B4zrgDemllbjKLqI.cache +1 -0
  140. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/f3/f3IV7AH-agFherPIRg6gz-gH_q-pbMlmZYvwA-wgh28.cache +0 -0
  141. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/hC/hCBrZ9RI110j1EhVdHOP-z9uOZwRm9UvutWo6eY1N_g.cache +1 -0
  142. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/iT/iThi-stKgqJGA0IjU1RUrH30vN1eQNdVqLgVCK224mI.cache +1 -0
  143. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/lx/lxV4gmPmZnPnnIMP-IREWrSMXIZM15bHONEqvOQe550.cache +1 -0
  144. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/mS/mSro6DRbSWbZLjFnik8cEUvxGkkHnx30jmzgf90kWqw.cache +1 -0
  145. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/n_/n_xYqQYhwEMQknb3jFQnjlxxBE9TzMNHCdJ-bEyZFIw.cache +2 -0
  146. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/ne/neMAKY2HHX-jQtV34JCN-wAv1gZ4dBtdikwxulpNIU4.cache +1 -0
  147. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/nx/nxTv3sKVUQZADJyM3dPaVmUA78MIsMLD_K279yN_GsI.cache +2 -0
  148. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/oE/oELcpQtiEEZd7OlWIFZoxZmXO6i_0KQDJ9gSO8IMrAo.cache +1 -0
  149. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/oJ/oJN9HcCgMMjADHFGldRpNYSVpaR5KCRFVjou3lEGP_o.cache +1 -0
  150. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/qP/qPmv5snMrDw830S6hSICDcnIy7kVEWoFKXhGKT38lG4.cache +2 -0
  151. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/rD/rDC4aip_9aDeTYE-ixXTrw4TblEowO3UGk8BhYb0UXQ.cache +1 -0
  152. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/rG/rG5N7yI8mYTZmoFfvUWEF8AwRkSz7iwzbzjZgtyD-6Y.cache +1 -0
  153. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/rz/rzYbqBDzAezz5y7RBSX5kN3TmuBZYZzvh4AXBe6I1OQ.cache +2 -0
  154. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/uX/uXdmeUJXaGu-MF3ntZ6-oMn3I-G9Ub6r2UZzqMnqIyU.cache +2 -0
  155. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/uc/uc9nNzmH9YYkXWiQWt8sLWG3L6bnPakFQd3qAj7GI8Q.cache +0 -0
  156. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/wa/waRa6Y4GPI3rPY6lN66-DRb7GRW_AQcee1TP2qFEZzI.cache +0 -0
  157. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/x-/x-CSdYi9brwT6G4vAolSeuvGSaszo1oumOyPyfno7Zk.cache +0 -0
  158. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/x7/x7PYh8DJvPykcEqpVab2vcY9-GFz-3cqtoMlRAu94Uc.cache +2 -0
  159. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/xB/xBNFQ5zX18WjcjNby1R4X3UlLjHy1vAKBCFGDpHMpQE.cache +1 -0
  160. data/spec/test_app/tmp/cache/assets/sprockets/v3.0/xp/xpdRk6Yq3nW29DONCODCnLPuF9MWzGSavMHHQSUshjQ.cache +1 -0
  161. metadata +408 -0
@@ -0,0 +1,39 @@
1
+ <h1>
2
+ Step <%= @n %>
3
+ </h1>
4
+ <%%= form_for @questionnaire, url: questionnaire_step<%= @n %>_path do |f| %>
5
+ <%%= hidden_field_tag :direction, 'next' %>
6
+ <% if @n > 1 %>
7
+ <%%= link_to :previous, "javascript:void(0)", id: 'knowmore-previous', method: :post %>
8
+ <% end %>
9
+ <% if @n < KnowMore.config.pages %>
10
+ <%%= link_to :next, "javascript:void(0)", id: 'knowmore-next', method: :post %>
11
+ <% else %>
12
+ <%%= link_to :done, "javascript:void(0)", id: 'knowmore-next', method: :post %>
13
+ <% end %>
14
+ <%% end %>
15
+
16
+ <script>
17
+ var $directionInput = $('input#direction'),
18
+ $previousLink = $('a#knowmore-previous'),
19
+ $nextLink = $('a#knowmore-next');
20
+
21
+ if($previousLink != null){
22
+ $previousLink.on('click', function(e){
23
+ e.preventDefault();
24
+ $directionInput.val('previous');
25
+ $('form').submit();
26
+ });
27
+ }
28
+ if($nextLink != null){
29
+ $nextLink.on('click', function(e){
30
+ e.preventDefault();
31
+ $directionInput.val('next');
32
+ $('form').submit();
33
+ });
34
+ }
35
+
36
+ </script>
37
+
38
+
39
+
@@ -0,0 +1,32 @@
1
+ %h1
2
+ Step <%= @n %>
3
+ = form_for @questionnaire, url: questionnaire_step<%= @n %>_path do |f|
4
+ = hidden_field_tag :direction, 'next'
5
+ <% if @n > 1 %>
6
+ = link_to :previous, "javascript:void(0)", id: 'knowmore-previous', method: :post
7
+ <% end %>
8
+ <% if @n < KnowMore.config.pages %>
9
+ = link_to :next, "javascript:void(0)", id: 'knowmore-next', method: :post
10
+ <% else %>
11
+ = link_to :done, "javascript:void(0)", id: 'knowmore-next', method: :post
12
+ <% end %>
13
+
14
+ :javascript
15
+ var $directionInput = $('input#direction'),
16
+ $previousLink = $('a#knowmore-previous'),
17
+ $nextLink = $('a#knowmore-next');
18
+
19
+ if($previousLink != null){
20
+ $previousLink.on('click', function(e){
21
+ e.preventDefault();
22
+ $directionInput.val('previous');
23
+ $('form').submit();
24
+ });
25
+ }
26
+ if($nextLink != null){
27
+ $nextLink.on('click', function(e){
28
+ e.preventDefault();
29
+ $directionInput.val('next');
30
+ $('form').submit();
31
+ });
32
+ }
@@ -0,0 +1,4 @@
1
+ KnowMore.configure do |config|
2
+ config.pages = 3
3
+ config.redirect_url = '/'
4
+ end
@@ -0,0 +1,9 @@
1
+ class Create<%= @model_name.camelize%> <%= %q(<)%> ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :<%= @model_name.underscore.pluralize %> do |t|
4
+ t.integer :progress, default: 0
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ class <%= @model_name.camelize%> <%= %q(<)%> ActiveRecord::Base
2
+ include KnowMore::Questionnaire
3
+ end
@@ -0,0 +1,6 @@
1
+ require "know_more/engine"
2
+ require "know_more/base"
3
+
4
+ module KnowMore
5
+ include Base
6
+ end
@@ -0,0 +1,24 @@
1
+ require 'know_more/configuration'
2
+
3
+ module KnowMore
4
+ module Base
5
+ class << self
6
+ def included(base)
7
+ base.extend ClassMethods
8
+
9
+ # set default values
10
+ base.config.pages = 3
11
+ end
12
+ end
13
+
14
+ module ClassMethods
15
+ def config
16
+ Configuration.instance
17
+ end
18
+ def configure
19
+ return unless block_given?
20
+ yield Configuration.instance
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,9 @@
1
+ module KnowMore
2
+ class Configuration
3
+ include Singleton
4
+ attr_accessor :pages
5
+
6
+ # the url when finish the questionnaire
7
+ attr_accessor :redirect_url
8
+ end
9
+ end
@@ -0,0 +1,16 @@
1
+ module KnowMore
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace KnowMore
4
+
5
+ config.generators do |g|
6
+ g.test_framework :rspec
7
+ g.fixture_replacement :factory_girl, :dir => 'spec/factories'
8
+ end
9
+
10
+ initializer 'know_more.route' do |app|
11
+ app.routes.append do
12
+ mount KnowMore::Engine => "/know_more", as: 'know_more'
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,3 @@
1
+ module KnowMore
2
+ VERSION = "0.9.1"
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :know_more do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,57 @@
1
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ ENV['RAILS_ENV'] ||= 'test'
3
+ require File.expand_path('../../config/environment', __FILE__)
4
+ # Prevent database truncation if the environment is production
5
+ abort("The Rails environment is running in production mode!") if Rails.env.production?
6
+ require 'spec_helper'
7
+ require 'rspec/rails'
8
+ # Add additional requires below this line. Rails is not loaded until this point!
9
+
10
+ # Requires supporting ruby files with custom matchers and macros, etc, in
11
+ # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
12
+ # run as spec files by default. This means that files in spec/support that end
13
+ # in _spec.rb will both be required and run as specs, causing the specs to be
14
+ # run twice. It is recommended that you do not name files matching this glob to
15
+ # end with _spec.rb. You can configure this pattern with the --pattern
16
+ # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
17
+ #
18
+ # The following line is provided for convenience purposes. It has the downside
19
+ # of increasing the boot-up time by auto-requiring all files in the support
20
+ # directory. Alternatively, in the individual `*_spec.rb` files, manually
21
+ # require only the support files necessary.
22
+ #
23
+ # Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
24
+
25
+ # Checks for pending migration and applies them before tests are run.
26
+ # If you are not using ActiveRecord, you can remove this line.
27
+ ActiveRecord::Migration.maintain_test_schema!
28
+
29
+ RSpec.configure do |config|
30
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
31
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
32
+
33
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
34
+ # examples within a transaction, remove the following line or assign false
35
+ # instead of true.
36
+ config.use_transactional_fixtures = true
37
+
38
+ # RSpec Rails can automatically mix in different behaviours to your tests
39
+ # based on their file location, for example enabling you to call `get` and
40
+ # `post` in specs under `spec/controllers`.
41
+ #
42
+ # You can disable this behaviour by removing the line below, and instead
43
+ # explicitly tag your specs with their type, e.g.:
44
+ #
45
+ # RSpec.describe UsersController, :type => :controller do
46
+ # # ...
47
+ # end
48
+ #
49
+ # The different available types are documented in the features, such as in
50
+ # https://relishapp.com/rspec/rspec-rails/docs
51
+ config.infer_spec_type_from_file_location!
52
+
53
+ # Filter lines from Rails gems in backtraces.
54
+ config.filter_rails_from_backtrace!
55
+ # arbitrary gems may also be filtered via:
56
+ # config.filter_gems_from_backtrace("gem name")
57
+ end
@@ -0,0 +1,99 @@
1
+ # This file was generated by the `rails generate rspec:install` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
4
+ # this file to always be loaded, without a need to explicitly require it in any
5
+ # files.
6
+ #
7
+ # Given that it is always loaded, you are encouraged to keep this file as
8
+ # light-weight as possible. Requiring heavyweight dependencies from this file
9
+ # will add to the boot time of your test suite on EVERY test run, even for an
10
+ # individual file that may not need all of that loaded. Instead, consider making
11
+ # a separate helper file that requires the additional dependencies and performs
12
+ # the additional setup, and require it from the spec files that actually need
13
+ # it.
14
+ #
15
+ # The `.rspec` file also contains a few flags that are not defaults but that
16
+ # users commonly want.
17
+ #
18
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
19
+ RSpec.configure do |config|
20
+ # rspec-expectations config goes here. You can use an alternate
21
+ # assertion/expectation library such as wrong or the stdlib/minitest
22
+ # assertions if you prefer.
23
+ config.expect_with :rspec do |expectations|
24
+ # This option will default to `true` in RSpec 4. It makes the `description`
25
+ # and `failure_message` of custom matchers include text for helper methods
26
+ # defined using `chain`, e.g.:
27
+ # be_bigger_than(2).and_smaller_than(4).description
28
+ # # => "be bigger than 2 and smaller than 4"
29
+ # ...rather than:
30
+ # # => "be bigger than 2"
31
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
32
+ end
33
+
34
+ # rspec-mocks config goes here. You can use an alternate test double
35
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
36
+ config.mock_with :rspec do |mocks|
37
+ # Prevents you from mocking or stubbing a method that does not exist on
38
+ # a real object. This is generally recommended, and will default to
39
+ # `true` in RSpec 4.
40
+ mocks.verify_partial_doubles = true
41
+ end
42
+
43
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
44
+ # have no way to turn it off -- the option exists only for backwards
45
+ # compatibility in RSpec 3). It causes shared context metadata to be
46
+ # inherited by the metadata hash of host groups and examples, rather than
47
+ # triggering implicit auto-inclusion in groups with matching metadata.
48
+ config.shared_context_metadata_behavior = :apply_to_host_groups
49
+
50
+ # The settings below are suggested to provide a good initial experience
51
+ # with RSpec, but feel free to customize to your heart's content.
52
+ =begin
53
+ # This allows you to limit a spec run to individual examples or groups
54
+ # you care about by tagging them with `:focus` metadata. When nothing
55
+ # is tagged with `:focus`, all examples get run. RSpec also provides
56
+ # aliases for `it`, `describe`, and `context` that include `:focus`
57
+ # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
58
+ config.filter_run_when_matching :focus
59
+
60
+ # Allows RSpec to persist some state between runs in order to support
61
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
62
+ # you configure your source control system to ignore this file.
63
+ config.example_status_persistence_file_path = "spec/examples.txt"
64
+
65
+ # Limits the available syntax to the non-monkey patched syntax that is
66
+ # recommended. For more details, see:
67
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
68
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
69
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
70
+ config.disable_monkey_patching!
71
+
72
+ # Many RSpec users commonly either run the entire suite or an individual
73
+ # file, and it's useful to allow more verbose output when running an
74
+ # individual spec file.
75
+ if config.files_to_run.one?
76
+ # Use the documentation formatter for detailed output,
77
+ # unless a formatter has already been configured
78
+ # (e.g. via a command-line flag).
79
+ config.default_formatter = 'doc'
80
+ end
81
+
82
+ # Print the 10 slowest examples and example groups at the
83
+ # end of the spec run, to help surface which specs are running
84
+ # particularly slow.
85
+ config.profile_examples = 10
86
+
87
+ # Run specs in random order to surface order dependencies. If you find an
88
+ # order dependency and want to debug it, you can fix the order by providing
89
+ # the seed, which is printed after each run.
90
+ # --seed 1234
91
+ config.order = :random
92
+
93
+ # Seed global randomization in this process using the `--seed` CLI option.
94
+ # Setting this allows you to use `--seed` to deterministically reproduce
95
+ # test failures related to randomization by passing the same `--seed` value
96
+ # as the one that triggered the failure.
97
+ Kernel.srand config.seed
98
+ =end
99
+ end
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require_relative 'config/application'
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,5 @@
1
+
2
+ //= link_tree ../images
3
+ //= link_directory ../javascripts .js
4
+ //= link_directory ../stylesheets .css
5
+ //= link know_more_manifest.js
@@ -0,0 +1,15 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
14
+ //= require jquery
15
+ //= require jquery_ujs
@@ -0,0 +1,13 @@
1
+ // Action Cable provides the framework to deal with WebSockets in Rails.
2
+ // You can generate new channels where WebSocket features live using the rails generate channel command.
3
+ //
4
+ //= require action_cable
5
+ //= require_self
6
+ //= require_tree ./channels
7
+
8
+ (function() {
9
+ this.App || (this.App = {});
10
+
11
+ App.cable = ActionCable.createConsumer();
12
+
13
+ }).call(this);
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,4 @@
1
+ module ApplicationCable
2
+ class Channel < ActionCable::Channel::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module ApplicationCable
2
+ class Connection < ActionCable::Connection::Base
3
+ end
4
+ end
@@ -0,0 +1,8 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery with: :exception
3
+ include KnowMore::ControllerHelpers
4
+
5
+ def current_questionnaire
6
+ @current_questionnaire ||= Questionnaire.last()
7
+ end
8
+ end
@@ -0,0 +1,42 @@
1
+ module KnowMore
2
+ # this module is used to define the functions
3
+ # that will actually run in the KnowMore/QuestionnaireController
4
+ module QuestionnaireControllerConcerns
5
+ def self.included(base)
6
+ # define the behaviour when included
7
+ base.before_action :set_questionnaire
8
+ end
9
+
10
+ # _stepN function will be called by questionnaire#stepN
11
+
12
+ def _step1
13
+ end
14
+
15
+ def _step1_update
16
+ @questionnaire.update(questionnaire_params)
17
+ end
18
+
19
+ def _step2
20
+ end
21
+
22
+ def _step2_update
23
+ @questionnaire.update(questionnaire_params)
24
+ end
25
+
26
+ def _step3
27
+ end
28
+
29
+ def _step3_update
30
+ @questionnaire.update(questionnaire_params)
31
+ end
32
+
33
+ private
34
+ def set_questionnaire
35
+ @questionnaire = current_questionnaire
36
+ end
37
+
38
+ def questionnaire_params
39
+ params.require(:questionnaire).permit(:attribute1, :attribute2, :attribute3)
40
+ end
41
+ end
42
+ end