quby-compiler 0.4.12 → 0.4.14

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: a9f80c06ecab5163ba31ba68e5548ec4e53211b4d327d738b07947578409afed
4
- data.tar.gz: a56fa925a142ec55eb909e33257c3f399d8990c79ace266e6ebc7687cefb49cc
3
+ metadata.gz: 864809e71abc58743617937e4cd9967afa23b80958a5c7fef3c7265d77404d08
4
+ data.tar.gz: b3abb8c5572b12ac98b0f8fb81258cbf621adc20c00f978d24f8251533c8279d
5
5
  SHA512:
6
- metadata.gz: 3aa823181f25722654444f7ad79e8922b59f6cb93463e12e61abef7ead8a391695156fcb4cb8f4551ad115b6a710ab2e5d81138575d7fce05d442db1e86dd809
7
- data.tar.gz: 89376384e57965c290e667984fd98605668ef2a832a87d78215e6c0435379bd6ce4b4cf994091bcc9975554fb05e7ed3f6bfbf4beab6af13115fb3489cd87a94
6
+ metadata.gz: dd7c67aa581503fcc3451d2a62e182e22c3bbb38f27f61c7347dd4a2a743e47b524c5b667acdf36293225da1807ad439a10ef172eede13da526de71c6dc319cb
7
+ data.tar.gz: eedc2ae95790da8039f2f1b56c2526b710db523fe4eff4d47345a405c907331146852e5c8d526a9343577d4aaf261fd8d0f3843afffa89b20208f51897e6287c
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ # 0.4.14
2
+
3
+ * DSL: Add `hide_pii_from_researchers` and `hide_values_from_professionals`
4
+ * roqua.json: Add anonymous_conditions
5
+
6
+ # 0.4.13
7
+
8
+ * quby2.json:
9
+ * string-questions: Don't pass a size of 30, when no size had been specified
10
+ * rename date type to date_parts, switch to use `date_parts: [{part: year, key: 'yyyy'}, ..]`
11
+
1
12
  # 0.4.12
2
13
 
3
14
  * roqua.json: Add questionnaire license
data/exe/quby-compile CHANGED
@@ -40,7 +40,7 @@ paths.each do |path|
40
40
  definition = Quby::Compiler.validate(key, sourcecode, lookup_tables: lookup_tables)
41
41
  if definition.errors.any?
42
42
  error = definition.errors[:sourcecode].first
43
- STDERR.puts error[:message], error[:backtrace], ''
43
+ STDERR.puts(error)
44
44
  validation_errors_found = true
45
45
  next # let's not create new output files for questionnaires with errors
46
46
  end
@@ -147,6 +147,14 @@ module Quby
147
147
  @questionnaire.default_answer_value = value
148
148
  end
149
149
 
150
+ def hide_pii_from_researchers(value)
151
+ @questionnaire.anonymous_conditions = @questionnaire.anonymous_conditions.new(hide_pii_from_researchers: value)
152
+ end
153
+
154
+ def hide_values_from_professionals(value)
155
+ @questionnaire.anonymous_conditions = @questionnaire.anonymous_conditions.new(hide_values_from_professionals: value)
156
+ end
157
+
150
158
  def panel(title = nil, options = {}, &block)
151
159
  panel = PanelBuilder.build(title, **options, **default_panel_options, &block)
152
160
  @questionnaire.add_panel(panel)
@@ -0,0 +1,23 @@
1
+ module Quby
2
+ module Compiler
3
+ module Entities
4
+ class AnonymousConditions < Dry::Struct
5
+ class ConstantRule < Dry::Struct
6
+ attribute :type, Types::String.constrained(eql: "constant")
7
+ attribute :value, Types::Bool
8
+ end
9
+
10
+ class BasedOnValueRule < Dry::Struct
11
+ attribute :type, Types::String.constrained(eql: "based_on_value")
12
+ attribute :question_key, Types::String
13
+ attribute :question_value, Types::String
14
+ end
15
+
16
+ Rule = ConstantRule | BasedOnValueRule
17
+
18
+ attribute? :hide_pii_from_researchers, Rule.optional
19
+ attribute? :hide_values_from_professionals, Rule.optional
20
+ end
21
+ end
22
+ end
23
+ end
@@ -53,6 +53,7 @@ module Quby
53
53
  @lookup_tables = {}
54
54
  @versions = []
55
55
  @seeds_patch = {}
56
+ @anonymous_conditions = Entities::AnonymousConditions.new
56
57
  end
57
58
 
