jakewendt-surveyor 0.11.3
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.md +285 -0
- data/Rakefile +54 -0
- data/VERSION +1 -0
- data/app/controllers/surveyor_controller.rb +142 -0
- data/app/helpers/survey_form_builder.rb +37 -0
- data/app/helpers/surveyor_helper.rb +67 -0
- data/app/models/answer.rb +23 -0
- data/app/models/dependency.rb +50 -0
- data/app/models/dependency_condition.rb +47 -0
- data/app/models/question.rb +54 -0
- data/app/models/question_group.rb +33 -0
- data/app/models/response.rb +94 -0
- data/app/models/response_set.rb +316 -0
- data/app/models/survey.rb +172 -0
- data/app/models/survey_section.rb +18 -0
- data/app/models/validation.rb +38 -0
- data/app/models/validation_condition.rb +47 -0
- data/app/views/layouts/surveyor_default.html.erb +13 -0
- data/app/views/partials/_answer.html.haml +58 -0
- data/app/views/partials/_question.html.haml +80 -0
- data/app/views/partials/_question_group.html.haml +39 -0
- data/app/views/surveyor/edit.html.haml +38 -0
- data/app/views/surveyor/new.html.haml +16 -0
- data/app/views/surveyor/show.html.haml +12 -0
- data/config/routes.rb +11 -0
- data/features/step_definitions/surveyor_steps.rb +7 -0
- data/features/step_definitions/web_steps.rb +273 -0
- data/features/support/env.rb +57 -0
- data/features/support/paths.rb +25 -0
- data/features/surveyor.feature +11 -0
- data/generators/extend_surveyor/extend_surveyor_generator.rb +22 -0
- data/generators/extend_surveyor/templates/EXTENDING_SURVEYOR +17 -0
- data/generators/extend_surveyor/templates/extensions/survey_extensions.rb +24 -0
- data/generators/extend_surveyor/templates/extensions/surveyor_controller_extensions.rb +28 -0
- data/generators/extend_surveyor/templates/extensions/surveyor_custom.html.erb +13 -0
- data/generators/extend_surveyor/templates/extensions/surveyor_helper_extensions.rb +17 -0
- data/generators/surveyor/surveyor_generator.rb +67 -0
- data/generators/surveyor/templates/README +10 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_arrows_leftright.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_arrows_updown.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_close.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_doc.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_folder_closed.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_folder_open.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_minus.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_plus.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_11x11_icon_resize_se.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_35x9_colorpicker_indicator.gif.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_7x7_arrow_down.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_7x7_arrow_left.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_7x7_arrow_right.gif +0 -0
- data/generators/surveyor/templates/assets/images/222222_7x7_arrow_up.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_arrows_leftright.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_arrows_updown.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_close.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_doc.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_folder_closed.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_folder_open.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_minus.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_11x11_icon_plus.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_7x7_arrow_down.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_7x7_arrow_left.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_7x7_arrow_right.gif +0 -0
- data/generators/surveyor/templates/assets/images/454545_7x7_arrow_up.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_arrows_leftright.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_arrows_updown.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_close.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_doc.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_folder_closed.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_folder_open.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_minus.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_11x11_icon_plus.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_7x7_arrow_down.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_7x7_arrow_left.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_7x7_arrow_right.gif +0 -0
- data/generators/surveyor/templates/assets/images/888888_7x7_arrow_up.gif +0 -0
- data/generators/surveyor/templates/assets/images/dadada_40x100_textures_02_glass_75.png +0 -0
- data/generators/surveyor/templates/assets/images/e6e6e6_40x100_textures_02_glass_75.png +0 -0
- data/generators/surveyor/templates/assets/images/ffffff_40x100_textures_01_flat_0.png +0 -0
- data/generators/surveyor/templates/assets/images/ffffff_40x100_textures_02_glass_65.png +0 -0
- data/generators/surveyor/templates/assets/javascripts/accessibleUISlider.jQuery.js +201 -0
- data/generators/surveyor/templates/assets/javascripts/jquery-1.2.6.js +3549 -0
- data/generators/surveyor/templates/assets/javascripts/jquery-ui-personalized-1.5.3.js +7616 -0
- data/generators/surveyor/templates/assets/javascripts/jquery.form.js +637 -0
- data/generators/surveyor/templates/assets/javascripts/surveyor.js +47 -0
- data/generators/surveyor/templates/assets/stylesheets/jquery-ui-slider-additions.css +71 -0
- data/generators/surveyor/templates/assets/stylesheets/reset.css +50 -0
- data/generators/surveyor/templates/assets/stylesheets/sass/surveyor.sass +243 -0
- data/generators/surveyor/templates/assets/stylesheets/surveyor.css +235 -0
- data/generators/surveyor/templates/assets/stylesheets/ui.theme.css +851 -0
- data/generators/surveyor/templates/initializers/haml.rb +8 -0
- data/generators/surveyor/templates/initializers/surveyor.rb +10 -0
- data/generators/surveyor/templates/migrate/add_correct_answer_id_to_questions.rb +9 -0
- data/generators/surveyor/templates/migrate/add_display_order_to_surveys.rb +9 -0
- data/generators/surveyor/templates/migrate/add_index_to_response_sets.rb +9 -0
- data/generators/surveyor/templates/migrate/add_index_to_surveys.rb +9 -0
- data/generators/surveyor/templates/migrate/add_manual_numbering.rb +11 -0
- data/generators/surveyor/templates/migrate/add_unique_indicies.rb +17 -0
- data/generators/surveyor/templates/migrate/create_answers.rb +37 -0
- data/generators/surveyor/templates/migrate/create_dependencies.rb +22 -0
- data/generators/surveyor/templates/migrate/create_dependency_conditions.rb +29 -0
- data/generators/surveyor/templates/migrate/create_question_groups.rb +27 -0
- data/generators/surveyor/templates/migrate/create_questions.rb +36 -0
- data/generators/surveyor/templates/migrate/create_response_sets.rb +22 -0
- data/generators/surveyor/templates/migrate/create_responses.rb +33 -0
- data/generators/surveyor/templates/migrate/create_survey_sections.rb +29 -0
- data/generators/surveyor/templates/migrate/create_surveys.rb +31 -0
- data/generators/surveyor/templates/migrate/create_validation_conditions.rb +32 -0
- data/generators/surveyor/templates/migrate/create_validations.rb +20 -0
- data/generators/surveyor/templates/surveys/kitchen_sink_survey.rb +218 -0
- data/generators/surveyor/templates/tasks/surveyor.rb +4 -0
- data/generators/test_surveyor/templates/TESTING_SURVEYOR +0 -0
- data/generators/test_surveyor/templates/environments/cucumber.rb +21 -0
- data/generators/test_surveyor/test_surveyor_generator.rb +15 -0
- data/jakewendt-surveyor.gemspec +212 -0
- data/lib/fixtures_extensions.rb +6 -0
- data/lib/jakewendt-surveyor.rb +1 -0
- data/lib/surveyor.rb +44 -0
- data/lib/surveyor/acts_as_response.rb +33 -0
- data/lib/surveyor/config.rb +45 -0
- data/lib/tasks/surveyor_tasks.rake +33 -0
- data/lib/xml_formatter.rb +12 -0
- data/rails/init.rb +1 -0
- data/script/surveyor/answer.rb +54 -0
- data/script/surveyor/base.rb +77 -0
- data/script/surveyor/dependency.rb +13 -0
- data/script/surveyor/dependency_condition.rb +40 -0
- data/script/surveyor/parser.rb +207 -0
- data/script/surveyor/question.rb +37 -0
- data/script/surveyor/question_group.rb +26 -0
- data/script/surveyor/specs/answer_spec.rb +29 -0
- data/script/surveyor/specs/question_spec.rb +63 -0
- data/script/surveyor/specs/spec_helper.rb +7 -0
- data/script/surveyor/specs/survey_section_spec.rb +23 -0
- data/script/surveyor/specs/validation_condition_spec.rb +20 -0
- data/script/surveyor/specs/validation_spec.rb +20 -0
- data/script/surveyor/survey.rb +35 -0
- data/script/surveyor/survey_section.rb +21 -0
- data/script/surveyor/validation.rb +21 -0
- data/script/surveyor/validation_condition.rb +21 -0
- data/script/surveyor/whr_dsl.tmproj +244 -0
- data/spec/controllers/surveyor_controller_spec.rb +193 -0
- data/spec/factories.rb +145 -0
- data/spec/lib/surveyor_spec.rb +44 -0
- data/spec/models/answer_spec.rb +29 -0
- data/spec/models/dependency_condition_spec.rb +321 -0
- data/spec/models/dependency_spec.rb +81 -0
- data/spec/models/question_group_spec.rb +35 -0
- data/spec/models/question_spec.rb +75 -0
- data/spec/models/response_set_spec.rb +245 -0
- data/spec/models/response_spec.rb +76 -0
- data/spec/models/survey_section_spec.rb +32 -0
- data/spec/models/survey_spec.rb +71 -0
- data/spec/models/validation_condition_spec.rb +105 -0
- data/spec/models/validation_spec.rb +59 -0
- data/spec/rcov.opts +2 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +12 -0
- metadata +254 -0
File without changes
|
@@ -0,0 +1,21 @@
|
|
1
|
+
config.cache_classes = true # This must be true for Cucumber to operate correctly!
|
2
|
+
|
3
|
+
# Log error messages when you accidentally call methods on nil.
|
4
|
+
config.whiny_nils = true
|
5
|
+
|
6
|
+
# Show full error reports and disable caching
|
7
|
+
config.action_controller.consider_all_requests_local = true
|
8
|
+
config.action_controller.perform_caching = false
|
9
|
+
|
10
|
+
# Disable request forgery protection in test environment
|
11
|
+
config.action_controller.allow_forgery_protection = false
|
12
|
+
|
13
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
14
|
+
# The :test delivery method accumulates sent emails in the
|
15
|
+
# ActionMailer::Base.deliveries array.
|
16
|
+
config.action_mailer.delivery_method = :test
|
17
|
+
|
18
|
+
config.gem "cucumber", :lib => false, :version => ">=0.3.11" unless File.directory?(File.join(Rails.root, 'vendor/plugins/cucumber'))
|
19
|
+
config.gem "webrat", :lib => false, :version => ">=0.4.4" unless File.directory?(File.join(Rails.root, 'vendor/plugins/webrat'))
|
20
|
+
config.gem "rspec", :lib => false, :version => ">=1.2.6" unless File.directory?(File.join(Rails.root, 'vendor/plugins/rspec'))
|
21
|
+
config.gem "rspec-rails", :lib => 'spec/rails', :version => ">=1.2.6" unless File.directory?(File.join(Rails.root, 'vendor/plugins/rspec-rails'))
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class TestSurveyorGenerator < Rails::Generator::Base
|
2
|
+
def manifest
|
3
|
+
record do |m|
|
4
|
+
|
5
|
+
m.directory "surveys"
|
6
|
+
|
7
|
+
# Copy README to your app
|
8
|
+
m.file "TESTING_SURVEYOR", "surveys/TESTING_SURVEYOR"
|
9
|
+
|
10
|
+
m.file "environments/cucumber.rb", "config/environments/cucumber.rb"
|
11
|
+
m.readme "TESTING_SURVEYOR"
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,212 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{jakewendt-surveyor}
|
8
|
+
s.version = "0.11.3"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Brian Chamberlain", "Mark Yoon", "Jake Wendt"]
|
12
|
+
s.date = %q{2011-02-08}
|
13
|
+
s.email = %q{github@jake.otherinbox.com}
|
14
|
+
s.extra_rdoc_files = [
|
15
|
+
"README.md"
|
16
|
+
]
|
17
|
+
s.files = [
|
18
|
+
"MIT-LICENSE",
|
19
|
+
"README.md",
|
20
|
+
"Rakefile",
|
21
|
+
"VERSION",
|
22
|
+
"app/controllers/surveyor_controller.rb",
|
23
|
+
"app/helpers/survey_form_builder.rb",
|
24
|
+
"app/helpers/surveyor_helper.rb",
|
25
|
+
"app/models/answer.rb",
|
26
|
+
"app/models/dependency.rb",
|
27
|
+
"app/models/dependency_condition.rb",
|
28
|
+
"app/models/question.rb",
|
29
|
+
"app/models/question_group.rb",
|
30
|
+
"app/models/response.rb",
|
31
|
+
"app/models/response_set.rb",
|
32
|
+
"app/models/survey.rb",
|
33
|
+
"app/models/survey_section.rb",
|
34
|
+
"app/models/validation.rb",
|
35
|
+
"app/models/validation_condition.rb",
|
36
|
+
"app/views/layouts/surveyor_default.html.erb",
|
37
|
+
"app/views/partials/_answer.html.haml",
|
38
|
+
"app/views/partials/_question.html.haml",
|
39
|
+
"app/views/partials/_question_group.html.haml",
|
40
|
+
"app/views/surveyor/edit.html.haml",
|
41
|
+
"app/views/surveyor/new.html.haml",
|
42
|
+
"app/views/surveyor/show.html.haml",
|
43
|
+
"config/routes.rb",
|
44
|
+
"features/step_definitions/surveyor_steps.rb",
|
45
|
+
"features/step_definitions/web_steps.rb",
|
46
|
+
"features/support/env.rb",
|
47
|
+
"features/support/paths.rb",
|
48
|
+
"features/surveyor.feature",
|
49
|
+
"generators/extend_surveyor/extend_surveyor_generator.rb",
|
50
|
+
"generators/extend_surveyor/templates/EXTENDING_SURVEYOR",
|
51
|
+
"generators/extend_surveyor/templates/extensions/survey_extensions.rb",
|
52
|
+
"generators/extend_surveyor/templates/extensions/surveyor_controller_extensions.rb",
|
53
|
+
"generators/extend_surveyor/templates/extensions/surveyor_custom.html.erb",
|
54
|
+
"generators/extend_surveyor/templates/extensions/surveyor_helper_extensions.rb",
|
55
|
+
"generators/surveyor/surveyor_generator.rb",
|
56
|
+
"generators/surveyor/templates/README",
|
57
|
+
"generators/surveyor/templates/assets/images/222222_11x11_icon_arrows_leftright.gif",
|
58
|
+
"generators/surveyor/templates/assets/images/222222_11x11_icon_arrows_updown.gif",
|
59
|
+
"generators/surveyor/templates/assets/images/222222_11x11_icon_close.gif",
|
60
|
+
"generators/surveyor/templates/assets/images/222222_11x11_icon_doc.gif",
|
61
|
+
"generators/surveyor/templates/assets/images/222222_11x11_icon_folder_closed.gif",
|
62
|
+
"generators/surveyor/templates/assets/images/222222_11x11_icon_folder_open.gif",
|
63
|
+
"generators/surveyor/templates/assets/images/222222_11x11_icon_minus.gif",
|
64
|
+
"generators/surveyor/templates/assets/images/222222_11x11_icon_plus.gif",
|
65
|
+
"generators/surveyor/templates/assets/images/222222_11x11_icon_resize_se.gif",
|
66
|
+
"generators/surveyor/templates/assets/images/222222_35x9_colorpicker_indicator.gif.gif",
|
67
|
+
"generators/surveyor/templates/assets/images/222222_7x7_arrow_down.gif",
|
68
|
+
"generators/surveyor/templates/assets/images/222222_7x7_arrow_left.gif",
|
69
|
+
"generators/surveyor/templates/assets/images/222222_7x7_arrow_right.gif",
|
70
|
+
"generators/surveyor/templates/assets/images/222222_7x7_arrow_up.gif",
|
71
|
+
"generators/surveyor/templates/assets/images/454545_11x11_icon_arrows_leftright.gif",
|
72
|
+
"generators/surveyor/templates/assets/images/454545_11x11_icon_arrows_updown.gif",
|
73
|
+
"generators/surveyor/templates/assets/images/454545_11x11_icon_close.gif",
|
74
|
+
"generators/surveyor/templates/assets/images/454545_11x11_icon_doc.gif",
|
75
|
+
"generators/surveyor/templates/assets/images/454545_11x11_icon_folder_closed.gif",
|
76
|
+
"generators/surveyor/templates/assets/images/454545_11x11_icon_folder_open.gif",
|
77
|
+
"generators/surveyor/templates/assets/images/454545_11x11_icon_minus.gif",
|
78
|
+
"generators/surveyor/templates/assets/images/454545_11x11_icon_plus.gif",
|
79
|
+
"generators/surveyor/templates/assets/images/454545_7x7_arrow_down.gif",
|
80
|
+
"generators/surveyor/templates/assets/images/454545_7x7_arrow_left.gif",
|
81
|
+
"generators/surveyor/templates/assets/images/454545_7x7_arrow_right.gif",
|
82
|
+
"generators/surveyor/templates/assets/images/454545_7x7_arrow_up.gif",
|
83
|
+
"generators/surveyor/templates/assets/images/888888_11x11_icon_arrows_leftright.gif",
|
84
|
+
"generators/surveyor/templates/assets/images/888888_11x11_icon_arrows_updown.gif",
|
85
|
+
"generators/surveyor/templates/assets/images/888888_11x11_icon_close.gif",
|
86
|
+
"generators/surveyor/templates/assets/images/888888_11x11_icon_doc.gif",
|
87
|
+
"generators/surveyor/templates/assets/images/888888_11x11_icon_folder_closed.gif",
|
88
|
+
"generators/surveyor/templates/assets/images/888888_11x11_icon_folder_open.gif",
|
89
|
+
"generators/surveyor/templates/assets/images/888888_11x11_icon_minus.gif",
|
90
|
+
"generators/surveyor/templates/assets/images/888888_11x11_icon_plus.gif",
|
91
|
+
"generators/surveyor/templates/assets/images/888888_7x7_arrow_down.gif",
|
92
|
+
"generators/surveyor/templates/assets/images/888888_7x7_arrow_left.gif",
|
93
|
+
"generators/surveyor/templates/assets/images/888888_7x7_arrow_right.gif",
|
94
|
+
"generators/surveyor/templates/assets/images/888888_7x7_arrow_up.gif",
|
95
|
+
"generators/surveyor/templates/assets/images/dadada_40x100_textures_02_glass_75.png",
|
96
|
+
"generators/surveyor/templates/assets/images/e6e6e6_40x100_textures_02_glass_75.png",
|
97
|
+
"generators/surveyor/templates/assets/images/ffffff_40x100_textures_01_flat_0.png",
|
98
|
+
"generators/surveyor/templates/assets/images/ffffff_40x100_textures_02_glass_65.png",
|
99
|
+
"generators/surveyor/templates/assets/javascripts/accessibleUISlider.jQuery.js",
|
100
|
+
"generators/surveyor/templates/assets/javascripts/jquery-1.2.6.js",
|
101
|
+
"generators/surveyor/templates/assets/javascripts/jquery-ui-personalized-1.5.3.js",
|
102
|
+
"generators/surveyor/templates/assets/javascripts/jquery.form.js",
|
103
|
+
"generators/surveyor/templates/assets/javascripts/surveyor.js",
|
104
|
+
"generators/surveyor/templates/assets/stylesheets/jquery-ui-slider-additions.css",
|
105
|
+
"generators/surveyor/templates/assets/stylesheets/reset.css",
|
106
|
+
"generators/surveyor/templates/assets/stylesheets/sass/surveyor.sass",
|
107
|
+
"generators/surveyor/templates/assets/stylesheets/surveyor.css",
|
108
|
+
"generators/surveyor/templates/assets/stylesheets/ui.theme.css",
|
109
|
+
"generators/surveyor/templates/initializers/haml.rb",
|
110
|
+
"generators/surveyor/templates/initializers/surveyor.rb",
|
111
|
+
"generators/surveyor/templates/migrate/add_correct_answer_id_to_questions.rb",
|
112
|
+
"generators/surveyor/templates/migrate/add_display_order_to_surveys.rb",
|
113
|
+
"generators/surveyor/templates/migrate/add_index_to_response_sets.rb",
|
114
|
+
"generators/surveyor/templates/migrate/add_index_to_surveys.rb",
|
115
|
+
"generators/surveyor/templates/migrate/add_manual_numbering.rb",
|
116
|
+
"generators/surveyor/templates/migrate/add_unique_indicies.rb",
|
117
|
+
"generators/surveyor/templates/migrate/create_answers.rb",
|
118
|
+
"generators/surveyor/templates/migrate/create_dependencies.rb",
|
119
|
+
"generators/surveyor/templates/migrate/create_dependency_conditions.rb",
|
120
|
+
"generators/surveyor/templates/migrate/create_question_groups.rb",
|
121
|
+
"generators/surveyor/templates/migrate/create_questions.rb",
|
122
|
+
"generators/surveyor/templates/migrate/create_response_sets.rb",
|
123
|
+
"generators/surveyor/templates/migrate/create_responses.rb",
|
124
|
+
"generators/surveyor/templates/migrate/create_survey_sections.rb",
|
125
|
+
"generators/surveyor/templates/migrate/create_surveys.rb",
|
126
|
+
"generators/surveyor/templates/migrate/create_validation_conditions.rb",
|
127
|
+
"generators/surveyor/templates/migrate/create_validations.rb",
|
128
|
+
"generators/surveyor/templates/surveys/kitchen_sink_survey.rb",
|
129
|
+
"generators/surveyor/templates/tasks/surveyor.rb",
|
130
|
+
"generators/test_surveyor/templates/TESTING_SURVEYOR",
|
131
|
+
"generators/test_surveyor/templates/environments/cucumber.rb",
|
132
|
+
"generators/test_surveyor/test_surveyor_generator.rb",
|
133
|
+
"jakewendt-surveyor.gemspec",
|
134
|
+
"lib/fixtures_extensions.rb",
|
135
|
+
"lib/jakewendt-surveyor.rb",
|
136
|
+
"lib/surveyor.rb",
|
137
|
+
"lib/surveyor/acts_as_response.rb",
|
138
|
+
"lib/surveyor/config.rb",
|
139
|
+
"lib/tasks/surveyor_tasks.rake",
|
140
|
+
"lib/xml_formatter.rb",
|
141
|
+
"rails/init.rb",
|
142
|
+
"script/surveyor/answer.rb",
|
143
|
+
"script/surveyor/base.rb",
|
144
|
+
"script/surveyor/dependency.rb",
|
145
|
+
"script/surveyor/dependency_condition.rb",
|
146
|
+
"script/surveyor/parser.rb",
|
147
|
+
"script/surveyor/question.rb",
|
148
|
+
"script/surveyor/question_group.rb",
|
149
|
+
"script/surveyor/specs/answer_spec.rb",
|
150
|
+
"script/surveyor/specs/question_spec.rb",
|
151
|
+
"script/surveyor/specs/spec_helper.rb",
|
152
|
+
"script/surveyor/specs/survey_section_spec.rb",
|
153
|
+
"script/surveyor/specs/validation_condition_spec.rb",
|
154
|
+
"script/surveyor/specs/validation_spec.rb",
|
155
|
+
"script/surveyor/survey.rb",
|
156
|
+
"script/surveyor/survey_section.rb",
|
157
|
+
"script/surveyor/validation.rb",
|
158
|
+
"script/surveyor/validation_condition.rb",
|
159
|
+
"script/surveyor/whr_dsl.tmproj",
|
160
|
+
"spec/controllers/surveyor_controller_spec.rb",
|
161
|
+
"spec/factories.rb",
|
162
|
+
"spec/lib/surveyor_spec.rb",
|
163
|
+
"spec/models/answer_spec.rb",
|
164
|
+
"spec/models/dependency_condition_spec.rb",
|
165
|
+
"spec/models/dependency_spec.rb",
|
166
|
+
"spec/models/question_group_spec.rb",
|
167
|
+
"spec/models/question_spec.rb",
|
168
|
+
"spec/models/response_set_spec.rb",
|
169
|
+
"spec/models/response_spec.rb",
|
170
|
+
"spec/models/survey_section_spec.rb",
|
171
|
+
"spec/models/survey_spec.rb",
|
172
|
+
"spec/models/validation_condition_spec.rb",
|
173
|
+
"spec/models/validation_spec.rb",
|
174
|
+
"spec/rcov.opts",
|
175
|
+
"spec/spec.opts",
|
176
|
+
"spec/spec_helper.rb"
|
177
|
+
]
|
178
|
+
s.homepage = %q{http://github.com/jakewendt/surveyor}
|
179
|
+
s.require_paths = ["lib"]
|
180
|
+
s.rubygems_version = %q{1.5.0}
|
181
|
+
s.summary = %q{A rails (gem) plugin to enable surveys in your application}
|
182
|
+
s.test_files = [
|
183
|
+
"spec/controllers/surveyor_controller_spec.rb",
|
184
|
+
"spec/factories.rb",
|
185
|
+
"spec/lib/surveyor_spec.rb",
|
186
|
+
"spec/models/answer_spec.rb",
|
187
|
+
"spec/models/dependency_condition_spec.rb",
|
188
|
+
"spec/models/dependency_spec.rb",
|
189
|
+
"spec/models/question_group_spec.rb",
|
190
|
+
"spec/models/question_spec.rb",
|
191
|
+
"spec/models/response_set_spec.rb",
|
192
|
+
"spec/models/response_spec.rb",
|
193
|
+
"spec/models/survey_section_spec.rb",
|
194
|
+
"spec/models/survey_spec.rb",
|
195
|
+
"spec/models/validation_condition_spec.rb",
|
196
|
+
"spec/models/validation_spec.rb",
|
197
|
+
"spec/spec_helper.rb"
|
198
|
+
]
|
199
|
+
|
200
|
+
if s.respond_to? :specification_version then
|
201
|
+
s.specification_version = 3
|
202
|
+
|
203
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
204
|
+
s.add_runtime_dependency(%q<haml>, [">= 0"])
|
205
|
+
else
|
206
|
+
s.add_dependency(%q<haml>, [">= 0"])
|
207
|
+
end
|
208
|
+
else
|
209
|
+
s.add_dependency(%q<haml>, [">= 0"])
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'surveyor'
|
data/lib/surveyor.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/surveyor/acts_as_response'
|
2
|
+
module Surveyor
|
3
|
+
RAND_CHARS = [('a'..'z'), ('A'..'Z'), (0..9)].map{|r| r.to_a}.flatten.to_s
|
4
|
+
|
5
|
+
def self.make_tiny_code(len = 10)
|
6
|
+
if RUBY_VERSION < "1.8.7"
|
7
|
+
(1..len).to_a.map{|i| RAND_CHARS[rand(RAND_CHARS.size), 1] }.to_s
|
8
|
+
else
|
9
|
+
len.times.map{|i| RAND_CHARS[rand(RAND_CHARS.size), 1] }.to_s
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.to_normalized_string(text)
|
14
|
+
words_to_omit = %w(a be but has have in is it of on or the to when)
|
15
|
+
col_text = text.gsub(/(<[^>]*>)|\n|\t/s, ' ') # Remove html tags
|
16
|
+
col_text.downcase! # Remove capitalization
|
17
|
+
col_text.gsub!(/\"|\'/, '') # Remove potential problem characters
|
18
|
+
col_text.gsub!(/\(.*?\)/,'') # Remove text inside parens
|
19
|
+
col_text.gsub!(/\W/, ' ') # Remove all other non-word characters
|
20
|
+
cols = (col_text.split(' ') - words_to_omit)
|
21
|
+
(cols.size > 5 ? cols[-5..-1] : cols).join("_")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# From http://guides.rubyonrails.org/plugins.html#controllers
|
26
|
+
# Fix for:
|
27
|
+
# ArgumentError in SurveyorController#edit
|
28
|
+
# A copy of ApplicationController has been removed from the module tree but is still active!
|
29
|
+
# Equivalent of using "unloadable" in SurveyorController (unloadable has been deprecated)
|
30
|
+
|
31
|
+
%w{models controllers}.each do |dir|
|
32
|
+
path = File.expand_path(File.join(File.dirname(__FILE__), '../app', dir))
|
33
|
+
# $LOAD_PATH << path # already here
|
34
|
+
# ActiveSupport::Dependencies.load_paths << path # already here too
|
35
|
+
# ActiveSupport::Dependencies.load_once_paths.delete(path)
|
36
|
+
# ActiveSupport::Dependencies.autoload_once_paths.delete(path)
|
37
|
+
# [$LOAD_PATH, ActiveSupport::Dependencies.load_paths, ActiveSupport::Dependencies.load_once_paths].each{|x| Rails.logger.info x}
|
38
|
+
|
39
|
+
|
40
|
+
ActiveSupport::Dependencies.autoload_paths << path
|
41
|
+
ActiveSupport::Dependencies.autoload_once_paths << path
|
42
|
+
end
|
43
|
+
|
44
|
+
require 'surveyor/config'
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'active_record'
|
2
|
+
|
3
|
+
module Surveyor
|
4
|
+
module Response
|
5
|
+
def self.included(base)
|
6
|
+
base.extend(ClassMethods)
|
7
|
+
end
|
8
|
+
|
9
|
+
module ClassMethods
|
10
|
+
def acts_as_response
|
11
|
+
include Surveyor::Response::InstanceMethods
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
module InstanceMethods
|
16
|
+
# Returns the response as a particular response_class type
|
17
|
+
def as(type_symbol)
|
18
|
+
return case type_symbol.to_sym
|
19
|
+
when :string, :text, :integer, :float, :datetime
|
20
|
+
self.send("#{type_symbol}_value".to_sym)
|
21
|
+
when :date
|
22
|
+
self.datetime_value.nil? ? nil : self.datetime_value.to_date
|
23
|
+
when :time
|
24
|
+
self.datetime_value.nil? ? nil : self.datetime_value.to_time
|
25
|
+
else # :answer_id
|
26
|
+
self.answer_id
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
ActiveRecord::Base.send(:include, Surveyor::Response)
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Surveyor
|
2
|
+
#
|
3
|
+
# The Surveyor::Config object emulates a hash with simple bracket methods
|
4
|
+
# which allow you to get and set values in the configuration table:
|
5
|
+
#
|
6
|
+
# Surveyor::Config['setting.name'] = 'value'
|
7
|
+
# Surveyor::Config['setting.name'] #=> "value"
|
8
|
+
#
|
9
|
+
# Currently, there is not a way to edit configuration through the admin
|
10
|
+
# system so it must be done manually. The console script is probably the
|
11
|
+
# easiest way to this:
|
12
|
+
#
|
13
|
+
# % script/console production
|
14
|
+
# Loading production environment.
|
15
|
+
# >> Surveyor::Config['setting.name'] = 'value'
|
16
|
+
# => "value"
|
17
|
+
# >>
|
18
|
+
#
|
19
|
+
# Surveyor currently uses the following settings:
|
20
|
+
#
|
21
|
+
# defaults.title :: the title of the survey system
|
22
|
+
# defaults.layout :: the layout used by the survey system
|
23
|
+
|
24
|
+
class Config
|
25
|
+
@@config_hash = {}
|
26
|
+
|
27
|
+
class << self
|
28
|
+
def [](key)
|
29
|
+
@@config_hash[key]
|
30
|
+
end
|
31
|
+
|
32
|
+
def []=(key, value)
|
33
|
+
@@config_hash[key] = value
|
34
|
+
end
|
35
|
+
|
36
|
+
def to_hash
|
37
|
+
@@config_hash
|
38
|
+
end
|
39
|
+
|
40
|
+
def run
|
41
|
+
yield self if block_given?
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
desc "generate and load survey (specify FILE=surveys/your_survey.rb)"
|
2
|
+
task :surveyor => :"surveyor:default"
|
3
|
+
|
4
|
+
namespace :surveyor do
|
5
|
+
|
6
|
+
task :default => [:generate_fixtures, :load_fixtures]
|
7
|
+
|
8
|
+
desc "generate survey fixtures from survey file"
|
9
|
+
task :generate_fixtures => :environment do
|
10
|
+
require File.join(File.dirname(__FILE__), "../../script/surveyor/parser")
|
11
|
+
raise "USAGE: file name required e.g. 'FILE=surveys/kitchen_sink_survey.rb'" if ENV["FILE"].blank?
|
12
|
+
fixture_dir = File.join(RAILS_ROOT, "surveys", "fixtures")
|
13
|
+
mkdir fixture_dir unless File.exists?(fixture_dir)
|
14
|
+
SurveyParser::Parser.parse(File.join(RAILS_ROOT, ENV["FILE"]))
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "load survey fixtures"
|
18
|
+
task :load_fixtures => :environment do
|
19
|
+
require 'active_record/fixtures'
|
20
|
+
require 'fixtures_extensions' unless ENV["APPEND"].blank?
|
21
|
+
ActiveRecord::Base.establish_connection(Rails.env)
|
22
|
+
|
23
|
+
fixture_dir = File.join(RAILS_ROOT, "surveys", "fixtures")
|
24
|
+
fixtures = Dir.glob("#{fixture_dir}/*.yml")
|
25
|
+
raise "No fixtures found." if fixtures.empty?
|
26
|
+
|
27
|
+
fixtures.each do |file_name|
|
28
|
+
puts "Loading #{file_name}..."
|
29
|
+
Fixtures.create_fixtures(fixture_dir, File.basename(file_name, '.*'))
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module XmlFormatter
|
2
|
+
def to_xml(options = {})
|
3
|
+
options[:indent] ||= 2
|
4
|
+
xml = options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent])
|
5
|
+
xml.instruct! unless options[:skip_instruct]
|
6
|
+
xml.tag!(self.class.name.downcase.to_sym, self.attributes) do
|
7
|
+
self.class.reflect_on_all_associations.to_a.each do |assoc|
|
8
|
+
xml.tag!(assoc.name)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|