surveyor 0.14.5 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +12 -4
- data/VERSION +1 -1
- data/features/step_definitions/surveyor_steps.rb +64 -4
- data/features/surveyor.feature +144 -11
- data/lib/surveyor.rb +0 -4
- data/lib/surveyor/acts_as_response.rb +13 -29
- data/lib/surveyor/common.rb +2 -2
- data/lib/surveyor/models/answer_methods.rb +14 -1
- data/lib/surveyor/models/dependency_condition_methods.rb +4 -3
- data/lib/surveyor/models/question_methods.rb +11 -1
- data/lib/surveyor/models/response_methods.rb +2 -1
- data/lib/surveyor/models/survey_methods.rb +10 -2
- data/lib/surveyor/models/survey_section_methods.rb +11 -1
- data/lib/surveyor/models/validation_condition_methods.rb +3 -2
- data/lib/surveyor/models/validation_methods.rb +2 -2
- data/lib/surveyor/parser.rb +274 -0
- data/lib/tasks/surveyor_tasks.rake +25 -25
- data/spec/factories.rb +1 -1
- data/spec/lib/common_spec.rb +22 -0
- data/spec/lib/parser_spec.rb +30 -0
- data/spec/models/answer_spec.rb +6 -5
- data/spec/models/dependency_condition_spec.rb +7 -6
- data/spec/models/question_spec.rb +12 -10
- data/spec/models/survey_section_spec.rb +3 -2
- data/spec/models/survey_spec.rb +11 -0
- data/spec/models/validation_condition_spec.rb +5 -5
- data/spec/models/validation_spec.rb +5 -4
- data/surveyor.gemspec +7 -23
- metadata +10 -26
- data/lib/fixtures_extensions.rb +0 -6
- data/script/surveyor/answer.rb +0 -54
- data/script/surveyor/base.rb +0 -75
- data/script/surveyor/dependency.rb +0 -13
- data/script/surveyor/dependency_condition.rb +0 -40
- data/script/surveyor/parser.rb +0 -223
- data/script/surveyor/question.rb +0 -59
- data/script/surveyor/question_group.rb +0 -26
- data/script/surveyor/specs/answer_spec.rb +0 -29
- data/script/surveyor/specs/question_spec.rb +0 -63
- data/script/surveyor/specs/spec_helper.rb +0 -7
- data/script/surveyor/specs/survey_section_spec.rb +0 -23
- data/script/surveyor/specs/validation_condition_spec.rb +0 -20
- data/script/surveyor/specs/validation_spec.rb +0 -20
- data/script/surveyor/survey.rb +0 -34
- data/script/surveyor/survey_section.rb +0 -21
- data/script/surveyor/validation.rb +0 -21
- data/script/surveyor/validation_condition.rb +0 -21
- data/script/surveyor/whr_dsl.tmproj +0 -244
- data/spec/lib/surveyor_spec.rb +0 -44
@@ -1,20 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
require 'validation'
|
3
|
-
|
4
|
-
describe SurveyParser::Validation, " when first created" do
|
5
|
-
before do
|
6
|
-
answer = mock("SurveyParser::Answer", :id => 2, :parser => mock("SurveyParser::Parser", :new_validation_id => 1))
|
7
|
-
answer.stub!(:class => SurveyParser::Answer)
|
8
|
-
args = [{:rule => "C", :message => "Please select a number between 0 and 120"}]
|
9
|
-
options = {}
|
10
|
-
@validation = SurveyParser::Validation.new(answer, args, options)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should set initialization parameters properly" do
|
14
|
-
@validation.id.should == 1
|
15
|
-
@validation.message.should == "Please select a number between 0 and 120"
|
16
|
-
@validation.answer_id.should == 2
|
17
|
-
@validation.rule.should == "C"
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
data/script/surveyor/survey.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
module SurveyParser
|
2
|
-
class Survey < SurveyParser::Base
|
3
|
-
# Context, Content, Reference, Expiry, Display
|
4
|
-
attr_accessor :id, :parser
|
5
|
-
attr_accessor :title, :description
|
6
|
-
attr_accessor :access_code, :reference_identifier, :data_export_identifier, :common_namespace, :common_identitier
|
7
|
-
attr_accessor :active_at, :inactive_at
|
8
|
-
attr_accessor :css_url, :custom_class
|
9
|
-
has_children :survey_sections
|
10
|
-
|
11
|
-
def parse_args(args)
|
12
|
-
title = args[0]
|
13
|
-
{:title => title, :access_code => Surveyor::Common.to_normalized_string(title)}.merge(args[1] || {})
|
14
|
-
end
|
15
|
-
|
16
|
-
def find_question_by_reference(ref_id)
|
17
|
-
found = nil
|
18
|
-
survey_sections.detect{|s| found = s.find_question_by_reference(ref_id)}
|
19
|
-
return found
|
20
|
-
end
|
21
|
-
|
22
|
-
def reconcile_dependencies
|
23
|
-
survey_sections.each do |section|
|
24
|
-
section.questions.each do |question|
|
25
|
-
question.dependency.dependency_conditions.each { |con| con.reconcile_dependencies} unless question.dependency.nil?
|
26
|
-
end
|
27
|
-
section.question_groups.each do |group|
|
28
|
-
group.dependency.dependency_conditions.each { |con| con.reconcile_dependencies} unless group.dependency.nil?
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module SurveyParser
|
2
|
-
class SurveySection < SurveyParser::Base
|
3
|
-
# Context, Content, Display, Reference, Children, Placeholders
|
4
|
-
attr_accessor :id, :parser, :survey_id
|
5
|
-
attr_accessor :title, :description
|
6
|
-
attr_accessor :reference_identifier, :data_export_identifier, :common_namespace, :common_identitier
|
7
|
-
attr_accessor :display_order, :custom_class
|
8
|
-
has_children :question_groups, :questions
|
9
|
-
|
10
|
-
def parse_args(args)
|
11
|
-
title = args[0]
|
12
|
-
{:title => title, :data_export_identifier => Surveyor::Common.to_normalized_string(title)}.merge(args[1] || {})
|
13
|
-
end
|
14
|
-
|
15
|
-
# Used to find questions for dependency linking
|
16
|
-
def find_question_by_reference(ref_id)
|
17
|
-
self.questions.detect{|q| q.reference_identifier == ref_id}
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module SurveyParser
|
2
|
-
class Validation < SurveyParser::Base
|
3
|
-
|
4
|
-
# Context, Conditional, Children
|
5
|
-
attr_accessor :id, :answer_id, :parser
|
6
|
-
attr_accessor :rule, :message
|
7
|
-
has_children :validation_conditions
|
8
|
-
|
9
|
-
|
10
|
-
def default_options
|
11
|
-
{:rule => "A"}
|
12
|
-
end
|
13
|
-
def parse_args(args)
|
14
|
-
args[0] || {}
|
15
|
-
end
|
16
|
-
def parse_opts(opts)
|
17
|
-
{} # toss the method name and reference identifier by default
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module SurveyParser
|
2
|
-
class ValidationCondition < SurveyParser::Base
|
3
|
-
# Context, Conditional, Value, Reference
|
4
|
-
attr_accessor :id, :validation_id, :rule_key, :parser
|
5
|
-
attr_accessor :operator
|
6
|
-
attr_accessor :question_id, :answer_id, :datetime_value, :integer_value, :float_value, :unit, :text_value, :string_value, :response_other, :regexp
|
7
|
-
attr_accessor :question_reference, :answer_reference
|
8
|
-
|
9
|
-
def default_options
|
10
|
-
{ :operator => "==" }
|
11
|
-
end
|
12
|
-
def parse_args(args)
|
13
|
-
a0, a1 = args
|
14
|
-
{:operator => a0}.merge(a1 || {})
|
15
|
-
end
|
16
|
-
def parse_opts(opts)
|
17
|
-
{:rule_key => opts[:reference_identifier]}
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|
@@ -1,244 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
|
-
<plist version="1.0">
|
4
|
-
<dict>
|
5
|
-
<key>currentDocument</key>
|
6
|
-
<string>whrparse.rb</string>
|
7
|
-
<key>documents</key>
|
8
|
-
<array>
|
9
|
-
<dict>
|
10
|
-
<key>expanded</key>
|
11
|
-
<true/>
|
12
|
-
<key>name</key>
|
13
|
-
<string>whr_dsl</string>
|
14
|
-
<key>regexFolderFilter</key>
|
15
|
-
<string>!.*/(\.[^/]*|CVS|_darcs|_MTN|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$</string>
|
16
|
-
<key>sourceDirectory</key>
|
17
|
-
<string></string>
|
18
|
-
</dict>
|
19
|
-
</array>
|
20
|
-
<key>fileHierarchyDrawerWidth</key>
|
21
|
-
<integer>261</integer>
|
22
|
-
<key>metaData</key>
|
23
|
-
<dict>
|
24
|
-
<key>answer.rb</key>
|
25
|
-
<dict>
|
26
|
-
<key>caret</key>
|
27
|
-
<dict>
|
28
|
-
<key>column</key>
|
29
|
-
<integer>5</integer>
|
30
|
-
<key>line</key>
|
31
|
-
<integer>54</integer>
|
32
|
-
</dict>
|
33
|
-
<key>firstVisibleColumn</key>
|
34
|
-
<integer>0</integer>
|
35
|
-
<key>firstVisibleLine</key>
|
36
|
-
<integer>13</integer>
|
37
|
-
</dict>
|
38
|
-
<key>columnizer.rb</key>
|
39
|
-
<dict>
|
40
|
-
<key>caret</key>
|
41
|
-
<dict>
|
42
|
-
<key>column</key>
|
43
|
-
<integer>112</integer>
|
44
|
-
<key>line</key>
|
45
|
-
<integer>3</integer>
|
46
|
-
</dict>
|
47
|
-
<key>firstVisibleColumn</key>
|
48
|
-
<integer>0</integer>
|
49
|
-
<key>firstVisibleLine</key>
|
50
|
-
<integer>0</integer>
|
51
|
-
</dict>
|
52
|
-
<key>partials/_checkboxes.rhtml</key>
|
53
|
-
<dict>
|
54
|
-
<key>caret</key>
|
55
|
-
<dict>
|
56
|
-
<key>column</key>
|
57
|
-
<integer>0</integer>
|
58
|
-
<key>line</key>
|
59
|
-
<integer>0</integer>
|
60
|
-
</dict>
|
61
|
-
<key>firstVisibleColumn</key>
|
62
|
-
<integer>0</integer>
|
63
|
-
<key>firstVisibleLine</key>
|
64
|
-
<integer>0</integer>
|
65
|
-
</dict>
|
66
|
-
<key>partials/_date.rhtml</key>
|
67
|
-
<dict>
|
68
|
-
<key>caret</key>
|
69
|
-
<dict>
|
70
|
-
<key>column</key>
|
71
|
-
<integer>0</integer>
|
72
|
-
<key>line</key>
|
73
|
-
<integer>0</integer>
|
74
|
-
</dict>
|
75
|
-
<key>firstVisibleColumn</key>
|
76
|
-
<integer>0</integer>
|
77
|
-
<key>firstVisibleLine</key>
|
78
|
-
<integer>0</integer>
|
79
|
-
</dict>
|
80
|
-
<key>question.rb</key>
|
81
|
-
<dict>
|
82
|
-
<key>caret</key>
|
83
|
-
<dict>
|
84
|
-
<key>column</key>
|
85
|
-
<integer>68</integer>
|
86
|
-
<key>line</key>
|
87
|
-
<integer>68</integer>
|
88
|
-
</dict>
|
89
|
-
<key>firstVisibleColumn</key>
|
90
|
-
<integer>0</integer>
|
91
|
-
<key>firstVisibleLine</key>
|
92
|
-
<integer>46</integer>
|
93
|
-
</dict>
|
94
|
-
<key>registry_code.rb</key>
|
95
|
-
<dict>
|
96
|
-
<key>caret</key>
|
97
|
-
<dict>
|
98
|
-
<key>column</key>
|
99
|
-
<integer>49</integer>
|
100
|
-
<key>line</key>
|
101
|
-
<integer>19</integer>
|
102
|
-
</dict>
|
103
|
-
<key>firstVisibleColumn</key>
|
104
|
-
<integer>0</integer>
|
105
|
-
<key>firstVisibleLine</key>
|
106
|
-
<integer>0</integer>
|
107
|
-
</dict>
|
108
|
-
<key>section.rb</key>
|
109
|
-
<dict>
|
110
|
-
<key>caret</key>
|
111
|
-
<dict>
|
112
|
-
<key>column</key>
|
113
|
-
<integer>9</integer>
|
114
|
-
<key>line</key>
|
115
|
-
<integer>98</integer>
|
116
|
-
</dict>
|
117
|
-
<key>firstVisibleColumn</key>
|
118
|
-
<integer>0</integer>
|
119
|
-
<key>firstVisibleLine</key>
|
120
|
-
<integer>59</integer>
|
121
|
-
</dict>
|
122
|
-
<key>section_template.rhtml</key>
|
123
|
-
<dict>
|
124
|
-
<key>caret</key>
|
125
|
-
<dict>
|
126
|
-
<key>column</key>
|
127
|
-
<integer>134</integer>
|
128
|
-
<key>line</key>
|
129
|
-
<integer>3</integer>
|
130
|
-
</dict>
|
131
|
-
<key>firstVisibleColumn</key>
|
132
|
-
<integer>0</integer>
|
133
|
-
<key>firstVisibleLine</key>
|
134
|
-
<integer>0</integer>
|
135
|
-
</dict>
|
136
|
-
<key>specs/answer_spec.rb</key>
|
137
|
-
<dict>
|
138
|
-
<key>caret</key>
|
139
|
-
<dict>
|
140
|
-
<key>column</key>
|
141
|
-
<integer>50</integer>
|
142
|
-
<key>line</key>
|
143
|
-
<integer>24</integer>
|
144
|
-
</dict>
|
145
|
-
<key>columnSelection</key>
|
146
|
-
<false/>
|
147
|
-
<key>firstVisibleColumn</key>
|
148
|
-
<integer>0</integer>
|
149
|
-
<key>firstVisibleLine</key>
|
150
|
-
<integer>3</integer>
|
151
|
-
<key>selectFrom</key>
|
152
|
-
<dict>
|
153
|
-
<key>column</key>
|
154
|
-
<integer>60</integer>
|
155
|
-
<key>line</key>
|
156
|
-
<integer>24</integer>
|
157
|
-
</dict>
|
158
|
-
<key>selectTo</key>
|
159
|
-
<dict>
|
160
|
-
<key>column</key>
|
161
|
-
<integer>50</integer>
|
162
|
-
<key>line</key>
|
163
|
-
<integer>24</integer>
|
164
|
-
</dict>
|
165
|
-
</dict>
|
166
|
-
<key>specs/question_spec.rb</key>
|
167
|
-
<dict>
|
168
|
-
<key>caret</key>
|
169
|
-
<dict>
|
170
|
-
<key>column</key>
|
171
|
-
<integer>21</integer>
|
172
|
-
<key>line</key>
|
173
|
-
<integer>5</integer>
|
174
|
-
</dict>
|
175
|
-
<key>firstVisibleColumn</key>
|
176
|
-
<integer>0</integer>
|
177
|
-
<key>firstVisibleLine</key>
|
178
|
-
<integer>0</integer>
|
179
|
-
</dict>
|
180
|
-
<key>specs/section_spec.rb</key>
|
181
|
-
<dict>
|
182
|
-
<key>caret</key>
|
183
|
-
<dict>
|
184
|
-
<key>column</key>
|
185
|
-
<integer>43</integer>
|
186
|
-
<key>line</key>
|
187
|
-
<integer>43</integer>
|
188
|
-
</dict>
|
189
|
-
<key>firstVisibleColumn</key>
|
190
|
-
<integer>0</integer>
|
191
|
-
<key>firstVisibleLine</key>
|
192
|
-
<integer>0</integer>
|
193
|
-
</dict>
|
194
|
-
<key>specs/whrparse_spec.rb</key>
|
195
|
-
<dict>
|
196
|
-
<key>caret</key>
|
197
|
-
<dict>
|
198
|
-
<key>column</key>
|
199
|
-
<integer>5</integer>
|
200
|
-
<key>line</key>
|
201
|
-
<integer>6</integer>
|
202
|
-
</dict>
|
203
|
-
<key>firstVisibleColumn</key>
|
204
|
-
<integer>0</integer>
|
205
|
-
<key>firstVisibleLine</key>
|
206
|
-
<integer>0</integer>
|
207
|
-
</dict>
|
208
|
-
<key>whrparse.rb</key>
|
209
|
-
<dict>
|
210
|
-
<key>caret</key>
|
211
|
-
<dict>
|
212
|
-
<key>column</key>
|
213
|
-
<integer>9</integer>
|
214
|
-
<key>line</key>
|
215
|
-
<integer>20</integer>
|
216
|
-
</dict>
|
217
|
-
<key>firstVisibleColumn</key>
|
218
|
-
<integer>0</integer>
|
219
|
-
<key>firstVisibleLine</key>
|
220
|
-
<integer>0</integer>
|
221
|
-
</dict>
|
222
|
-
</dict>
|
223
|
-
<key>openDocuments</key>
|
224
|
-
<array>
|
225
|
-
<string>registry_code.rb</string>
|
226
|
-
<string>whrparse.rb</string>
|
227
|
-
<string>specs/answer_spec.rb</string>
|
228
|
-
<string>specs/question_spec.rb</string>
|
229
|
-
<string>specs/section_spec.rb</string>
|
230
|
-
<string>section.rb</string>
|
231
|
-
<string>section_template.rhtml</string>
|
232
|
-
<string>partials/_date.rhtml</string>
|
233
|
-
<string>partials/_checkboxes.rhtml</string>
|
234
|
-
<string>columnizer.rb</string>
|
235
|
-
<string>specs/whrparse_spec.rb</string>
|
236
|
-
<string>question.rb</string>
|
237
|
-
<string>answer.rb</string>
|
238
|
-
</array>
|
239
|
-
<key>showFileHierarchyDrawer</key>
|
240
|
-
<true/>
|
241
|
-
<key>windowFrame</key>
|
242
|
-
<string>{{282, 61}, {1119, 816}}</string>
|
243
|
-
</dict>
|
244
|
-
</plist>
|
data/spec/lib/surveyor_spec.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../lib/surveyor')
|
2
|
-
|
3
|
-
describe Surveyor do
|
4
|
-
it "should create a normalized code from the answer text" do
|
5
|
-
# The answer object should take the title of the text and convert it to a code that is more appropirate for a database entry
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
# Taking a few answers from the survey for testing
|
11
|
-
strings = [ "This? is a in - t3rrible-@nswer of! (question) on",
|
12
|
-
"Private insurance/ HMO/ PPO",
|
13
|
-
"<bold>VA</bold>",
|
14
|
-
"PMS (Premenstrual syndrome)/ PMDD (Premenstrual Dysphoric Disorder)",
|
15
|
-
"Have never been employed outside the home",
|
16
|
-
"Professional",
|
17
|
-
"Not working because of temporary disability, but expect to return to a job",
|
18
|
-
"How long has it been since you last visited a doctor for a routine checkup (routine being not for a particular reason)?",
|
19
|
-
"Do you take medications as directed?",
|
20
|
-
"Do you every leak urine (or) water when you didn't want to?", #checking for () and ' removal
|
21
|
-
"Do your biological family members (not adopted) have a \"history\" of any of the following?",
|
22
|
-
"Your health:",
|
23
|
-
"In general, you would say your health is:" ]
|
24
|
-
|
25
|
-
# What the results should look like
|
26
|
-
codes = [ "this_t3rrible_nswer",
|
27
|
-
"private_insurance_hmo_ppo",
|
28
|
-
"va",
|
29
|
-
"pms_pmdd",
|
30
|
-
"never_been_employed_outside_home",
|
31
|
-
"professional",
|
32
|
-
"temporary_disability_expect_return_job",
|
33
|
-
"visited_doctor_for_routine_checkup",
|
34
|
-
"you_take_medications_as_directed",
|
35
|
-
"urine_water_you_didnt_want",
|
36
|
-
"family_members_history_any_following",
|
37
|
-
"your_health",
|
38
|
-
"you_would_say_your_health" ]
|
39
|
-
|
40
|
-
strings.each_with_index do |s, i|
|
41
|
-
Surveyor::Common.to_normalized_string(s).should == codes[i]
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|