58
59
  attr_accessor :key
@@ -100,6 +101,7 @@ module Quby
100
101
  attr_accessor :outcome_tables
101
102
  attr_accessor :score_schemas
102
103
  attr_accessor :lookup_tables
104
+ attr_accessor :anonymous_conditions
103
105
 
104
106
  delegate :question_hash, :input_keys, :answer_keys, :expand_input_keys, to: :fields
105
107
 
@@ -24,7 +24,8 @@ module Quby
24
24
  def initialize(key, options = {})
25
25
  super
26
26
 
27
- @components = options[:components] || DEFAULT_COMPONENTS
27
+ # only possible order we support.
28
+ @components = options[:components] ? POSSIBLE_COMPONENTS & options[:components] : DEFAULT_COMPONENTS
28
29
  @required_components = options[:required_components] || @components
29
30
  @optional_components = @components - @required_components
30
31
 
@@ -39,7 +40,8 @@ module Quby
39
40
  def add_date_validation(explanation)
40
41
  @validations << {type: :valid_date,
41
42
  subtype: :"valid_date_#{components.sort.join('_')}",
42
- explanation: explanation}
43
+ explanation: explanation,
44
+ requiredParts: required_components}
43
45
  end
44
46
 
45
47
  def claimed_keys
@@ -60,10 +62,16 @@ module Quby
60
62
  end
61
63
 
62
64
  def as_json(options = {})
63
- component_keys = components.each_with_object({}) do |component, hash|
64
- hash["#{component}Key"] = send("#{component}_key")
65
- end
66
- super.merge(components: components).merge(component_keys)
65
+ super.merge(
66
+ type: 'date_parts',
67
+ as: 'date_parts',
68
+ dateParts: components.map { |component|
69
+ {
70
+ part: component,
71
+ key: send("#{component}_key")
72
+ }
73
+ }
74
+ )
67
75
  end
68
76
  end
69
77
  end
@@ -6,7 +6,7 @@ module Quby
6
6
  module Questions
7
7
  class StringQuestion < Question
8
8
  def as_json(options = {})
9
- super.merge(autocomplete: @autocomplete, size: @size || 30)
9
+ super.merge(autocomplete: @autocomplete, size: @size)
10
10
  end
11
11
  end
12
12
  end
@@ -6,7 +6,7 @@ module Quby
6
6
  module Questions
7
7
  class TextQuestion < Question
8
8
  def as_json(options = {})
9
- super.merge(autocomplete: @autocomplete, lines: lines, cols: cols)
9
+ super.merge(autocomplete: @autocomplete, lines: lines)
10
10
  end
11
11
  end
12
12
  end
@@ -7,6 +7,7 @@ require 'quby/compiler/entities/version'
7
7
  require 'quby/compiler/entities/question_option'
8
8
  require 'quby/compiler/entities/item'
9
9
  require 'quby/compiler/entities/score_calculation'
10
+ require 'quby/compiler/entities/anonymous_conditions'
10
11
 
11
12
  require 'quby/compiler/entities/subscore_schema'
12
13
  require 'quby/compiler/entities/score_schema'
@@ -36,6 +36,7 @@ module Quby
36
36
  outcome_tables_schema: outcome_tables_schema,
37
37
  questions: questions,
38
38
  scores: scores,
39
+ anonymous_conditions: questionnaire.anonymous_conditions,
39
40
  license: questionnaire.license,
40
41
  licensor: questionnaire.licensor,
41
42
  }
@@ -271,6 +272,7 @@ module Quby
271
272
  end \
272
273
  .text
273
274
  .gsub(/\s+/, ' ')
275
+ .strip
274
276
  .presence
275
277
  end
276
278
  end
@@ -1,5 +1,5 @@
1
1
  module Quby
2
2
  module Compiler
3
- VERSION = "0.4.12"
3
+ VERSION = "0.4.14"
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.12
4
+ version: 0.4.14
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-08-08 00:00:00.000000000 Z
11
+ date: 2022-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -186,6 +186,7 @@ files:
186
186
  - lib/quby/compiler/dsl/standardized_panel_generators.rb
187
187
  - lib/quby/compiler/dsl/table_builder.rb
188
188
  - lib/quby/compiler/entities.rb
189
+ - lib/quby/compiler/entities/anonymous_conditions.rb
189
190
  - lib/quby/compiler/entities/charting/bar_chart.rb
190
191
  - lib/quby/compiler/entities/charting/chart.rb
191
192
  - lib/quby/compiler/entities/charting/charts.rb