easy_flow 0.5.0 → 0.6.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.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3e565fcc4e95b85f7910540f6146c9e8f41273d4f4b10cbbe5f5ea1e0c9206de
|
|
4
|
+
data.tar.gz: 8e2b2c0412a31dee8362e57277e5fc8ab6e5390f496582608afb6059669270d8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7c0e0d7b2889c2c4dc5fd0f6b8d338c1980f64a97c896386030f5996bcd9141154d0d5918878d6d5f3c05e7ac3ebe96952796875eeb528afe9004f23f2153211
|
|
7
|
+
data.tar.gz: d52a2bacea91c23509b3018009b5a1ed052ab31e7b2bd1c02ba879d8dbebcc669a06c17cee72a8faf09750ed55338dc1f2fee5e75b7b112a363d23d2ad4609e4
|
|
@@ -107,6 +107,8 @@ module EasyFlow
|
|
|
107
107
|
def submitted_answers
|
|
108
108
|
given = params.fetch(:answers, {})
|
|
109
109
|
answers = given.permit(*given.keys.select { |key| @guide.step(key) }).to_h.symbolize_keys
|
|
110
|
+
return one_answer_back(answers) if params[:back].present?
|
|
111
|
+
|
|
110
112
|
key = params[:asked].to_s.to_sym
|
|
111
113
|
asked = @guide.step(key)
|
|
112
114
|
return answers unless asked
|
|
@@ -116,6 +118,11 @@ module EasyFlow
|
|
|
116
118
|
@refused ? answers.except(key) : answers.merge(key => answer)
|
|
117
119
|
end
|
|
118
120
|
|
|
121
|
+
def one_answer_back(answers)
|
|
122
|
+
answered = @guide.state_on_path(answers)
|
|
123
|
+
answered.except(answered.keys.last)
|
|
124
|
+
end
|
|
125
|
+
|
|
119
126
|
def record_submitted
|
|
120
127
|
id, value = params.fetch(:answers, {}).permit(*asked).to_h.first
|
|
121
128
|
id ||= params[:asked].presence_in(asked)
|
|
@@ -71,6 +71,16 @@ module EasyFlow
|
|
|
71
71
|
state.slice(*walk(state).first)
|
|
72
72
|
end
|
|
73
73
|
|
|
74
|
+
def questions_left(state)
|
|
75
|
+
cursor = next_step(state) && step(next_step(state).id)
|
|
76
|
+
left = 0
|
|
77
|
+
while cursor && decided?(cursor, state)
|
|
78
|
+
left += 1 if step_type(cursor)&.awaits_input?
|
|
79
|
+
cursor = successor(cursor, state)
|
|
80
|
+
end
|
|
81
|
+
left
|
|
82
|
+
end
|
|
83
|
+
|
|
74
84
|
private
|
|
75
85
|
|
|
76
86
|
def walk(state)
|
|
@@ -100,6 +110,12 @@ module EasyFlow
|
|
|
100
110
|
[ recorded, nil ]
|
|
101
111
|
end
|
|
102
112
|
|
|
113
|
+
def decided?(node, state)
|
|
114
|
+
return true unless step_type(node)&.routes?
|
|
115
|
+
|
|
116
|
+
step_type(node).settings.naming_steps.all? { |setting| state.key?(node.config[setting.to_s].to_s) }
|
|
117
|
+
end
|
|
118
|
+
|
|
103
119
|
def visit_key(id, visit)
|
|
104
120
|
visit == 1 ? id : "#{id}@#{visit}"
|
|
105
121
|
end
|
|
@@ -40,6 +40,10 @@ module EasyFlow
|
|
|
40
40
|
@digest.state_on_path(named(state)).symbolize_keys
|
|
41
41
|
end
|
|
42
42
|
|
|
43
|
+
def questions_left(state)
|
|
44
|
+
@digest.questions_left(named(state))
|
|
45
|
+
end
|
|
46
|
+
|
|
43
47
|
def steps_on_path(state)
|
|
44
48
|
state_on_path(state).keys.map { |id| shown(@digest.step(id.to_s)) }
|
|
45
49
|
end
|
data/lib/easy_flow/version.rb
CHANGED