quby-compiler 0.5.22 → 0.5.23

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: 07f0d4268936ab1120ebb48d593645367e443a2b236f705de943599aa5e44847
4
- data.tar.gz: e7462e8862d04e7b54badb52f833371aa304d42798c28c5da5edb4fe3d2be5f3
3
+ metadata.gz: c6d745ba161d7dca63ed71bd68f0e0d3fcd22f217f730c1a06584bee9084d62c
4
+ data.tar.gz: 4ac2be2cd51b3f9ad5e91e2c16f0654ea3fc52263ab93da3416cf3afcca745c0
5
5
  SHA512:
6
- metadata.gz: f34d09ad62cbcf84a1749d014c651960409c0bde03a408be228f2940f7efb81c01c97bdeb7a82889d92c16aad637bdaf8cf7674a94bf513dd78454546ee15dc5
7
- data.tar.gz: 3743a39d0850ee252b3c9d6fa32ef8d89c6ee88e69ffd1a280f39d49af97c5635943b47fec4bce53b0ab9920d408a790e780cb09907691b779254d1957893a01
6
+ metadata.gz: 66cf125bda0986919c0d019d704cab0180eff8a075d0d16649eac654517df018585800d88629548bec29289a92d7f712c7c036680f8e64ea00f87de93a04bfea
7
+ data.tar.gz: 7e639345f39abf65ab07353751cbfddd7db6ecab328eed8feaf0bfa239ebb3b18e3d5e7961a4e42a46932d1090db00c60c4c41c9eaac1fec875cab5601a55ec2
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # 0.5.23
2
+
3
+ * Validate check_all_option and uncheck_all_option exists.
4
+ * Validate checkbox keys start with question key (disable with do_not_check_checkbox_options_start_with_question_key)
5
+
1
6
  # 0.5.22
2
7
 
3
8
  * quby2: Add questionKeys to panels, so we can validate completeness and make quby2 simpler.
@@ -0,0 +1,16 @@
1
+ merge(values(:v_1, :v_2), values(v_4).recode(1 => 3)).sum
2
+
3
+
4
+
5
+ divide(value(:v_2), multiply(value(:v_1), value(:v_1)))
6
+
7
+ w / l * l
8
+
9
+
10
+ sexp_variable :key1 do
11
+ foo = values(:v_1, :v_2)
12
+ bar = recode(foo, 1 => 3)
13
+ bla = merge(foo, bar)
14
+ sum(bla)
15
+
16
+ end
@@ -292,6 +292,10 @@ module Quby
292
292
  @questionnaire.add_outcome_table(**table_options)
293
293
  end
294
294
 
295
+ def do_not_check_checkbox_options_start_with_question_key
296
+ @questionnaire.check_checkbox_options_start_with_question_key = false
297
+ end
298
+
295
299
  private
296
300
 
297
301
  def default_panel_options
@@ -58,6 +58,7 @@ module Quby
58
58
  @versions = []
59
59
  @seeds_patch = {}
60
60
  @anonymous_conditions = Entities::AnonymousConditions.new
61
+ @check_checkbox_options_start_with_question_key = true
61
62
  end
62
63
 
63
64
  attr_accessor :key
@@ -110,6 +111,8 @@ module Quby
110
111
  attr_accessor :lookup_tables
111
112
  attr_accessor :anonymous_conditions
112
113
 
114
+ attr_accessor :check_checkbox_options_start_with_question_key
115
+
113
116
  delegate :question_hash, :input_keys, :answer_keys, :expand_input_keys, to: :fields
114
117
 
115
118
  def tags=(tags)
@@ -28,6 +28,7 @@ module Quby
28
28
  validate_raw_content_items(questionnaire) if questionnaire.validate_html
29
29
  validate_sexp_variables(questionnaire)
30
30
  validate_info_blocks(questionnaire)
31
+ validate_checkbox_options(questionnaire)
31
32
  # Some compilation errors are Exceptions (pure syntax errors) and some StandardErrors (NameErrors)
32
33
  rescue Exception => exception # rubocop:disable Lint/RescueException
33
34
  definition.errors.add(:sourcecode, message: "Questionnaire error: #{definition.key}\n" \
@@ -376,12 +377,46 @@ scores_schema tables to the resulting seed."
376
377
  def validate_sexp_variables(questionnaire)
377
378
  questionnaire.sexp_variables.each_value do |sexp_variable|
378
379
  sexp_variable.validate(questionnaire)
379
- end
380
+ end
380
381
  end
381
382
 
382
383
  def delete_prefix(key, questionnaire)
383
384
  key.delete_prefix("#{questionnaire.key}_")
384
385
  end
386
+
387
+ def validate_checkbox_options(questionnaire)
388
+ questionnaire.panels.each do |panel|
389
+ panel.items.each do |item|
390
+ return unless item.type == :check_box
391
+ validate_checkbox_options_are_assignable_to_question_key(item, questionnaire)
392
+ validate_check_all_question_exists(item)
393
+ end
394
+ end
395
+ end
396
+
397
+ def validate_checkbox_options_are_assignable_to_question_key(question, questionnaire)
398
+ return unless questionnaire.check_checkbox_options_start_with_question_key
399
+
400
+ question.options.each do |option|
401
+ next if option.key.to_s.start_with?(question.key.to_s)
402
+
403
+ fail "Question with key :#{question.key} has one or more invalid option keys: #{question.options.map(&:key)}"
404
+ end
405
+ end
406
+
407
+ def validate_check_all_question_exists(question)
408
+ return unless question.uncheck_all_option || question.check_all_option
409
+
410
+ option_keys = question.options.map(&:key)
411
+
412
+ if question.check_all_option && !option_keys.include?(question.check_all_option)
413
+ fail "check_all_option key :#{question.check_all_option} does not exist on question :#{question.key}"
414
+ end
415
+
416
+ if question.uncheck_all_option && !option_keys.include?(question.uncheck_all_option)
417
+ fail "uncheck_all_option key :#{question.uncheck_all_option} does not exist on question :#{question.key}"
418
+ end
419
+ end
385
420
  end
386
421
  end
387
422
  end
@@ -1,5 +1,5 @@
1
1
  module Quby
2
2
  module Compiler
3
- VERSION = "0.5.22"
3
+ VERSION = "0.5.23"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quby-compiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.22
4
+ version: 0.5.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marten Veldthuis
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-06-17 00:00:00.000000000 Z
10
+ date: 2025-06-24 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: activemodel
@@ -151,6 +151,7 @@ files:
151
151
  - lib/quby/compiler/dsl/charting/radar_chart_builder.rb
152
152
  - lib/quby/compiler/dsl/helpers.rb
153
153
  - lib/quby/compiler/dsl/info_block_builder.rb
154
+ - lib/quby/compiler/dsl/merge(values(:v_1, :v_2), values(v_4).rb
154
155
  - lib/quby/compiler/dsl/panel_builder.rb
155
156
  - lib/quby/compiler/dsl/question_builder.rb
156
157
  - lib/quby/compiler/dsl/questionnaire_builder.rb