quby-compiler 0.5.0 → 0.5.2

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: c114222ce815660bdbff3a284c6893b8dc809760818d1839193fec984a1027e3
4
- data.tar.gz: 8b7938ae820807e963178a251313a3f6a237a3103e0d9aab92539eb5a534cd51
3
+ metadata.gz: ed4f85aa0af92e39a7cf5186bc39ebfa3a597a9727ddcf46baa2907795f9448a
4
+ data.tar.gz: aafc346743a54a8e1eab829e9be774d533b2a5cf505fc2aae38f7ba4d074a38b
5
5
  SHA512:
6
- metadata.gz: 65bba6e155ee6722e836054f584c8df708c1ef9e8a87d9cb560d8020c8c16b3dadfb17b59da4ec0df128f9236f4ff20a69705af6f456c11204f8195a3cb01c36
7
- data.tar.gz: b9f974a3ab3e6da317397726cad05b3913cc12f81b912ef928fcec50ed9b994196a7404e99f18754abcf4632fab19aad5656e354021ce3573d6735d1a42b1af5
6
+ metadata.gz: 03f01c088abb8bf0241061b05caef5c0278e3bdb8e1ac41fbda66bdd1cf04c7f21bf5d273c63ddce3931faa96375425496be7a945de4dbfa59eb80a34bcf266d
7
+ data.tar.gz: 9b6eba420a82a1b5f603b00dbe81b07d2ff37b086d3e50058f58dcd41ca763410b11be577b8e94c3645d843f532e0a694c18162dd174955e874ab6d2d6be3e5b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ # 0.5.2
2
+
3
+ * Fix custom_methods for ruby 3
4
+
5
+ # 0.5.1
6
+
7
+ * Support for ruby 3.2
8
+ * Switch from nokogumbo to nokogiri
9
+
1
10
  # 0.5.0
2
11
 
3
12
  * quby2.json BREAKING CHANGES!:
@@ -11,9 +11,9 @@ module Quby
11
11
  super
12
12
  end
13
13
 
14
- def method_missing(method_sym, *args, &block)
14
+ def method_missing(method_sym, *args, **kwargs, &block)
15
15
  if @custom_methods.key? method_sym
16
- instance_exec(*args, &custom_methods[method_sym])
16
+ instance_exec(*args, **kwargs, &custom_methods[method_sym])
17
17
  else
18
18
  super
19
19
  end
@@ -6,7 +6,6 @@ module Quby
6
6
  module Compiler
7
7
  module DSL
8
8
  class PanelBuilder < Base
9
- attr_reader :title
10
9
  attr_reader :questionnaire
11
10
 
12
11
  def initialize(title, default_question_options: {}, **options)
@@ -37,7 +36,7 @@ module Quby
37
36
  end
38
37
 
39
38
  def video(*urls, **options)
40
- video_html = video_tag *urls, **options
39
+ video_html = video_tag(*urls, **options)
41
40
  @panel.items << Entities::Text.new('', raw_content: video_html)
42
41
  end
43
42
 
@@ -66,9 +65,9 @@ module Quby
66
65
  table_builder.instance_eval(&block) if block
67
66
  end
68
67
 
69
- def method_missing(method_sym, *args, &block)
68
+ def method_missing(method_sym, *args, **kwargs, &block)
70
69
  if @custom_methods.key? method_sym
71
- instance_exec(*args, &@custom_methods[method_sym])
70
+ instance_exec(*args, **kwargs, &@custom_methods[method_sym])
72
71
  else
73
72
  super
74
73
  end
@@ -272,7 +272,7 @@ module Quby
272
272
  end
273
273
 
274
274
  def outcome_table(**table_options)
275
- @questionnaire.add_outcome_table table_options
275
+ @questionnaire.add_outcome_table(**table_options)
276
276
  end
277
277
 
278
278
  private
@@ -5,9 +5,6 @@ module Quby
5
5
  module DSL
6
6
  module Questions
7
7
  class Base < ::Quby::Compiler::DSL::Base
8
- attr_reader :key
9
- attr_reader :title
10
- attr_reader :type
11
8
  attr_reader :questionnaire
12
9
 
13
10
  def initialize(key, questionnaire:, **options)
@@ -49,10 +49,10 @@ module Quby
49
49
  attr_accessor :y_range_categories
50
50
 
51
51
  # @return [Symbol]
52
- attr_accessor :chart_type
52
+ attr_reader :chart_type
53
53
 
54
54
  # @return [Range]
55
- attr_accessor :y_range
55
+ attr_writer :y_range
56
56
 
