quby-compiler 0.4.9 → 0.4.10
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: 0a76be7d6ec0fbd4f1fabe4beeacd159210a050fe62ab79b69198f472dfefd42
|
4
|
+
data.tar.gz: 01a6a867ec3680ae24f49447000bd0d95dcb465cd1c9cba5fd71d66079c5c150
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a863660e2399ca7472cd1e2353c72444405fb8bd859da2c5b259097e77d0522493867ccd0b6b690a2c6c5000c65fc829ff4e85ac69f46a7b0ddd0dd960a756c
|
7
|
+
data.tar.gz: b96591eb23810f2e66cbf1111e9232a691b3bf508efe8402cf3473e5201a734818c0f459b6fb959a6b54303c81f83e7c41019b8815a94fda7ac424410fb43c36
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# 0.4.10
|
2
|
+
|
3
|
+
* quby2.json: Fix validations json (regex-serialization and key-capitalization)
|
4
|
+
* roqua.json: Change questions, options, date_parts, scores, subscores and outcome_tables from hash to array, since ordering is important and not all systems preserve the order of hashes (like pg's jsonb)
|
5
|
+
|
1
6
|
# 0.4.9
|
2
7
|
|
3
8
|
* roqua.json: Fix html stripping for string with no whitespace
|
@@ -6,10 +6,23 @@ module Quby
|
|
6
6
|
@questionnaire = questionnaire
|
7
7
|
end
|
8
8
|
|
9
|
+
# TODO: Move all attributes here from Questionnaire#as_json
|
9
10
|
def as_json(options = {})
|
10
|
-
@questionnaire.as_json
|
11
|
+
@questionnaire.as_json.merge \
|
12
|
+
validations: validations
|
13
|
+
end
|
14
|
+
|
15
|
+
def validations
|
16
|
+
@questionnaire.validations.map do |validation|
|
17
|
+
validation.config.compact
|
18
|
+
.transform_keys{ _1.to_s.camelize(:lower) }
|
19
|
+
.tap do |validation_hsh|
|
20
|
+
# otherwise ruby will put a (?-mix around the regex, which js errors on.
|
21
|
+
validation_hsh['matcher'] = validation_hsh['matcher'].source.to_s if validation_hsh['matcher']
|
22
|
+
end.as_json
|
23
|
+
end
|
11
24
|
end
|
12
25
|
end
|
13
26
|
end
|
14
27
|
end
|
15
|
-
end
|
28
|
+
end
|
@@ -107,15 +107,18 @@ module Quby
|
|
107
107
|
|
108
108
|
def outcome_tables_from_definition
|
109
109
|
# hash of tables, with the score keys (rows) and subscore keys (columns) used for each
|
110
|
-
tables =
|
110
|
+
tables = []
|
111
111
|
# hash of `subscore_key: subscore_label` pairs used in tables
|
112
112
|
headers = {}
|
113
113
|
|
114
114
|
questionnaire.outcome_tables.each do |table|
|
115
|
-
tables
|
116
|
-
|
117
|
-
|
118
|
-
|
115
|
+
tables << {
|
116
|
+
key: table.key,
|
117
|
+
name: table.name,
|
118
|
+
default_collapsed: table.default_collapsed,
|
119
|
+
score_keys: table.score_keys,
|
120
|
+
subscore_keys: table.subscore_keys
|
121
|
+
}.compact
|
119
122
|
|
120
123
|
table.subscore_keys.each do |subscore_key|
|
121
124
|
table.score_keys.find do |score_key|
|
@@ -142,6 +145,7 @@ module Quby
|
|
142
145
|
questionnaire.score_schemas.values.each do |schema|
|
143
146
|
schema.subscore_schemas.each do |subschema|
|
144
147
|
next if subschema.outcome_table.blank?
|
148
|
+
tables[subschema.outcome_table][:key] = subschema.outcome_table
|
145
149
|
tables[subschema.outcome_table][:subscore_keys] << subschema.key
|
146
150
|
tables[subschema.outcome_table][:score_keys] << schema.key
|
147
151
|
headers[subschema.key] = subschema.label
|
@@ -150,7 +154,7 @@ module Quby
|
|
150
154
|
|
151
155
|
{
|
152
156
|
headers: headers,
|
153
|
-
tables: tables,
|
157
|
+
tables: tables.values,
|
154
158
|
}
|
155
159
|
end
|
156
160
|
|
@@ -170,25 +174,22 @@ module Quby
|
|
170
174
|
# date_parts [nil/{..}]
|
171
175
|
# options: [nil/{..}]
|
172
176
|
def questions
|
173
|
-
questionnaire.sorted_questions.reject{_1.type == :hidden}.
|
174
|
-
|
175
|
-
question.key,
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
options: options_for(question)
|
190
|
-
}.compact
|
191
|
-
]
|
177
|
+
questionnaire.sorted_questions.reject{_1.type == :hidden}.map { |question|
|
178
|
+
{
|
179
|
+
key: question.key,
|
180
|
+
sbg_key: question.sbg_key,
|
181
|
+
type: QUBY_TYPE_TO_ROQUA_TYPE.fetch(question.type),
|
182
|
+
title: parse_markdown_and_strip_tags(question.title),
|
183
|
+
context_free_title: question.context_free_title,
|
184
|
+
unit: question.unit,
|
185
|
+
deprecated: question.hidden.presence,
|
186
|
+
default_invisible: question.default_invisible.presence,
|
187
|
+
parent_question_key: question.parent&.key,
|
188
|
+
parent_option_key: question.parent_option_key,
|
189
|
+
title_question_key: question.title_question&.key,
|
190
|
+
date_parts: date_parts_for(question),
|
191
|
+
options: options_for(question)
|
192
|
+
}.compact
|
192
193
|
}
|
193
194
|
end
|
194
195
|
|
@@ -197,13 +198,11 @@ module Quby
|
|
197
198
|
def date_parts_for(question)
|
198
199
|
return nil unless question.type == :date
|
199
200
|
|
200
|
-
question.components.
|
201
|
-
|
202
|
-
component,
|
203
|
-
{
|
204
|
-
|
205
|
-
}
|
206
|
-
]
|
201
|
+
question.components.map { |component|
|
202
|
+
{
|
203
|
+
part: component,
|
204
|
+
key: question.send("#{component}_key")
|
205
|
+
}
|
207
206
|
}
|
208
207
|
end
|
209
208
|
|
@@ -216,22 +215,19 @@ module Quby
|
|
216
215
|
return nil if question.options.empty?
|
217
216
|
|
218
217
|
question.options.reject { |option| option.inner_title || option.placeholder }
|
219
|
-
.
|
220
|
-
|
221
|
-
option.key,
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
child_question_keys: option.questions.map(&:key).presence
|
227
|
-
}.compact
|
228
|
-
]
|
218
|
+
.map { |option|
|
219
|
+
{
|
220
|
+
key: option.key,
|
221
|
+
value: (option.value.to_s unless question.type == :check_box),
|
222
|
+
description: option.context_free_description || parse_markdown_and_strip_tags(option.description),
|
223
|
+
child_question_keys: option.questions.map(&:key).presence
|
224
|
+
}.compact
|
229
225
|
}
|
230
226
|
end
|
231
227
|
|
232
228
|
# [{ key: { .., subscores: { subkey: {..} } } }]
|
233
229
|
def scores
|
234
|
-
questionnaire.score_schemas.
|
230
|
+
questionnaire.score_schemas.values.map { |score|
|
235
231
|
{
|
236
232
|
key: score.key,
|
237
233
|
label: score.label,
|
@@ -242,16 +238,13 @@ module Quby
|
|
242
238
|
|
243
239
|
# { subkey: {..} }
|
244
240
|
def subscores_for(score)
|
245
|
-
score.subscore_schemas.
|
246
|
-
|
247
|
-
subscore.key,
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
only_for_export: subscore.only_for_export.presence
|
253
|
-
}.compact
|
254
|
-
]
|
241
|
+
score.subscore_schemas.map { |subscore|
|
242
|
+
{
|
243
|
+
key: subscore.key,
|
244
|
+
label: subscore.label,
|
245
|
+
export_key: subscore.export_key,
|
246
|
+
only_for_export: subscore.only_for_export.presence
|
247
|
+
}.compact
|
255
248
|
}
|
256
249
|
end
|
257
250
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quby-compiler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marten Veldthuis
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|