surveyor 0.20.0 → 0.21.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. data/.gitignore +26 -0
  2. data/Gemfile +11 -0
  3. data/Gemfile.rails_version +13 -0
  4. data/README.md +40 -22
  5. data/Rakefile +92 -29
  6. data/app/helpers/survey_form_builder.rb +37 -0
  7. data/app/helpers/surveyor_helper.rb +9 -9
  8. data/app/views/partials/_answer.html.haml +1 -1
  9. data/app/views/partials/_question.html.haml +3 -3
  10. data/app/views/partials/_question_group.html.haml +2 -2
  11. data/app/views/partials/_section.html.haml +1 -1
  12. data/app/views/surveyor/edit.html.haml +11 -3
  13. data/app/views/surveyor/new.html.haml +8 -1
  14. data/ci-exec.sh +50 -0
  15. data/config/routes.rb +9 -13
  16. data/cucumber.yml +10 -0
  17. data/doc/question types.png +0 -0
  18. data/features/redcap_parser.feature +1 -1
  19. data/features/step_definitions/common_setps.rb +3 -0
  20. data/features/step_definitions/parser_steps.rb +8 -1
  21. data/features/step_definitions/surveyor_steps.rb +33 -9
  22. data/features/step_definitions/web_steps.rb +85 -165
  23. data/features/support/env.rb +40 -46
  24. data/features/support/paths.rb +4 -4
  25. data/features/support/selectors.rb +39 -0
  26. data/features/surveyor.feature +63 -13
  27. data/features/surveyor_dependencies.feature +289 -0
  28. data/features/surveyor_parser.feature +29 -20
  29. data/lib/formtastic/surveyor_builder.rb +9 -9
  30. data/lib/generators/surveyor/custom_generator.rb +17 -0
  31. data/lib/generators/surveyor/install_generator.rb +50 -0
  32. data/{generators/extend_surveyor/templates/extensions → lib/generators/surveyor/templates/app/controllers}/surveyor_controller.rb +0 -0
  33. data/{generators/extend_surveyor/templates/extensions → lib/generators/surveyor/templates/app/views/layouts}/surveyor_custom.html.erb +0 -0
  34. data/{generators/surveyor/templates → lib/generators/surveyor/templates/config}/locales/surveyor_en.yml +0 -0
  35. data/{generators/surveyor/templates → lib/generators/surveyor/templates/config}/locales/surveyor_es.yml +0 -0
  36. data/{generators/surveyor/templates → lib/generators/surveyor/templates/config}/locales/surveyor_he.yml +0 -0
  37. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/add_api_ids.rb +0 -0
  38. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/add_correct_answer_id_to_questions.rb +0 -0
  39. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/add_default_value_to_answers.rb +0 -0
  40. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/add_display_order_to_surveys.rb +0 -0
  41. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/add_display_type_to_answers.rb +0 -0
  42. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/add_index_to_response_sets.rb +0 -0
  43. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/add_index_to_surveys.rb +0 -0
  44. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/add_section_id_to_responses.rb +0 -0
  45. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/add_unique_indicies.rb +0 -0
  46. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/create_answers.rb +0 -0
  47. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/create_dependencies.rb +0 -0
  48. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/create_dependency_conditions.rb +0 -0
  49. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/create_question_groups.rb +0 -0
  50. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/create_questions.rb +0 -0
  51. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/create_response_sets.rb +0 -0
  52. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/create_responses.rb +0 -0
  53. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/create_survey_sections.rb +0 -0
  54. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/create_surveys.rb +0 -0
  55. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/create_validation_conditions.rb +0 -0
  56. data/{generators/surveyor/templates → lib/generators/surveyor/templates/db}/migrate/create_validations.rb +0 -0
  57. data/{generators/surveyor/templates/assets/images → lib/generators/surveyor/templates/public/images/surveyor}/next.gif +0 -0
  58. data/{generators/surveyor/templates/assets/images → lib/generators/surveyor/templates/public/images/surveyor}/prev.gif +0 -0
  59. data/lib/generators/surveyor/templates/public/javascripts/surveyor/jquery.blockUI.js +499 -0
  60. data/{generators/surveyor/templates/assets/javascripts → lib/generators/surveyor/templates/public/javascripts/surveyor}/jquery.surveyor.js +47 -4
  61. data/{generators/surveyor/templates/assets/javascripts → lib/generators/surveyor/templates/public/javascripts/surveyor}/jquery.tools.min.js +0 -0
  62. data/{generators/surveyor/templates/assets → lib/generators/surveyor/templates/public}/stylesheets/sass/custom.sass +0 -0
  63. data/{generators/surveyor/templates/assets → lib/generators/surveyor/templates/public}/stylesheets/sass/surveyor.sass +2 -2
  64. data/{generators/surveyor/templates/assets/stylesheets → lib/generators/surveyor/templates/public/stylesheets/surveyor}/dateinput.css +0 -0
  65. data/{generators/surveyor/templates/assets/stylesheets → lib/generators/surveyor/templates/public/stylesheets/surveyor}/reset.css +0 -0
  66. data/{generators/surveyor/templates/assets/stylesheets → lib/generators/surveyor/templates/public/stylesheets/surveyor}/results.css +0 -0
  67. data/{generators/extend_surveyor/templates/EXTENDING_SURVEYOR → lib/generators/surveyor/templates/surveys/EXTENDING_SURVEYOR.md} +0 -0
  68. data/{generators → lib/generators}/surveyor/templates/surveys/kitchen_sink_survey.rb +0 -0
  69. data/{generators → lib/generators}/surveyor/templates/surveys/quiz.rb +0 -0
  70. data/lib/surveyor.rb +7 -0
  71. data/lib/surveyor/engine.rb +12 -0
  72. data/lib/surveyor/models/answer_methods.rb +0 -1
  73. data/lib/surveyor/models/dependency_condition_methods.rb +1 -3
  74. data/lib/surveyor/models/question_methods.rb +0 -1
  75. data/lib/surveyor/models/response_methods.rb +2 -2
  76. data/lib/surveyor/models/response_set_methods.rb +30 -14
  77. data/lib/surveyor/models/survey_methods.rb +2 -1
  78. data/lib/surveyor/models/survey_section_methods.rb +1 -2
  79. data/lib/surveyor/parser.rb +9 -7
  80. data/lib/surveyor/redcap_parser.rb +10 -7
  81. data/lib/surveyor/surveyor_controller_methods.rb +45 -11
  82. data/lib/surveyor/version.rb +3 -0
  83. data/lib/tasks/surveyor_tasks.rake +2 -2
  84. data/rails/init.rb +0 -1
  85. data/spec/controllers/surveyor_controller_spec.rb +81 -35
  86. data/spec/helpers/surveyor_helper_spec.rb +7 -1
  87. data/spec/models/dependency_condition_spec.rb +76 -63
  88. data/spec/models/response_set_spec.rb +52 -47
  89. data/spec/models/response_spec.rb +19 -16
  90. data/spec/spec_helper.rb +21 -44
  91. data/surveyor.gemspec +25 -176
  92. metadata +302 -77
  93. data/CHANGELOG +0 -335
  94. data/VERSION +0 -1
  95. data/ci-env.sh +0 -29
  96. data/generators/extend_surveyor/extend_surveyor_generator.rb +0 -21
  97. data/generators/surveyor/surveyor_generator.rb +0 -69
  98. data/generators/surveyor/templates/README +0 -10
  99. data/generators/surveyor/templates/tasks/surveyor.rb +0 -4
  100. data/hudson.rakefile +0 -33
  101. data/init_testbed.rakefile +0 -55
  102. data/testbed/Gemfile +0 -13
