quby-compiler 0.5.25 → 0.5.26

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: 88d7b643df83366f5d577296c9d157aa6862a1f67f859e04031bef70bc43a40d
4
- data.tar.gz: 7e7dcd545a28bbf2089d1d024a4670fb4b6e661d992f4e2fde8aed059440a1da
3
+ metadata.gz: eb03f5addb141e1e202837e24ca40e98f9e9c8e2560eccfbdd3685dbe88d2f4a
4
+ data.tar.gz: 4d5b0f40b267fc8e2b538edcb0e7af777fb63df221aa982f8fb8a8f2c334491f
5
5
  SHA512:
6
- metadata.gz: d13f171ab6f4c2ef3944435b3a9b2974e4d872341128d2d6d461ee9502331086cf30a7b4b9b65d9efa194e34d8facb6489db686e06c0ad2d70fc07a4d4825bdc
7
- data.tar.gz: 263f34523e7de734570fb375c1887dc77d4ed307574087cef3d8debf455a3f0c01e45f9a359314502efcb34640c453f4de02a809bbe5b4c0d0c16ac3a60b6d01
6
+ metadata.gz: bdc2a846329dd4f32cbbdaf6b29eac0112d02777c1105773321c864addef32158005b1660ad6012ae83ccfeea0d5e5e18c730b6737b911a432d5f9ca768f0c10
7
+ data.tar.gz: be50d806c0711d615bf3dc2de53d1646253e945345c73f984e8111b4cf0af2edc93dca50ecaa5157e9fdd8d3c011b8efee00a7018c5d2587f9b291ab99c1b0ee
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # 0.5.26
2
+
3
+ * Quby2: Allow img tags
4
+ * Added numeric_compare visibility rule to questions
5
+
1
6
  # 0.5.25
2
7
 
3
8
  * Give info block a type in ruby (new validator expects it)
@@ -83,6 +83,36 @@ module Quby
83
83
  end
84
84
  end
85
85
 
86
+ module CompareVisibilityRule
87
+ def compare_value(op:, value:, show_questions: [], hide_questions: [])
88
+ raise "unknown op #{op} for #{@question.key}" unless %i[gt gteq lt lteq eq].include?(op)
89
+ condition = {
90
+ type: 'numeric_compare',
91
+ field_key: @question.key,
92
+ op:,
93
+ value:
94
+ }
95
+ show_questions.each do |show_key|
96
+ @question.visibility_rules << Entities::VisibilityRule.new(
97
+ condition:,
98
+ action: {
99
+ type: 'show_question',
100
+ field_key: show_key
101
+ }
102
+ )
103
+ end
104
+ hide_questions.each do |hide_key|
105
+ @question.visibility_rules << Entities::VisibilityRule.new(
106
+ condition:,
107
+ action: {
108
+ type: 'hide_question',
109
+ field_key: hide_key
110
+ }
111
+ )
112
+ end
113
+ end
114
+ end
115
+
86
116
  module Labeling
87
117
  def label(value)
88
118
  @question.labels << value
@@ -9,6 +9,7 @@ module Quby
9
9
  include Labeling
10
10
  include Units
11
11
  include Sizes
12
+ include CompareVisibilityRule
12
13
 
13
14
  def initialize(key, **options, &block)
14
15
  super
@@ -9,6 +9,7 @@ module Quby
9
9
  include Labeling
10
10
  include Units
11
11
  include Sizes
12
+ include CompareVisibilityRule
12
13
 
13
14
  def initialize(key, **options, &block)
14
15
  super
@@ -8,6 +8,7 @@ module Quby
8
8
  include MultipleChoice
9
9
  include Subquestions
10
10
  include InnerTitles
11
+ include CompareVisibilityRule
11
12
 
12
13
  def initialize(key, **options, &block)
13
14
  super
@@ -6,6 +6,7 @@ module Quby
6
6
  module Questions
7
7
  class SelectQuestionBuilder < Base
8
8
  include MultipleChoice
9
+ include CompareVisibilityRule
9
10
 
10
11
  def initialize(key, **options, &block)
11
12
  super
@@ -69,6 +69,7 @@ module Quby
69
69
 
70
70
  # Structuring
71
71
  attr_accessor :validations
72
+ attr_reader :visibility_rules # Quby2 only
72
73
  attr_accessor :dependencies
73
74
 
74
75
  # To display unit for number items
@@ -150,6 +151,7 @@ module Quby
150
151
  @display_modes = options[:display_modes]
151
152
  @presentation = options[:presentation]
152
153
  @validations = []
154
+ @visibility_rules = []
153
155
  @parent = options[:parent]
154
156
  @hidden = options[:hidden]
155
157
  @table = options[:table]
@@ -4,6 +4,8 @@ module Quby
4
4
  class VisibilityRule
5
5
  def self.from(question)
6
6
  [].tap do |rules|
7
+ rules.concat question.visibility_rules
8
+
7
9
  # Transform "default invisible" into just being hidden by itself,
8
10
  # since any other question showing it will take precedence anyway.
9
11
  if question.default_invisible
@@ -331,11 +331,11 @@ module Quby
331
331
  if layout_version == :v2
332
332
  case type
333
333
  when :simple
334
- html_sanitizer.sanitize(html, tags: %w[strong em sup sub br span], attributes: %w[class])
334
+ html_sanitizer.sanitize(html, tags: %w[strong em sup sub br span img], attributes: %w[class src alt width height])
335
335
  when :question_description
336
- html_sanitizer.sanitize(html, tags: %w[strong em b i u sup sub pre blockquote p span br ul ol li a], attributes: %w[class])
336
+ html_sanitizer.sanitize(html, tags: %w[strong em b i u sup sub pre blockquote p span br ul ol li a img], attributes: %w[class href target src alt width height])
337
337
  when :prose
338
- html_sanitizer.sanitize(html, tags: %w[strong em b i u sup sub pre blockquote p span br ul ol li a h1 h2 h3 h4 hr], attributes: %w[href class target])
338
+ html_sanitizer.sanitize(html, tags: %w[strong em b i u sup sub pre blockquote p span br ul ol li a img h1 h2 h3 h4 hr], attributes: %w[href class target src alt width height])
339
339
  end
340
340
  elsif v1_markdown
341
341
  Quby::Compiler::MarkdownParser.new(html).to_html
@@ -1,5 +1,5 @@
1
1
  module Quby
2
2
  module Compiler
3
- VERSION = "0.5.25"
3
+ VERSION = "0.5.26"
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.25
4
+ version: 0.5.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marten Veldthuis
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-07-07 00:00:00.000000000 Z
10
+ date: 2025-07-29 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: activemodel