quby-compiler 0.3.7 → 0.4.3

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: 9afe2a68ca9334f324a6d096918e625d432016b631794fdfe1db307acd25ebff
4
- data.tar.gz: 87cce57c50f1509b48ef072d53dfa4f56a8880b3dc82c002dbd9c6b70a368c7b
3
+ metadata.gz: 51cced2ed60f5bf58986b0bb1359a06e20349ee41f8313a86fd8abe7743b942f
4
+ data.tar.gz: 63dfc7514011d1a0518a5a5fd5dec191dd326104dab042eba491bb3b71380ff8
5
5
  SHA512:
6
- metadata.gz: 32acc8cd41565840352dc2c5b3137aca5f31422ee000424dd0b412d9ae9cadde00ff7d1eb5b92eb54b6b4ee493bd581413aee3c93fd01c2fd176fc57d7ec2e3b
7
- data.tar.gz: 6f677f3ea56d37009e637298d58d1969761fa6793c412b42dc8068ca99bb47a185427d31beae7e29b60236ea724929e911ebafca78db2e0a2755babf9b1956bd
6
+ metadata.gz: 0cef3595b41bdeb1eb0cd4ced9b903fc63441359a98a12b2999bdfda66daa2b705c07316cf6eaf16912e64a20098296348b838565eb89c6f15b42bab659fbdee
7
+ data.tar.gz: a5ad54369e5bf53e516d2f03665309d0e3e530b3acd488be9cad1eb4d1bcab0cebb6e3d23274c5d3bbfba225475e8970aa24fc776eee1b5206049428dd8c1d0d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,20 @@
1
+ # 0.4.3
2
+
3
+ * roqua.json: add scores hash.
4
+
5
+ # 0.4.2
6
+
7
+ * quby2: Added labels to slider questions.
8
+
9
+ # 0.4.1
10
+
11
+ * seeds: Fix depends: :present rule being overridden.
12
+
13
+ # 0.4.0
14
+
15
+ * rename flag visibilty rule value to trigger_on
16
+ * Don't parse select option descriptions as markdown.
17
+
1
18
  # 0.3.7
2
19
 
3
20
  * Remove last_update
@@ -89,7 +89,7 @@ module Quby
89
89
  end
90
90
 
91
91
  def as_json
92
- question_hash
92
+ question_hash.as_json
93
93
  end
94
94
 
95
95
  private
@@ -231,7 +231,6 @@ module Quby
231
231
  title: Quby::MarkdownParser.new(title).to_html,
232
232
  description: Quby::MarkdownParser.new(description).to_html,
233
233
  type: type,
234
- unit: unit,
235
234
  size: size,
236
235
  hidden: hidden?,
237
236
  displayModes: display_modes,
@@ -243,7 +242,10 @@ module Quby
243
242
  presentation: presentation,
244
243
  as: as,
245
244
  questionGroup: question_group
246
- )
245
+ ).tap do |json|
246
+ json[:unit] = unit if %i[integer float string].include?(type) && as != :slider
247
+ json[:labels] = labels if as == :slider
248
+ end
247
249
  end
248
250
 
249
251
  # Returns all keys belonging to html inputs generated by this question.
@@ -57,8 +57,12 @@ module Quby
57
57
  {
58
58
  key: key,
59
59
  value: value,
60
- description: Quby::MarkdownParser.new(description).to_html,
61
- context_free_description: Quby::MarkdownParser.new(context_free_description).to_html,
60
+ description: question.type == :select \
61
+ ? description
62
+ : Quby::MarkdownParser.new(description).to_html,
63
+ context_free_description: question.type == :select \
64
+ ? context_free_description
65
+ : Quby::MarkdownParser.new(context_free_description).to_html,
62
66
  questions: questions,
63
67
  innerTitle: inner_title,
64
68
  hidesQuestions: hides_questions,
@@ -193,7 +193,7 @@ module Quby
193
193
  outcomeDescription: outcome_description,
194
194
  shortDescription: short_description,
195
195
  panels: panels,
196
- fields: fields,
196
+ fields: fields.as_json,
197
197
  flags: flags,
198
198
  textvars: textvars,
199
199
  validations: validations,
@@ -39,7 +39,7 @@ module Quby
39
39
  end
40
40
 
41
41
  def self.from_flag(flag)
42
- condition = { type: "flag_equal", flag_key: flag.key, value: flag.trigger_on }
42
+ condition = { type: "flag_equal", flag_key: flag.key, trigger_on: flag.trigger_on }
43
43
 
44
44
  [].tap do |rules|
45
45
  flag.shows_questions.each do |question_key|
@@ -22,6 +22,7 @@ module Quby
22
22
  tags: questionnaire.tags.to_h.keys,
23
23
  charts: charts,
24
24
  outcome_tables_schema: outcome_tables_schema,
25
+ scores: scores,
25
26
  }
