quby-compiler 0.4.14 → 0.4.16

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: 864809e71abc58743617937e4cd9967afa23b80958a5c7fef3c7265d77404d08
4
- data.tar.gz: b3abb8c5572b12ac98b0f8fb81258cbf621adc20c00f978d24f8251533c8279d
3
+ metadata.gz: 1b37ba70c10be5b93150a219396c5af20cac6c9b1ec2d18e0afa2acdd8c6f7b4
4
+ data.tar.gz: c0782d3d8cc1fb6dbdcd21e0613811e941254dbd68edfc10bbe71084cf3c872c
5
5
  SHA512:
6
- metadata.gz: dd7c67aa581503fcc3451d2a62e182e22c3bbb38f27f61c7347dd4a2a743e47b524c5b667acdf36293225da1807ad439a10ef172eede13da526de71c6dc319cb
7
- data.tar.gz: eedc2ae95790da8039f2f1b56c2526b710db523fe4eff4d47345a405c907331146852e5c8d526a9343577d4aaf261fd8d0f3843afffa89b20208f51897e6287c
6
+ metadata.gz: ed384ce1f96bac8d3159d26111ad7ad96dc17471e849aaf495877482eb5f587d521c7698f053e7f3bcafc320417f6d164e756ac8b0ede495d33072bbf318d17d
7
+ data.tar.gz: cfbc1079c4a8603a16499c2b180ecc1c416d2d2338899aaf5839376cae32dffb42cfa0d2a38cc5e8b4ce570f55dfc38c657a2d8716dd1b4e8e255e9095f3f642
data/CHANGELOG.md CHANGED
@@ -1,3 +1,24 @@
1
+ # 0.5.0
2
+
3
+ * quby2.json BREAKING CHANGES!:
4
+ * Removed: Question#options
5
+ * Removed: Option#innerTitle and Option#placeholder
6
+ * Removed: Option#context_free_title
7
+
8
+ # 0.4.16
9
+
10
+ * quby2:
11
+ * Added children attribute to select questions to replace the options
12
+ * children can be of type option/html/placeholder
13
+ * Deprecate: Question#options
14
+ * Deprecate: Option#innerTitle moved to html type
15
+ * Deprecate: Option#placeholder moved to Question#placeholder attr
16
+ * Deprecate: Option#context_free_title, never needed
17
+
18
+ # 0.4.15
19
+
20
+ * quby2.json: Question#size is now always an integer/nil
21
+
1
22
  # 0.4.14
2
23
 
3
24
  * DSL: Add `hide_pii_from_researchers` and `hide_values_from_professionals`
@@ -240,7 +240,7 @@ module Quby
240
240
  title: Quby::MarkdownParser.new(title).to_html,
241
241
  description: Quby::MarkdownParser.new(description).to_html,
242
242
  type: type,
243
- size: size,
243
+ size: size.presence && Integer(size), # 2022-11: 4k string and 7k integer
244
244
  hidden: hidden?,
245
245
  displayModes: display_modes,
246
246
  defaultInvisible: default_invisible,
@@ -12,12 +12,14 @@ module Quby
12
12
  attr_reader :value
13
13
  attr_reader :description, :context_free_description
14
14
  attr_reader :questions
15
+ # for scale/radio/checbox questions, piece of of html that is rendered between the options
15
16
  attr_reader :inner_title
16
17
  validates :inner_title, inclusion: {in: [true, false, nil], message: "must be boolean"}
17
18
  attr_reader :hides_questions
18
19
  attr_reader :shows_questions
19
20
  attr_reader :hidden
20
21
  validates :hidden, inclusion: {in: [true, false], message: "must be boolean"}
22
+ # for select questions, option with no value and key is removed from answers if this one is selected.
21
23
  attr_reader :placeholder
22
24
  validates :placeholder, inclusion: {in: [true, false], message: "must be boolean"}
23
25
  attr_reader :question
@@ -53,7 +55,26 @@ module Quby
53
55
  end
54
56
 
55
57
  def as_json(options = {})
58
+ if inner_title
59
+ inner_title_as_json(options)
60
+ elsif placeholder
61
+ nil # placeholder attr on question.
62
+ else
63
+ option_as_json(options)
64
+ end
65
+ end
66
+
67
+ def inner_title_as_json(options = {})
68
+ {
69
+ type: 'html',
70
+ key: SecureRandom.uuid,
71
+ html: Quby::MarkdownParser.new(description).to_html
72
+ }
73
+ end
74
+
75
+ def option_as_json(options = {})
56
76
  {
77
+ type: 'option',
57
78
  key: key,
58
79
  value: value,
59
80
  description: question.type == :select \
@@ -63,11 +84,11 @@ module Quby
63
84
  ? context_free_description
64
85
  : Quby::MarkdownParser.new(context_free_description).to_html,
65
86
  questions: questions,
66
- innerTitle: inner_title,
87
+ innerTitle: inner_title, # deprecated, removed in 0.5.0
67
88
  hidesQuestions: hides_questions,
68
89
  showsQuestions: shows_questions,
69
90
  hidden: hidden,
70
- placeholder: placeholder,
91
+ placeholder: placeholder, # deprecated, removed in 0.5.0
71
92
  viewId: view_id
72
93
  }
73
94
  end
@@ -67,7 +67,7 @@ module Quby
67
67
  end
68
68
 
69
69
  def as_json(options = {})
70
- super.merge(options: @options.as_json)
70
+ super.merge(children: @options.as_json, options: @options.map(&:option_as_json))
71
71
  end
72
72
  end
73
73
  end
@@ -6,7 +6,7 @@ module Quby
6
6
  module Questions
7
7
  class RadioQuestion < Question
8
8
  def as_json(options = {})
9
- super.merge(options: @options.as_json)
9
+ super.merge(children: @options.as_json, options: @options.map(&:option_as_json))
10
10
  end
11
11
  end
12
12
  end
@@ -6,7 +6,11 @@ module Quby
6
6
  module Questions
7
7
  class SelectQuestion < Question
8
8
  def as_json(options = {})
9
- super.merge(options: @options.as_json)
9
+ super.merge(
10
+ children: @options.as_json.compact, # for now just options, but we'll add optgroups later.
11
+ options: @options.map(&:option_as_json), # deprecated, removed in 0.5
12
+ placeholder: @options.find { _1.placeholder }&.description # nil for no placeholder
13
+ )
10
14
  end
11
15
  end
12
16
  end
@@ -1,5 +1,5 @@
1
1
  module Quby
2
2
  module Compiler
3
- VERSION = "0.4.14"
3
+ VERSION = "0.4.16"
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.4.14
4
+ version: 0.4.16
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-09-21 00:00:00.000000000 Z
11
+ date: 2022-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -260,7 +260,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
260
260
  - !ruby/object:Gem::Version
261
261
  version: '0'
262
262
  requirements: []
263
- rubygems_version: 3.1.4
263
+ rubygems_version: 3.3.22
264
264
  signing_key:
265
265
  specification_version: 4
266
266
  summary: Quby::Compiler compiles a DSL for questionnaires to JSON