57
57
  # @return [Float]
58
58
  attr_accessor :tick_interval
@@ -11,7 +11,7 @@ module Quby
11
11
  attr_accessor :y_label
12
12
 
13
13
  # @return [Symbol]
14
- attr_accessor :tonality
14
+ attr_reader :tonality
15
15
 
16
16
  # @return [Proc]
17
17
  attr_accessor :baseline
@@ -10,7 +10,7 @@ module Quby
10
10
  include ActiveSupport::Callbacks
11
11
  define_callbacks :after_dsl_enhance
12
12
 
13
- attr_accessor :presentation
13
+ attr_writer :presentation
14
14
  attr_accessor :switch_cycle
15
15
 
16
16
  # Raw content may contain a raw HTML replacement for this item
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'quby/compiler/entities'
4
-
5
3
  module Quby
6
4
  module Compiler
7
5
  module Entities
@@ -12,7 +12,7 @@ module Quby
12
12
 
13
13
  # Standard attributes
14
14
  attr_accessor :key
15
- validates :key, presence: true, 'quby/type': {is_a: Symbol}
15
+ validates :key, presence: true, 'quby/compiler/type': {is_a: Symbol}
16
16
  attr_accessor :sbg_key
17
17
  attr_accessor :questionnaire
18
18
  attr_accessor :title
@@ -50,10 +50,6 @@ module Quby
50
50
  attr_accessor :allow_blank_titles
51
51
  validates :allow_blank_titles, inclusion: {in: [true, false, nil], message: "must be boolean"}
52
52
 
53
- # Minimum and maximum values for float and integer types
54
- attr_accessor :minimum
55
- attr_accessor :maximum
56
-
57
53
  # Whether the browser should autocomplete this question (off by default)
58
54
  attr_accessor :autocomplete
59
55
 
@@ -119,7 +115,7 @@ module Quby
119
115
  attr_accessor :table
120
116
 
121
117
  # In case of being displayed inside a table, amount of columns/rows to span
122
- attr_accessor :col_span
118
+ attr_writer :col_span
123
119
  attr_accessor :row_span
124
120
 
125
121
  attr_accessor :default_invisible
@@ -127,7 +123,7 @@ module Quby
127
123
 
128
124
  # Slider only: where to place the sliding thing by default
129
125
  # Can have value :hidden for a hidden handle.
130
- attr_accessor :default_position
126
+ attr_writer :default_position
131
127
 
132
128
  ##########################################################
133
129
 
@@ -237,8 +233,8 @@ module Quby
237
233
  # rubocop:disable SymbolName
