typed_form 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a388e80e46e93cdf800db1cd021694a69ed9aed0
4
- data.tar.gz: 2130492e803088d27ecf5d91576c9ba212b3e566
3
+ metadata.gz: 1040c6aea3cd1bfa22bd1270113948506f618093
4
+ data.tar.gz: 961b3445eeb8887ec5789b756bef80154ec03720
5
5
  SHA512:
6
- metadata.gz: '089b3bdba82b45d19823f71d1474c58dd088ee0516c66a133c7661c4b9f6bd88bc7341f11661930da29232aa85a616e5e69480c32172b4d82a417604dddf3f17'
7
- data.tar.gz: 5800494788d591fc198451074850f01009665643eca9bb854fcf3c68edcfa12c813b4a3356ba1c8e3b2fd7c2993f516de5e04c799abe9862e9c79f5ae3acee91
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/ 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.
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)/ }
@@ -15,7 +15,13 @@ module TypedForm
15
15
  end
16
16
 
17
17
  def type
18
- @_type ||= field_id.split("_")[0]
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
@@ -1,3 +1,3 @@
1
1
  module TypedForm
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/typed_form.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "httparty"
2
2
  require "forwardable"
3
+ require "byebug"
3
4
  require "arendelle"
4
5
  require "typed_form/client"
5
6
  require "typed_form/json_response_handler"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typed_form
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Cole