quby-compiler 0.5.6 → 0.5.8

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
  SHA256:
3
- metadata.gz: 05f509c76c1f6c67029abdd77d29469b7a825708e86ea0d7d535e1ea05f4f57c
4
- data.tar.gz: 1b78d9c1fed73f4642f2e76d942ba5c5619f2bb354ff0024ff3a22d92b3c8aff
3
+ metadata.gz: 44068865d5a7d4dab6a76cf5d6b11bc8c6ce64be7f373e822e3e1ec30bbd1889
4
+ data.tar.gz: f0a6dc1e26bc3b212370054b1dbaad1af344b6833ea056b9c618b264b2a8e4f5
5
5
  SHA512:
6
- metadata.gz: 9c599463543dff5a691a135d97d374e858b9bf41f971d7bb61dea7448836bc36b3b179cf59dc4d9779a1e890a50d5c3b016fc15c63e634fde10a59ae1623ec41
7
- data.tar.gz: b1b8baa09ce07637d8b502421332be3c33bf1eee95d4d9845b5daae4235703cfdef89022858326e90f96dbc3fa8e5a9f91795f56bd58ef1fa6e4fdfe787cffb1
6
+ metadata.gz: 1d57ad082868f0f5e37dc1cf7094037d631dbc76232ec83400155ad07a05f6e4a37b569843750a973fa2543d134d5cbda63465775d0d64d912af1357c71ca56d
7
+ data.tar.gz: 3301d9eeca5a25a3186043c506b39beab4568d99f7945f0e646d29bdbd223e7813fd3479e6c3a215ef28e9ca36f0edb63a168b2abcdb5fe9600b15e21edd8e4f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # 0.5.8
2
+
3
+ * DefinitionValidator: Add uniqueness check over all question, flags, textvars and score keys.
4
+ * Moved flag description validation to definition_validator
5
+
6
+ # 0.5.7
7
+
8
+ * quby2.json
9
+ * Added showValues flag
10
+ * Added language
11
+ * removed outcomeDescription
12
+
1
13
  # 0.5.6
2
14
 
3
15
  * quby2.json:
@@ -19,21 +19,12 @@ module Quby
19
19
  # does not have an effect outside of the interface
20
20
  super(key, description_true, description_false, description, internal, trigger_on, shows_questions,
21
21
  hides_questions, Array.wrap(depends_on).map(&:to_s), default_in_interface)
22
- ensure_valid_descriptions
23
22
  end
24
23
  # rubocop:enable ParameterLists
25
24
 
26
25
  def if_triggered_by(answer_flags)
27
26
  yield if answer_flags[key] == trigger_on
28
27
  end
29
-
30
- private
31
-
32
- def ensure_valid_descriptions
33
- unless (description_false.present? && description_true.present?) || description.present?
34
- raise "Flag '#{key}' Requires at least either both description_true and description_false or a description"
35
- end
36
- end
37
28
  end
38
29
  end
39
30
  end
@@ -249,6 +249,7 @@ module Quby
249
249
  questionGroup: question_group
250
250
  ).tap do |json|
251
251
  json[:unit] = unit if %i[integer float string].include?(type) && as != :slider
252
+ json[:showValues] = [true, :all].include?(show_values) if %i[radio scale].include?(type) && show_values
252
253
  end
253
254
  end
254
255
 
@@ -14,8 +14,8 @@ module Quby
14
14
  {
15
15
  key: key,
16
16
  title: title,
17
+ language: language || "nl",
17
18
  description: description,
18
- outcomeDescription: outcome_description,
19
19
  shortDescription: short_description,
20
20
  defaultAnswerValue: Services::TransformQuby1ValuesIntoQuby2Values.run!(@questionnaire, default_answer_value),
21
21
  panels: panels,
@@ -21,6 +21,7 @@ module Quby
21
21
  validate_scores(questionnaire)
22
22
  validate_table_edgecases(questionnaire)
23
23
  validate_flags(questionnaire)
24
+ validate_key_uniqueness(questionnaire)
24
25
  validate_respondent_types(questionnaire)
25
26
  validate_outcome_tables(questionnaire)
26
27
  validate_markdown_fields(questionnaire) if questionnaire.validate_html
@@ -127,12 +128,19 @@ module Quby
127
128
 
128
129
  def validate_flags(questionnaire)
129
130
  questionnaire.flags.each_value do |flag|
131
+ ensure_valid_descriptions(questionnaire, flag)
130
132
  validate_flag_shows(questionnaire, flag)
131
133
  validate_flag_hides(questionnaire, flag)
132
134
  validate_flag_depends_on(questionnaire, flag)
133
135
  end
134
136
  end
135
137
 
138
+ def ensure_valid_descriptions(questionnaire, flag)
139
+ unless (flag.description_false.present? && flag.description_true.present?) || flag.description.present?
140
+ fail ArgumentError, "Flag '#{flag.key}' Requires at least either both description_true and description_false or a description"
141
+ end
142
+ end
143
+
136
144
  def validate_flag_shows(questionnaire, flag)
137
145
  unknown_questions = flag.shows_questions.select { |key| !questionnaire.key_in_use?(key) }
138
146
  return if unknown_questions.blank?
@@ -153,6 +161,18 @@ module Quby
153
161
  fail ArgumentError, "Flag #{flag.key} depends_on nonexistent flag '#{missing.to_sentence}'"
154
162
  end
155
163
 
164
+ def validate_key_uniqueness(questionnaire)
165
+ keys = questionnaire.fields.answer_keys.to_a \
166
+ + questionnaire.score_schemas.keys.map(&:to_sym) \
167
+ + questionnaire.flags.keys.map { delete_prefix(_1, questionnaire).to_sym } \
168
+ + questionnaire.textvars.keys.map { delete_prefix(_1, questionnaire).to_sym }
169
+
170
+ return if keys.size == keys.uniq.size
171
+
172
+ duplicates = keys.tally.filter_map { |k,v| k if v > 1 }
173
+ fail ArgumentError, "Duplicate keys: #{duplicates.to_sentence}"
174
+ end
175
+
156
176
  def validate_respondent_types(questionnaire)
157
177
  valid_respondent_types = Entities::Questionnaire::RESPONDENT_TYPES
158
178
 
@@ -339,6 +359,10 @@ scores_schema tables to the resulting seed."
339
359
 
340
360
  fail "#{key || html} contains invalid html: #{fragment.errors.map(&:to_s).join(', ')}."
341
361
  end
362
+
363
+ def delete_prefix(key, questionnaire)
364
+ key.delete_prefix("#{questionnaire.key}_")
365
+ end
342
366
  end
343
367
  end
344
368
  end
@@ -1,5 +1,5 @@
1
1
  module Quby
2
2
  module Compiler
3
- VERSION = "0.5.6"
3
+ VERSION = "0.5.8"
4
4
  end
5
5
  end
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.5.6
4
+ version: 0.5.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marten Veldthuis
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-10-06 00:00:00.000000000 Z
11
+ date: 2024-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -245,7 +245,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
245
245
  - !ruby/object:Gem::Version
246
246
  version: '0'
247
247
  requirements: []
248
- rubygems_version: 3.4.19
248
+ rubygems_version: 3.5.3
249
249
  signing_key:
250
250
  specification_version: 4
251
251
  summary: Quby::Compiler compiles a DSL for questionnaires to JSON