238
234
  super.merge(
239
235
  key: key,
240
- title: Quby::MarkdownParser.new(title).to_html,
241
- description: Quby::MarkdownParser.new(description).to_html,
236
+ title: Quby::Compiler::MarkdownParser.new(title).to_html,
237
+ description: Quby::Compiler::MarkdownParser.new(description).to_html,
242
238
  type: type,
243
239
  size: size.presence && Integer(size), # 2022-11: 4k string and 7k integer
244
240
  hidden: hidden?,
@@ -293,10 +289,12 @@ module Quby
293
289
  @default_position || ((minimum + maximum) / half if minimum && maximum)
294
290
  end
295
291
 
292
+ # Minimum value for float and integer types, set by validation
296
293
  def minimum
297
294
  validations.find { |i| i[:type] == :minimum }.try(:fetch, :value)
298
295
  end
299
296
 
297
+ # Maximum value for float and integer types, set by validation
300
298
  def maximum
301
299
  validations.find { |i| i[:type] == :maximum }.try(:fetch, :value)
302
300
  end
@@ -68,7 +68,7 @@ module Quby
68
68
  {
69
69
  type: 'html',
70
70
  key: SecureRandom.uuid,
71
- html: Quby::MarkdownParser.new(description).to_html
71
+ html: Quby::Compiler::MarkdownParser.new(description).to_html
72
72
  }
73
73
  end
74
74
 
@@ -79,7 +79,7 @@ module Quby
79
79
  value: value,
80
80
  description: question.type == :select \
81
81
  ? description
82
- : Quby::MarkdownParser.new(description).to_html,
82
+ : Quby::Compiler::MarkdownParser.new(description).to_html,
83
83
  questions: questions,
84
84
  hidesQuestions: hides_questions,
85
85
  showsQuestions: shows_questions,
@@ -61,7 +61,7 @@ module Quby
61
61
  attr_accessor :description
62
62
  attr_accessor :outcome_description
63
63
  attr_accessor :short_description
64
- attr_accessor :roqua_keys
64
+ attr_writer :roqua_keys
65
65
  attr_accessor :sbg_key # not required to be unique
66
66
  attr_accessor :sbg_domains
67
67
  attr_accessor :versions
@@ -71,11 +71,11 @@ module Quby
71
71
  attr_accessor :score_calculations
72
72
  attr_accessor :default_answer_value
73
73
  attr_accessor :renderer_version
74
- attr_accessor :leave_page_alert
74
+ attr_writer :leave_page_alert
75
75
  attr_reader :fields
76
76
  attr_accessor :extra_css
77
77
  attr_accessor :allow_switch_to_bulk
78
- attr_accessor :license
78
+ attr_reader :license
79
79
  attr_accessor :licensor
80
80
  attr_accessor :language
81
81
  attr_accessor :respondent_types
@@ -91,7 +91,7 @@ module Quby
91
91
  attr_accessor :validate_html
92
92
 
93
93
  attr_accessor :last_author
94
- attr_accessor :allow_hotkeys # allow hotkeys for :all views, just :bulk views (default), or :none for never
94
+ attr_writer :allow_hotkeys # allow hotkeys for :all views, just :bulk views (default), or :none for never
95
95
 
96
96
  attr_accessor :charts
97
97
 
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'quby/compiler/entities/item'
4
- require 'quby/markdown_parser'
5
4
 
6
5
  module Quby
7
6
  module Compiler
@@ -36,7 +35,7 @@ module Quby
36
35
  end
37
36
 
38
37
  def text
39
- @text ||= Quby::MarkdownParser.new(str).to_html
38
+ @text ||= Quby::Compiler::MarkdownParser.new(str).to_html
40
39
  end
41
40
 
42
41
  def key
@@ -4,7 +4,7 @@ require 'redcarpet'
4
4
 
5
5
  require 'quby/compiler/services/text_transformation'
6
6
 
7
- module Quby
7
+ module Quby::Compiler
8
8
  class MarkdownParser
9
9
  include Quby::Compiler::Services::TextTransformation
10
10
 
@@ -263,7 +263,7 @@ module Quby
263
263
  end
264
264
 
265
265
  def parse_markdown_and_strip_tags(markdown)
266
- strip_tags_without_html_encode(Quby::MarkdownParser.new(markdown).to_html)
266
+ strip_tags_without_html_encode(Quby::Compiler::MarkdownParser.new(markdown).to_html)
267
267
  end
268
268
 
269
269
  def strip_tags_without_html_encode(html)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require 'nokogumbo'
2
+ require 'nokogiri'
3
3
  require 'active_model'
4
4
  require 'quby/compiler/entities/questionnaire'
5
5
 
@@ -27,9 +27,9 @@ module Quby
27
27
  validate_raw_content_items(questionnaire) if questionnaire.validate_html
28
28
  # Some compilation errors are Exceptions (pure syntax errors) and some StandardErrors (NameErrors)
29
29
  rescue Exception => exception # rubocop:disable Lint/RescueException
30
- definition.errors.add(:sourcecode, {message: "Questionnaire error: #{definition.key}\n" \
31
- "#{exception.message}",
32
- backtrace: exception.backtrace[0..20]})
30
+ definition.errors.add(:sourcecode, message: "Questionnaire error: #{definition.key}\n" \
31
+ "#{exception.message}",
32
+ backtrace: exception.backtrace[0..20])
33
33
  end
34
34
 
35
35
  def validate_metadata(questionnaire)
@@ -294,12 +294,12 @@ module Quby
294
294
  end
295
295
 
296
296
  def strip_p_tag(text)
297
- text.gsub /^<p>(.*)<\/p>\n?$/, '\1'
297
+ text.gsub(/^<p>(.*)<\/p>\n?$/, '\1')
298
298
  end
299
299
 
300
300
  def strip_question_number_slashes(quests)
301
301
  quests.transform_values! do |value|
302
- value&.gsub /^(\s*\d+)\\/, '\1'
302
+ value&.gsub(/^(\s*\d+)\\/, '\1')
303
303
  end
304
304
  end
305
305
 
@@ -77,7 +77,7 @@ module Quby
77
77
  else
78
78
  patch
79
79
  end
80
- rescue Exception => e
80
+ rescue Exception
81
81
  puts "path: #{path}"
82
82
  raise
83
83
  end
@@ -1,7 +1,7 @@
1
1
  require 'active_model'
2
2
 
3
3
  # validates :key, 'quby/type': {is_a: Symbol}
4
- module Quby
4
+ module Quby::Compiler
5
5
  class TypeValidator < ActiveModel::EachValidator
6
6
  def validate_each(record, attribute, value)
7
7
  return if value.is_a? options[:is_a]
@@ -1,5 +1,5 @@
1
1
  module Quby
2
2
  module Compiler
3
- VERSION = "0.5.0"
3
+ VERSION = "0.5.2"
4
4
  end
5
5
  end
data/lib/quby/compiler.rb CHANGED
@@ -15,11 +15,9 @@ module Quby
15
15
  end
16
16
  end
17
17
 
18
- require 'quby/array_attribute_valid_validator'
19
- require 'quby/attribute_valid_validator'
20
- require 'quby/markdown_parser'
18
+ require 'quby/compiler/markdown_parser'
21
19
  require 'quby/range_categories'
22
- require 'quby/type_validator'
20
+ require 'quby/compiler/type_validator'
23
21
 
24
22
  require 'quby/compiler/instance'
25
23
  require 'quby/compiler/entities'
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.5.0
4
+ version: 0.5.2
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-24 00:00:00.000000000 Z
11
+ date: 2023-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -80,20 +80,6 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '1.8'
83
- - !ruby/object:Gem::Dependency
84
- name: nokogumbo
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :runtime
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: redcarpet
99
85
  requirement: !ruby/object:Gem::Requirement
@@ -156,8 +142,6 @@ files:
156
142
  - config/locales/rails-i18n/en.yml
157
143
  - config/locales/rails-i18n/nl.yml
158
144
  - exe/quby-compile
159
- - lib/quby/array_attribute_valid_validator.rb
160
- - lib/quby/attribute_valid_validator.rb
161
145
  - lib/quby/compiler.rb
162
146
  - lib/quby/compiler/dsl.rb
163
147
  - lib/quby/compiler/dsl/base.rb
@@ -224,6 +208,7 @@ files:
224
208
  - lib/quby/compiler/entities/version.rb
225
209
  - lib/quby/compiler/entities/visibility_rule.rb
226
210
  - lib/quby/compiler/instance.rb
211
+ - lib/quby/compiler/markdown_parser.rb
227
212
  - lib/quby/compiler/output.rb
228
213
  - lib/quby/compiler/outputs.rb
229
214
  - lib/quby/compiler/outputs/quby_frontend_v1_serializer.rb
@@ -234,12 +219,11 @@ files:
234
219
  - lib/quby/compiler/services/quby_proxy.rb
235
220
  - lib/quby/compiler/services/seed_diff.rb
236
221
  - lib/quby/compiler/services/text_transformation.rb
222
+ - lib/quby/compiler/type_validator.rb
237
223
  - lib/quby/compiler/version.rb
238
- - lib/quby/markdown_parser.rb
239
224
  - lib/quby/range_categories.rb
240
225
  - lib/quby/settings.rb
241
226
  - lib/quby/text_transformation.rb
242
- - lib/quby/type_validator.rb
243
227
  homepage: https://gitlab.roqua.nl/roqua/quby-compiler
244
228
  licenses:
245
229
  - MIT
@@ -260,7 +244,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
260
244
  - !ruby/object:Gem::Version
261
245
  version: '0'
262
246
  requirements: []
263
- rubygems_version: 3.3.22
247
+ rubygems_version: 3.4.6
264
248
  signing_key:
265
249
  specification_version: 4
266
250
  summary: Quby::Compiler compiles a DSL for questionnaires to JSON
@@ -1,15 +0,0 @@
1
- require 'active_model'
2
-
3
- module Quby
4
- class ArrayAttributeValidValidator < ActiveModel::EachValidator
5
- def validate_each(record, attribute, value)
6
- value&.each&.with_index do |element, index|
7
- if !element.respond_to?(:valid?)
8
- record.errors.add(attribute, "element ##{index} does not respond_to valid?")
9
- elsif !element.valid?
10
- record.errors.add(attribute, "element ##{index} #{element.errors.full_messages.join(', ')}")
11
- end
12
- end
13
- end
14
- end
15
- end
@@ -1,14 +0,0 @@
1
- require 'active_model'
2
-
3
- module Quby
4
- class AttributeValidValidator < ActiveModel::EachValidator
5
- def validate_each(record, attribute, value)
6
- return if value.blank?
7
- if value.respond_to?(:valid?)
8
- record.errors.add(attribute, value.errors.full_messages.join(', ')) unless value.valid?
9
- else
10
- record.errors.add(attribute, 'does not respond_to valid?')
11
- end
12
- end
13
- end
14
- end