typed_form 0.0.2 → 0.0.3
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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/typed_form/form_response.rb +0 -6
- data/lib/typed_form/question.rb +15 -1
- data/lib/typed_form/version.rb +1 -1
- data/lib/typed_form.rb +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1040c6aea3cd1bfa22bd1270113948506f618093
|
4
|
+
data.tar.gz: 961b3445eeb8887ec5789b756bef80154ec03720
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b33c79a8bbb090f60e8a7f57b592ae8833d0e521f36d5ab69d447cd3c4992326bc73238bb531a8b28926467ed00cdf84fa220ef6fcbf1d404f102f6038362c4b
|
7
|
+
data.tar.gz: 28f39c791e87beb6806b8792cd4b47125cee848121fa2d13a982bde6ad1264740d31d92e91078e8fa4622df8c2f3369db91dd0c63c2c037e25d38bf9f8870faf
|
data/README.md
CHANGED
@@ -45,7 +45,7 @@ In addition to piping/interpolation, Typeform's data is structured in a difficul
|
|
45
45
|
|
46
46
|
Finally, if you've ever tried to duplicate a Typeform Form, you'll notice that their response field IDs completely change, and can no longer be used for locating answers. This gem attempts to solve that as well, by associating questions and answers together based on their results.
|
47
47
|
|
48
|
-
Take a look at https://github.com/useed/typed_form/spec/fixtures
|
48
|
+
Take a look at https://github.com/useed/typed_form/tree/master/spec/fixtures for examples of what you can expect when it comes to their data API; this should help shed some additional light on the purpose behind this gem.
|
49
49
|
|
50
50
|
|
51
51
|
## Installation
|
@@ -33,12 +33,6 @@ module TypedForm
|
|
33
33
|
raise ArgumentError, "Grouped questions do not have matching text"
|
34
34
|
end
|
35
35
|
|
36
|
-
def type_for_grouped(grouped_questions)
|
37
|
-
types = questions.map(&:type)
|
38
|
-
return types.first if types.uniq.size == 1
|
39
|
-
raise ArgumentError, "Grouped questions do not have matching types"
|
40
|
-
end
|
41
|
-
|
42
36
|
def answerable_questions
|
43
37
|
parsed_questions
|
44
38
|
.reject { |q| q.id.match /(hidden|legal|statement|group)/ }
|
data/lib/typed_form/question.rb
CHANGED
@@ -15,7 +15,13 @@ module TypedForm
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def type
|
18
|
-
@_type ||=
|
18
|
+
@_type ||= determine_type
|
19
|
+
end
|
20
|
+
|
21
|
+
def type_for_grouped(grouped_questions)
|
22
|
+
types = questions.map(&:type)
|
23
|
+
return types.first if types.uniq.size == 1
|
24
|
+
raise ArgumentError, "Grouped questions do not have matching types"
|
19
25
|
end
|
20
26
|
|
21
27
|
def self.with_response_data(question:, text:, answer:)
|
@@ -24,5 +30,13 @@ module TypedForm
|
|
24
30
|
new_question.text = text
|
25
31
|
end
|
26
32
|
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def determine_type
|
37
|
+
detected_type = ids.map { |id| id.split("_")[0] }.uniq
|
38
|
+
return detected_type.first if detected_type.size == 1
|
39
|
+
raise StandardError, "Cannot detect type of question ids #{ids}"
|
40
|
+
end
|
27
41
|
end
|
28
42
|
end
|
data/lib/typed_form/version.rb
CHANGED
data/lib/typed_form.rb
CHANGED