26
27
  end
27
28
 
@@ -139,7 +140,33 @@ module Quby
139
140
  tables: tables,
140
141
  }
141
142
  end
143
+
144
+ # [{ key: { .., subscores: { subkey: {..} } } }]
145
+ def scores
146
+ questionnaire.score_schemas.transform_values { |score|
147
+ {
148
+ key: score.key,
149
+ label: score.label,
150
+ subscores: subscores_for(score)
151
+ }
152
+ }
153
+ end
154
+
155
+ # { subkey: {..} }
156
+ def subscores_for(score)
157
+ score.subscore_schemas.to_h { |subscore|
158
+ [
159
+ subscore.key,
160
+ {
161
+ key: subscore.key,
162
+ label: subscore.label,
163
+ export_key: subscore.export_key,
164
+ only_for_export: subscore.only_for_export.presence
165
+ }.compact
166
+ ]
167
+ }
168
+ end
142
169
  end
143
170
  end
144
171
  end
145
- end
172
+ end
@@ -30,9 +30,6 @@ module Quby
30
30
  @hidden_questions = {} # hash containing questions hidden by other questions
31
31
 
32
32
  for question in questions_flat
33
- if question.hidden && question.type != :check_box
34
- d_qtypes[question.key.to_s] = { depends: :present } unless options[:without_depends]
35
- end
36
33
  unless question.hidden && (question.type == :check_box || question.type == :hidden)
37
34
  vars << question.key.to_s
38
35
  end
@@ -184,6 +181,9 @@ module Quby
184
181
  if hidden = @hidden_questions[question.key.to_s]
185
182
  d_qtypes[question.key.to_s][:depends] ||= hidden unless options[:without_depends]
186
183
  end
184
+ if question.hidden && question.type != :check_box
185
+ d_qtypes[question.key.to_s][:depends] = :present unless options[:without_depends]
186
+ end
187
187
  end
188
188
 
189
189
  def generate_question_titles
@@ -1,5 +1,5 @@
1
1
  module Quby
2
2
  module Compiler
3
- VERSION = "0.3.7"
3
+ VERSION = "0.4.3"
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.3.7
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marten Veldthuis
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-11-11 00:00:00.000000000 Z
11
+ date: 2021-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -144,21 +144,10 @@ executables:
144
144
  extensions: []
145
145
  extra_rdoc_files: []
146
146
  files:
147
- - ".gitignore"
148
- - ".gitlab-ci.yml"
149
- - ".rspec"
150
- - ".ruby-version"
151
147
  - CHANGELOG.md
152
- - CODE_OF_CONDUCT.md
153
- - Dockerfile
154
- - Gemfile
155
- - Gemfile.lock
156
148
  - LICENSE.txt
157
149
  - README.md
158
150
  - Rakefile
159
- - bin/console
160
- - bin/rspec
161
- - bin/setup
162
151
  - config/locales/de.yml
163
152
  - config/locales/en.yml
164
153
  - config/locales/nl.yml
@@ -167,7 +156,6 @@ files:
167
156
  - config/locales/rails-i18n/en.yml
168
157
  - config/locales/rails-i18n/nl.yml
169
158
  - exe/quby-compile
170
- - lib/quby/.DS_Store
171
159
  - lib/quby/array_attribute_valid_validator.rb
172
160
  - lib/quby/attribute_valid_validator.rb
173
161
  - lib/quby/compiler.rb
@@ -250,7 +238,6 @@ files:
250
238
  - lib/quby/settings.rb
