quby-compiler 0.6.1 → 0.6.3

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: 204fe4926804a88d4ba8889a7dc644cf0e6e526f4f0535b066e78cc47fb1dee3
4
- data.tar.gz: 0fc9f69f7305608de6b1349c3b283da728bea6037689c8d4272012ec56cc23e7
3
+ metadata.gz: f0db7cde28558a1299251282f5fa19fef2fd8ab3528b70779930d962737f96c8
4
+ data.tar.gz: 74e0a2075d664b251160e2ed98ecb937185ecbcafea38ba23a777422d30d6496
5
5
  SHA512:
6
- metadata.gz: 24e4d191808d82cd3185d7aa645579af39906b38d02c3bfef736a1d42b49c867086f9a7ac23c6275e7b8918655997edd7b1b1b5b5b3b6d91f47e2e9f89c984a6
7
- data.tar.gz: 0f888b7293af6f9e5a7dc35fc935c8008af5c61682756a78c8e00fcfa07e19c7de0148ea85971f36b3879f29f5ea3a5a65f8033dcca1f448a0c0a9c0fb772cd4
6
+ metadata.gz: e9fa3343bd33f58bad878747e0d690966dec5e4b6c50b4be6b928c46642c0c1eb2515ba1b012fe06d24c7ff3b4ccf5f043b7a425e82841dd2866713cfb26cb9e
7
+ data.tar.gz: 3449a3124f17da8e64f45b3b941d9768d1d4011360078a25ea9694647732aa2d4aa94f2786f1a6dfd81ae3a6745eaca3cd8f63af67ebb0d43d1f2a3c2178f664
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ # 0.6.3
2
+
3
+ * dsl + quby2.json: Add subtype to info_blocks.
4
+
5
+ # 0.6.2
6
+
7
+ * dsl:
8
+ * Add text option to info_blocks, so you can start with the key.
9
+ * Allow label for placeholder option.
10
+ * quby2.json
11
+ * Use . between panel/info_block key and default key for items, for more consistency. Remove double panel key for items with default key.
12
+ * Don't camelcase translation keys for quby2, no real benefit and was wrongly camelcasing html keys.
13
+
1
14
  # 0.6.1
2
15
 
3
16
  * Switch to oj for serializing, since JSON.serialize is dumb as ^%#$& (not serializing inner object)
@@ -11,8 +11,8 @@ module Quby
11
11
  delegate :panel, to: :info_block
12
12
  delegate :questionnaire, to: :panel
13
13
 
14
- def initialize(key, start_open: true, panel:, default_question_options:, custom_methods:)
15
- @info_block = Entities::InfoBlock.new(key: , panel:, start_open:)
14
+ def initialize(key, panel:, default_question_options:, custom_methods:, **options)
15
+ @info_block = Entities::InfoBlock.new(key: , panel:, **options)
16
16
  @default_question_options = default_question_options
17
17
  @custom_methods = custom_methods
18
18
  check_key_uniqueness(key, questionnaire:)
@@ -29,6 +29,10 @@ module Quby
29
29
  info_block.items << Entities::Text.new('', html_content: value.to_s, key:)
30
30
  end
31
31
 
32
+ def text(key:, html: nil, md: nil, **options)
33
+ info_block.items << Entities::Text.new(key:, md:, html_content: html, **options)
34
+ end
35
+
32
36
  def question(key, **options, &block)
33
37
  options = default_question_options.merge(options).merge(questionnaire:)
34
38
 
@@ -53,7 +57,7 @@ module Quby
53
57
  def fallback_key
54
58
  raise "Item without key in #{info_block.key}" if questionnaire.translatable?
55
59
 
56
- "#{info_block.key}_item_#{info_block.items.size}"
60
+ "#{info_block.key}.item_#{info_block.items.size}"
57
61
  end
58
62
  end
59
63
  end
@@ -95,7 +95,7 @@ module Quby
95
95
  def fallback_key
96
96
  raise "Item without key in #{@panel.key}" if @questionnaire.translatable?
97
97
 
98
- "#{@panel.key}_item_#{@panel.items.size}"
98
+ "#{@panel.key}.item_#{@panel.items.size}"
99
99
  end
100
100
  end
101
101
  end
@@ -2,16 +2,18 @@ module Quby
2
2
  module Compiler
3
3
  module Entities
4
4
  class InfoBlock < Item
5
- attr_reader :key, :items, :start_open, :panel
5
+ attr_reader :key, :items, :start_open, :subtype, :panel
6
6
  attr_accessor :html
7
7
 
8
8
  validates :key, presence: true, 'quby/compiler/type': {is_a: Symbol}
9
9
  validates :html, presence: true
10
+ validates :subtype, presence: true, inclusion: {in: ["info", "question-bar"]}
10
11
 
11
- def initialize(key:, panel:, start_open: true)
12
+ def initialize(key:, panel:, start_open: true, subtype: "info")
12
13
  @panel = panel
13
14
  @key = key
14
15
  @start_open = start_open
16
+ @subtype = subtype
15
17
  @items = []
16
18
  end
17
19
 
@@ -31,7 +31,7 @@ module Quby
31
31
  items.flat_map { |item|
32
32
  case item
33
33
  when Quby::Compiler::Entities::Text
34
- { "#{panel.key}.#{item.key}" => item.html }
34
+ { "#{item.key}" => item.html }
35
35
  when Quby::Compiler::Entities::Question
36
36
  questions_for_question(item).flat_map { |question|
37
37
  question_locale_values(question, panel:)
@@ -97,6 +97,7 @@ module Quby
97
97
  def info_block_item(info_block)
98
98
  {
99
99
  type: 'info',
100
+ subtype: info_block.subtype,
100
101
  key: info_block.key,
101
102
  html: handle_html(info_block.html, type: :prose, v1_markdown: false),
102
103
  startOpen: info_block.start_open,
@@ -178,10 +179,11 @@ module Quby
178
179
  end
179
180
 
180
181
  def select_question(question)
182
+ placeholder = question.all_options.find(&:placeholder)
181
183
  {
182
184
  **base_question(question),
183
185
  children: children(question),
184
- placeholder: question.all_options.find { _1.placeholder }&.description,
186
+ placeholder: placeholder&.label || placeholder&.description,
185
187
  }.compact
186
188
  end
187
189
 
@@ -330,8 +332,7 @@ module Quby
330
332
  key.ends_with?("context_free_title") \
331
333
  || key.ends_with?("context_free_description") \
332
334
  || key == "short_description"
333
- } \
334
- .transform_keys! { |k| k.to_s.split('.').tap{ _1[-1] = _1[-1].camelize(:lower) }.join('.') }
335
+ }
335
336
  }
336
337
  end
337
338
 
@@ -1,5 +1,5 @@
1
1
  module Quby
2
2
  module Compiler
3
- VERSION = "0.6.1"
3
+ VERSION = "0.6.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quby-compiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marten Veldthuis