quby-compiler 0.5.7 → 0.5.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/quby/compiler/entities/flag.rb +0 -9
- data/lib/quby/compiler/entities/questionnaire.rb +1 -0
- data/lib/quby/compiler/services/definition_validator.rb +24 -0
- data/lib/quby/compiler/services/transform_quby1_values_into_quby2_values.rb +2 -0
- data/lib/quby/compiler/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 392bac29f2cc7b4b00ce1344f010b39941148e96e5e529d6487f8e0d49a5a5fe
|
4
|
+
data.tar.gz: 7c0538c6243f30481c3f282bfc2892874494454b64f5eb0013b0a0a4aa56e0c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8360a9fd3ec70b80766ece8d51bbbc301067ae7eb8c441515c06dc8c8003205527290c10b1249948deb5b4fab798a1e61ba56e03594f1e5188f5a43d3fbffa9f
|
7
|
+
data.tar.gz: 16b077a6db915f93dd30f6c6bb8f411c5c21e8cd2adc3ba279abbc11596a34598bd3e80dbea4527b431e7f1719f5eecb78c39f1c1252011c7d71a2332b576331
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
# 0.5.9
|
2
|
+
|
3
|
+
* added `require 'ostruct'` since running quby-compile suddenly fails on this.
|
4
|
+
|
5
|
+
# 0.5.8
|
6
|
+
|
7
|
+
* DefinitionValidator: Add uniqueness check over all question, flags, textvars and score keys.
|
8
|
+
* Moved flag description validation to definition_validator
|
9
|
+
|
1
10
|
# 0.5.7
|
2
11
|
|
3
12
|
* 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
|
@@ -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
|
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.
|
4
|
+
version: 0.5.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marten Veldthuis
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-04-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.
|
248
|
+
rubygems_version: 3.5.7
|
249
249
|
signing_key:
|
250
250
|
specification_version: 4
|
251
251
|
summary: Quby::Compiler compiles a DSL for questionnaires to JSON
|