@@ -1,10 +0,0 @@
1
-
2
- Surveyor installed. Next, run the migrations:
3
-
4
- rake db:migrate
5
-
6
- Try out the "kitchen sink" survey:
7
-
8
- rake surveyor FILE=surveys/kitchen_sink_survey.rb
9
-
10
- Or see README.md for configuration and customization details
@@ -1,4 +0,0 @@
1
- $VERBOSE = nil
2
- if surveyor_gem = Gem.searcher.find('surveyor')
3
- Dir["#{surveyor_gem.full_gem_path}/lib/tasks/*.rake"].each { |ext| load ext }
4
- end
data/hudson.rakefile DELETED
@@ -1,33 +0,0 @@
1
- BUNDLER_VERSION="1.0.7"
2
- import 'init_testbed.rakefile'
3
-
4
- namespace :bundle do
5
- task :ensure_bundler_available do
6
- `gem list -i bundler -v '=#{BUNDLER_VERSION}'`
7
- unless $? == 0
8
- puts bordered_message("Installing bundler #{BUNDLER_VERSION}")
9
- system("gem install bundler -v '=#{BUNDLER_VERSION}' --no-ri --no-rdoc")
10
- unless $? == 0
11
- fail bordered_message("Install failed.\nPlease fix the problem and try again or manually install bundler #{BUNDLER_VERSION}.")
12
- end
13
- end
14
- end
15
-
16
- def bordered_message(msg)
17
- len = msg.split("\n").collect { |l| l.size }.max
18
- ['=' * len, msg, '=' * len].join("\n")
19
- end
20
- end
21
- namespace :ci do
22
- task :generate_testbed_for_hudson => [:'testbed:remove', :'testbed:generate'] do
23
- # Hudson
24
- chdir("testbed") do
25
- database_yml = File.read('config/database.yml') + "\n\nhudson:\n <<: *test\n"
26
- File.open('config/database.yml', 'w'){|f| f.write database_yml}
27
- sh "cp config/environments/cucumber.rb config/environments/hudson.rb"
28
- end
29
- end
30
- task :setup_testbed_for_hudson => [:'testbed:setup', :'testbed:migrate']
31
- end
32
-
33
- task :default => [:'bundle:ensure_bundler_available', :'ci:generate_testbed_for_hudson', :'ci:setup_testbed_for_hudson']
@@ -1,55 +0,0 @@
1
- desc "Set up a rails app for testing in the spec dir"
2
- task :default => [:"testbed:generate", :"testbed:setup", :"testbed:migrate"]
3
-
4
- namespace "testbed" do
5
- # "testbed" is also hardcoded in the spec/spec_helper.rb features/support/env.rb and gitignore file. Change it there too...
6
-
7
- "Generate rails, rspec, cucumber"
8
- task :generate do
9
- chdir("testbed") do
10
- sh "bundle install"
11
- sh "bundle exec rails ."
12
- sh "bundle exec script/generate rspec"
13
- sh "bundle exec script/generate cucumber --webrat"
14
- sh "rm -rf spec features"
15
- end
16
- end
17
-
18
- desc "Setup bundler, rspec, cucumber"
19
- task :setup do
20
- chdir("testbed") do
21
- # Bundler
22
- preinitializer_rb = "begin\n require \"rubygems\"\n require \"bundler\"\nrescue LoadError\n raise \"Could not load the bundler gem. Install it with `gem install bundler`.\"\nend\n\nif Gem::Version.new(Bundler::VERSION) <= Gem::Version.new(\"0.9.24\")\n raise RuntimeError, \"Your bundler version is too old for Rails 2.3.\" +\n \"Run `gem install bundler` to upgrade.\"\nend\n\nbegin\n # Set up load paths for all bundled gems\n ENV[\"BUNDLE_GEMFILE\"] = File.expand_path(\"../../Gemfile\", __FILE__)\n Bundler.setup\nrescue Bundler::GemNotFound\n raise RuntimeError, \"Bundler couldn't find some gems.\" +\n \"Did you run `bundle install`?\"\nend\n"
23
- File.open('config/preinitializer.rb', 'w'){|f| f.write preinitializer_rb}
24
-
25
- boot_rb = File.read('config/boot.rb').sub("# All that for this:", "class Rails::Boot\n def run\n load_initializer\n\n Rails::Initializer.class_eval do\n def load_gems\n @bundler_loaded ||= Bundler.require :default, Rails.env\n end\n end\n\n Rails::Initializer.run(:set_load_path)\n end\nend\n\n# All that for this:")
26
- File.open('config/boot.rb', 'w'){|f| f.write boot_rb}
27
- puts "NOTE: These files were created/modified as described here: http://gembundler.com/rails23.html"
28
-
29
- # Rspec
30
- rspec_rake = File.read('lib/tasks/rspec.rake').gsub('#{RAILS_ROOT}/spec/', '#{RAILS_ROOT}/../spec/').gsub("FileList['spec/", "FileList['../spec/").gsub("File.exist?('spec/","File.exist?('../spec/")
31
- File.open('lib/tasks/rspec.rake', 'w'){|f| f.write rspec_rake}
32
-
33
- # Cucumber
34
- cucumber_rake = File.read('lib/tasks/cucumber.rake').sub("begin", "ENV['FEATURE'] ||= '../features'\n\nbegin")
35
- File.open('lib/tasks/cucumber.rake', 'w'){|f| f.write cucumber_rake}
36
- end
37
- end
38
-
39
- desc "Generate, migrate testbed"
40
- task :migrate do
41
- sh "cp -R generators testbed/lib"
42
- chdir("testbed") do
43
- sh "bundle exec script/generate surveyor"
44
- sh "bundle exec rake db:migrate db:test:prepare"
45
- end
46
- end
47
-
48
- desc "Remove testbed app"
49
- task :remove do
50
- puts "Removing the test_app in the spec folder"
51
- chdir("testbed") do
52
- sh 'rm -rf Gemfile.lock README Rakefile app config db doc features lib log public script spec surveys test tmp vendor'
53
- end
54
- end
55
- end
data/testbed/Gemfile DELETED
@@ -1,13 +0,0 @@
1
- source :rubygems
2
-
3
- gem 'rails', '2.3.10'
4
- gem 'rspec', '~> 1.3'
5
- gem 'rspec-rails', '1.3.3'
6
- gem 'sqlite3-ruby', '1.2.5' # Using this version for ruby 1.8.7 compatibility reasons
7
- gem 'webrat'
8
- gem 'cucumber', '~>0.9'
9
- gem 'cucumber-rails', '0.3.2'
10
- gem 'database_cleaner'
11
- gem 'factory_girl'
12
-
13
- gem 'surveyor', :path => ".."