quby-compiler 0.4.15 → 0.4.16
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 +4 -4
- data/CHANGELOG.md +17 -0
- data/lib/quby/compiler/entities/question_option.rb +23 -2
- data/lib/quby/compiler/entities/questions/checkbox_question.rb +1 -1
- data/lib/quby/compiler/entities/questions/radio_question.rb +1 -1
- data/lib/quby/compiler/entities/questions/select_question.rb +5 -1
- data/lib/quby/compiler/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b37ba70c10be5b93150a219396c5af20cac6c9b1ec2d18e0afa2acdd8c6f7b4
|
4
|
+
data.tar.gz: c0782d3d8cc1fb6dbdcd21e0613811e941254dbd68edfc10bbe71084cf3c872c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed384ce1f96bac8d3159d26111ad7ad96dc17471e849aaf495877482eb5f587d521c7698f053e7f3bcafc320417f6d164e756ac8b0ede495d33072bbf318d17d
|
7
|
+
data.tar.gz: cfbc1079c4a8603a16499c2b180ecc1c416d2d2338899aaf5839376cae32dffb42cfa0d2a38cc5e8b4ce570f55dfc38c657a2d8716dd1b4e8e255e9095f3f642
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,20 @@
|
|
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
|
+
|
1
18
|
# 0.4.15
|
2
19
|
|
3
20
|
* quby2.json: Question#size is now always an integer/nil
|
@@ -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
|
@@ -6,7 +6,11 @@ module Quby
|
|
6
6
|
module Questions
|
7
7
|
class SelectQuestion < Question
|
8
8
|
def as_json(options = {})
|
9
|
-
super.merge(
|
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
|
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.
|
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-11-
|
11
|
+
date: 2022-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|