251
239
  - lib/quby/text_transformation.rb
252
240
  - lib/quby/type_validator.rb
253
- - quby-compiler.gemspec
254
241
  homepage: https://gitlab.roqua.nl/roqua/quby-compiler
255
242
  licenses:
256
243
  - MIT
@@ -271,7 +258,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
271
258
  - !ruby/object:Gem::Version
272
259
  version: '0'
273
260
  requirements: []
274
- rubygems_version: 3.2.15
261
+ rubygems_version: 3.1.4
275
262
  signing_key:
276
263
  specification_version: 4
277
264
  summary: Quby::Compiler compiles a DSL for questionnaires to JSON
data/.gitignore DELETED
@@ -1,13 +0,0 @@
1
- .DS_Store
2
- /.bundle/
3
- /.yardoc
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
- /output/
11
-
12
- # rspec failure tracking
13
- .rspec_status
data/.gitlab-ci.yml DELETED
@@ -1,5 +0,0 @@
1
- test:
2
- image: docker
3
- script:
4
- - docker build . --tag quby-compiler-$CI_COMMIT_SHA
5
- - docker run quby-compiler-$CI_COMMIT_SHA bundle exec rspec
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 2.7.2
data/CODE_OF_CONDUCT.md DELETED
@@ -1,74 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- In the interest of fostering an open and welcoming environment, we as
6
- contributors and maintainers pledge to making participation in our project and
7
- our community a harassment-free experience for everyone, regardless of age, body
8
- size, disability, ethnicity, gender identity and expression, level of experience,
9
- nationality, personal appearance, race, religion, or sexual identity and
10
- orientation.
11
-
12
- ## Our Standards
13
-
14
- Examples of behavior that contributes to creating a positive environment
15
- include:
16
-
17
- * Using welcoming and inclusive language
18
- * Being respectful of differing viewpoints and experiences
19
- * Gracefully accepting constructive criticism
20
- * Focusing on what is best for the community
21
- * Showing empathy towards other community members
22
-
23
- Examples of unacceptable behavior by participants include:
24
-
25
- * The use of sexualized language or imagery and unwelcome sexual attention or
26
- advances
27
- * Trolling, insulting/derogatory comments, and personal or political attacks
28
- * Public or private harassment
29
- * Publishing others' private information, such as a physical or electronic
30
- address, without explicit permission
31
- * Other conduct which could reasonably be considered inappropriate in a
32
- professional setting
33
-
34
- ## Our Responsibilities
35
-
36
- Project maintainers are responsible for clarifying the standards of acceptable
37
- behavior and are expected to take appropriate and fair corrective action in
38
- response to any instances of unacceptable behavior.
39
-
40
- Project maintainers have the right and responsibility to remove, edit, or
41
- reject comments, commits, code, wiki edits, issues, and other contributions
42
- that are not aligned to this Code of Conduct, or to ban temporarily or
43
- permanently any contributor for other behaviors that they deem inappropriate,
44
- threatening, offensive, or harmful.
45
-
46
- ## Scope
47
-
48
- This Code of Conduct applies both within project spaces and in public spaces
49
- when an individual is representing the project or its community. Examples of
50
- representing a project or community include using an official project e-mail
51
- address, posting via an official social media account, or acting as an appointed
52
- representative at an online or offline event. Representation of a project may be
53
- further defined and clarified by project maintainers.
54
-
55
- ## Enforcement
56
-
57
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
- reported by contacting the project team at marten@veldthuis.com. All
59
- complaints will be reviewed and investigated and will result in a response that
60
- is deemed necessary and appropriate to the circumstances. The project team is
61
- obligated to maintain confidentiality with regard to the reporter of an incident.
62
- Further details of specific enforcement policies may be posted separately.
63
-
64
- Project maintainers who do not follow or enforce the Code of Conduct in good
65
- faith may face temporary or permanent repercussions as determined by other
66
- members of the project's leadership.
67
-
68
- ## Attribution
69
-
70
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
- available at [https://contributor-covenant.org/version/1/4][version]
72
-
73
- [homepage]: https://contributor-covenant.org
74
- [version]: https://contributor-covenant.org/version/1/4/
data/Dockerfile DELETED
@@ -1,11 +0,0 @@
1
- FROM ruby:2.7-alpine
2
-
3
- RUN apk update && apk add docker git g++ make
4
-
5
- RUN gem update --system
6
- RUN gem install bundler
7
-
8
- WORKDIR /app
9
-
10
- ADD . /app
11
- RUN bundle install
data/Gemfile DELETED
@@ -1,8 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in quby-compiler.gemspec
4
- gemspec
5
-
6
- gem "rake", "~> 12.0"
7
- gem "rspec", "~> 3.0"
8
- gem 'pry'
data/Gemfile.lock DELETED
@@ -1,130 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- quby-compiler (0.3.7)
5
- actionview (>= 5.0)
6
- activemodel (>= 5.0)
7
- activesupport (>= 5.0)
8
- dry-struct (>= 1.3.0)
9
- method_source
10
- nokogiri (>= 1.8)
11
- nokogumbo
12
- redcarpet (~> 3.5)
13
- roqua-support
14
-
15
- GEM
16
- remote: https://rubygems.org/
17
- specs:
18
- actionview (6.1.4)
19
- activesupport (= 6.1.4)
20
- builder (~> 3.1)
21
- erubi (~> 1.4)
22
- rails-dom-testing (~> 2.0)
23
- rails-html-sanitizer (~> 1.1, >= 1.2.0)
24
- active_interaction (4.0.6)
25
- activemodel (>= 5, < 7)
26
- activesupport (>= 5, < 7)
27
- activemodel (6.1.4)
28
- activesupport (= 6.1.4)
29
- activerecord (6.1.4)
30
- activemodel (= 6.1.4)
31
- activesupport (= 6.1.4)
32
- activesupport (6.1.4)
33
- concurrent-ruby (~> 1.0, >= 1.0.2)
34
- i18n (>= 1.6, < 2)
35
- minitest (>= 5.1)
36
- tzinfo (~> 2.0)
37
- zeitwerk (~> 2.3)
38
- appsignal (3.0.15)
39
- rack
40
- builder (3.2.4)
41
- coderay (1.1.3)
42
- concurrent-ruby (1.1.9)
43
- crass (1.0.6)
44
- diff-lcs (1.4.4)
45
- dry-configurable (0.13.0)
46
- concurrent-ruby (~> 1.0)
47
- dry-core (~> 0.6)
48
- dry-container (0.9.0)
49
- concurrent-ruby (~> 1.0)
50
- dry-configurable (~> 0.13, >= 0.13.0)
51
- dry-core (0.7.1)
52
- concurrent-ruby (~> 1.0)
53
- dry-inflector (0.2.1)
54
- dry-logic (1.2.0)
55
- concurrent-ruby (~> 1.0)
56
- dry-core (~> 0.5, >= 0.5)
57
- dry-struct (1.4.0)
58
- dry-core (~> 0.5, >= 0.5)
59
- dry-types (~> 1.5)
60
- ice_nine (~> 0.11)
61
- dry-types (1.5.1)
62
- concurrent-ruby (~> 1.0)
63
- dry-container (~> 0.3)
64
- dry-core (~> 0.5, >= 0.5)
65
- dry-inflector (~> 0.1, >= 0.1.2)
66
- dry-logic (~> 1.0, >= 1.0.2)
67
- erubi (1.10.0)
68
- i18n (1.8.10)
69
- concurrent-ruby (~> 1.0)
70
- ice_nine (0.11.2)
71
- loofah (2.12.0)
72
- crass (~> 1.0.2)
73
- nokogiri (>= 1.5.9)
74
- method_source (1.0.0)
75
- mini_portile2 (2.6.1)
76
- minitest (5.14.4)
77
- naught (1.1.0)
78
- nokogiri (1.12.5)
79
- mini_portile2 (~> 2.6.1)
80
- racc (~> 1.4)
81
- nokogumbo (2.0.5)
82
- nokogiri (~> 1.8, >= 1.8.4)
83
- pry (0.13.1)
84
- coderay (~> 1.1)
85
- method_source (~> 1.0)
86
- racc (1.6.0)
87
- rack (2.2.3)
88
- rails-dom-testing (2.0.3)
89
- activesupport (>= 4.2.0)
90
- nokogiri (>= 1.6)
91
- rails-html-sanitizer (1.4.2)
92
- loofah (~> 2.3)
93
- rake (12.3.3)
94
- redcarpet (3.5.1)
95
- roqua-support (0.4.1)
96
- active_interaction (>= 3.0, < 5.0)
97
- activesupport (>= 5.2, < 6.2)
98
- appsignal (>= 2.9, < 3.1)
99
- naught (~> 1.0)
100
- with_advisory_lock (~> 3.2)
101
- rspec (3.9.0)
102
- rspec-core (~> 3.9.0)
103
- rspec-expectations (~> 3.9.0)
104
- rspec-mocks (~> 3.9.0)
105
- rspec-core (3.9.3)
106
- rspec-support (~> 3.9.3)
107
- rspec-expectations (3.9.2)
108
- diff-lcs (>= 1.2.0, < 2.0)
109
- rspec-support (~> 3.9.0)
110
- rspec-mocks (3.9.1)
111
- diff-lcs (>= 1.2.0, < 2.0)
112
- rspec-support (~> 3.9.0)
113
- rspec-support (3.9.3)
114
- tzinfo (2.0.4)
115
- concurrent-ruby (~> 1.0)
116
- with_advisory_lock (3.2.0)
117
- activerecord (>= 3.2)
118
- zeitwerk (2.5.1)
119
-
120
- PLATFORMS
121
- ruby
122
-
123
- DEPENDENCIES
124
- pry
125
- quby-compiler!
126
- rake (~> 12.0)
127
- rspec (~> 3.0)
128
-
129
- BUNDLED WITH
130
- 2.2.15
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "quby/compiler"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
data/bin/rspec DELETED
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- #
5
- # This file was generated by Bundler.
6
- #
7
- # The application 'rspec' is installed as part of a gem, and
8
- # this file is here to facilitate running it.
9
- #
10
-
11
- require "pathname"
12
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
- Pathname.new(__FILE__).realpath)
14
-
15
- bundle_binstub = File.expand_path("../bundle", __FILE__)
16
-
17
- if File.file?(bundle_binstub)
18
- if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
- load(bundle_binstub)
20
- else
21
- abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
- Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
- end
24
- end
25
-
26
- require "rubygems"
27
- require "bundler/setup"
28
-
29
- load Gem.bin_path("rspec-core", "rspec")
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
data/lib/quby/.DS_Store DELETED
Binary file
@@ -1,39 +0,0 @@
1
- require_relative 'lib/quby/compiler/version'
2
-
3
- Gem::Specification.new do |spec|
4
- spec.name = "quby-compiler"
5
- spec.version = Quby::Compiler::VERSION
6
- spec.authors = ["Marten Veldthuis"]
7
- spec.email = ["marten@veldthuis.com"]
8
-
9
- spec.summary = %q{Quby::Compiler compiles a DSL for questionnaires to JSON}
10
- #spec.description = %q{TODO: Write a longer description or delete this line.}
11
- spec.homepage = "https://gitlab.roqua.nl/roqua/quby-compiler"
12
- spec.license = "MIT"
13
- spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
14
-
15
- #spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
16
-
17
- spec.metadata["homepage_uri"] = spec.homepage
18
- #spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
19
- #spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
20
-
21
- # Specify which files should be added to the gem when it is released.
22
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
24
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
- end
26
- spec.bindir = "exe"
27
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
- spec.require_paths = ["lib"]
29
-
30
- spec.add_dependency "activemodel", ">= 5.0"
31
- spec.add_dependency "actionview", ">= 5.0"
32
- spec.add_dependency "activesupport", ">= 5.0"
33
- spec.add_dependency 'dry-struct', '>= 1.3.0'
34
- spec.add_dependency 'nokogiri', '>= 1.8'
35
- spec.add_dependency 'nokogumbo'
36
- spec.add_dependency "redcarpet", '~> 3.5'
37
- spec.add_dependency "method_source"
38
- spec.add_dependency "roqua-support"
39
- end