quby 4.0.2 → 5.0.0.pre4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.markdown +0 -1
- data/lib/quby.rb +2 -10
- data/lib/quby/answers/entities/answer.rb +4 -2
- data/lib/quby/answers/services/outcome_calculation.rb +1 -2
- data/lib/quby/answers/services/score_calculator.rb +1 -3
- data/lib/quby/engine.rb +0 -1
- data/lib/quby/questionnaires.rb +1 -0
- data/lib/quby/questionnaires/api.rb +5 -1
- data/lib/quby/questionnaires/deserializer.rb +439 -0
- data/lib/quby/questionnaires/dsl.rb +12 -15
- data/lib/quby/questionnaires/entities.rb +1 -0
- data/lib/quby/questionnaires/entities/charting/line_chart.rb +23 -0
- data/lib/quby/questionnaires/entities/charting/overview_chart.rb +3 -1
- data/lib/quby/questionnaires/entities/definition.rb +3 -5
- data/lib/quby/questionnaires/entities/fields.rb +0 -15
- data/lib/quby/questionnaires/entities/question.rb +9 -32
- data/lib/quby/questionnaires/entities/questionnaire.rb +4 -15
- data/lib/quby/questionnaires/entities/questions/checkbox_question.rb +0 -24
- data/lib/quby/questionnaires/entities/questions/date_question.rb +0 -8
- data/lib/quby/questionnaires/entities/score_calculation.rb +36 -3
- data/lib/quby/questionnaires/repos.rb +1 -0
- data/lib/quby/questionnaires/repos/bundle_disk_repo.rb +51 -0
- data/lib/quby/table_backend/range_tree.rb +0 -51
- data/lib/quby/version.rb +1 -1
- data/spec/features/tables_spec.rb +40 -0
- data/spec/internal/log/test-events.log +531 -0
- data/spec/internal/log/test.log +21098 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-22-10-22-54.041.html +207 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-22-10-22-54.041.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-22-10-23-23.175.html +323 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-22-10-23-23.175.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-22-10-23-32.352.html +323 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-22-10-23-32.352.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-22-10-23-35.247.html +323 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-22-10-23-35.247.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-22-10-23-38.152.html +323 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-22-10-23-38.152.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-22-10-23-41.012.html +323 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-22-10-23-41.012.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-22-10-23-43.918.html +323 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-22-10-23-43.918.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-22-10-23-46.782.html +323 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-22-10-23-46.782.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-22-10-23-49.678.html +323 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-22-10-23-49.678.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-22-10-23-52.495.html +323 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-22-10-23-52.495.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-14-25-21.063.html +207 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-14-25-21.063.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-21-57.510.html +1 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-21-57.510.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-23-56.006.html +1 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-23-56.006.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-24-43.842.html +12 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-24-43.842.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-25-04.631.html +12 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-25-04.631.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-25-11.690.html +12 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-25-11.690.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-26-25.111.html +12 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-26-25.111.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-26-57.026.html +12 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-26-57.026.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-27-13.545.html +12 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-27-13.545.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-27-45.475.html +12 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-27-45.475.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-32-13.907.html +1 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-32-13.907.png +0 -0
- data/spec/quby/answers/services/answer_validations_spec.rb +8 -8
- data/spec/quby/answers/services/score_calculator_spec.rb +4 -14
- data/spec/quby/questionnaires/deserializer/questionnaire_spec.rb +237 -0
- data/spec/quby/questionnaires/dsl_spec.rb +0 -9
- data/spec/quby/questionnaires/entities/fields_spec.rb +3 -3
- data/spec/quby/questionnaires/entities/question_spec.rb +0 -8
- data/spec/quby/questionnaires/entities/questionnaire_spec.rb +2 -26
- data/spec/quby/table_backend/range_tree_spec.rb +46 -13
- data/spec/spec_helper.rb +1 -1
- metadata +108 -55
- data/lib/quby/lookup_table.rb +0 -29
- data/lib/quby/lookup_table_repo.rb +0 -24
- data/lib/quby/questionnaires/dsl/base.rb +0 -20
- data/lib/quby/questionnaires/dsl/calls_custom_methods.rb +0 -29
- data/lib/quby/questionnaires/dsl/charting/bar_chart_builder.rb +0 -18
- data/lib/quby/questionnaires/dsl/charting/chart_builder.rb +0 -91
- data/lib/quby/questionnaires/dsl/charting/line_chart_builder.rb +0 -47
- data/lib/quby/questionnaires/dsl/charting/overview_chart_builder.rb +0 -31
- data/lib/quby/questionnaires/dsl/charting/radar_chart_builder.rb +0 -18
- data/lib/quby/questionnaires/dsl/helpers.rb +0 -51
- data/lib/quby/questionnaires/dsl/panel_builder.rb +0 -80
- data/lib/quby/questionnaires/dsl/question_builder.rb +0 -40
- data/lib/quby/questionnaires/dsl/questionnaire_builder.rb +0 -252
- data/lib/quby/questionnaires/dsl/questions/base.rb +0 -179
- data/lib/quby/questionnaires/dsl/questions/checkbox_question_builder.rb +0 -20
- data/lib/quby/questionnaires/dsl/questions/date_question_builder.rb +0 -18
- data/lib/quby/questionnaires/dsl/questions/deprecated_question_builder.rb +0 -18
- data/lib/quby/questionnaires/dsl/questions/float_question_builder.rb +0 -21
- data/lib/quby/questionnaires/dsl/questions/integer_question_builder.rb +0 -21
- data/lib/quby/questionnaires/dsl/questions/radio_question_builder.rb +0 -20
- data/lib/quby/questionnaires/dsl/questions/select_question_builder.rb +0 -18
- data/lib/quby/questionnaires/dsl/questions/string_question_builder.rb +0 -20
- data/lib/quby/questionnaires/dsl/questions/text_question_builder.rb +0 -22
- data/lib/quby/questionnaires/dsl/score_builder.rb +0 -22
- data/lib/quby/questionnaires/dsl/standardized_panel_generators.rb +0 -33
- data/lib/quby/questionnaires/dsl/table_builder.rb +0 -48
- data/lib/quby/questionnaires/services/definition_validator.rb +0 -298
- data/spec/benchmarks/load_normscore_csv.rb +0 -18
- data/spec/quby/lookup_table_repo_spec.rb +0 -20
- data/spec/quby/lookup_table_spec.rb +0 -38
- data/spec/quby/questionnaires/dsl/calls_custom_methods_spec.rb +0 -38
- data/spec/quby/questionnaires/dsl/charting/bar_chart_builder_spec.rb +0 -41
- data/spec/quby/questionnaires/dsl/charting/chart_builder_spec.rb +0 -127
- data/spec/quby/questionnaires/dsl/charting/line_chart_builder_spec.rb +0 -58
- data/spec/quby/questionnaires/dsl/charting/radar_chart_builder_spec.rb +0 -41
- data/spec/quby/questionnaires/dsl/helpers_spec.rb +0 -80
- data/spec/quby/questionnaires/dsl/questionnaire_builder_spec.rb +0 -480
- data/spec/quby/questionnaires/services/definition_validator_spec.rb +0 -793
- data/spec/support/examples_for_chart_builders.rb +0 -59
data/lib/quby/lookup_table.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'quby/table_backend/range_tree'
|
4
|
-
|
5
|
-
module Quby
|
6
|
-
class LookupTable
|
7
|
-
attr_accessor :key
|
8
|
-
|
9
|
-
def initialize(key)
|
10
|
-
@key = key
|
11
|
-
end
|
12
|
-
|
13
|
-
def backing
|
14
|
-
return @backing if @backing.present?
|
15
|
-
all_data = data
|
16
|
-
headers = all_data.shift
|
17
|
-
compare = all_data.shift
|
18
|
-
@backing = Quby::TableBackend::RangeTree.from_csv(levels: headers, compare: compare, data: all_data)
|
19
|
-
end
|
20
|
-
|
21
|
-
def lookup(parameters)
|
22
|
-
backing.lookup(parameters)
|
23
|
-
end
|
24
|
-
|
25
|
-
def data
|
26
|
-
Quby.lookup_table_repo.retrieve(key)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'pathname'
|
2
|
-
require 'csv'
|
3
|
-
|
4
|
-
module Quby
|
5
|
-
module LookupTableRepo
|
6
|
-
def self.validate_key(key)
|
7
|
-
raise 'invalid key' unless key =~ /\A[a-z][a-z_0-9]{1,50}\z/
|
8
|
-
end
|
9
|
-
|
10
|
-
class Disk
|
11
|
-
attr_reader :disk_table_root
|
12
|
-
|
13
|
-
def initialize(disk_table_root)
|
14
|
-
@disk_table_root = Pathname.new(disk_table_root)
|
15
|
-
end
|
16
|
-
|
17
|
-
def retrieve(key)
|
18
|
-
Quby::LookupTableRepo.validate_key(key)
|
19
|
-
path = disk_table_root.join(key + '.csv')
|
20
|
-
CSV.read(path, col_sep: ';', skip_blanks: true)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'quby/questionnaires/dsl/helpers'
|
4
|
-
require 'quby/questionnaires/dsl/calls_custom_methods'
|
5
|
-
|
6
|
-
module Quby
|
7
|
-
module Questionnaires
|
8
|
-
module DSL
|
9
|
-
class Base
|
10
|
-
include Helpers
|
11
|
-
|
12
|
-
def self.build(*args, &block)
|
13
|
-
builder = new(*args)
|
14
|
-
builder.instance_eval(&block) if block
|
15
|
-
builder.build
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Quby
|
4
|
-
module Questionnaires
|
5
|
-
module DSL
|
6
|
-
module CallsCustomMethods
|
7
|
-
attr_reader :custom_methods
|
8
|
-
|
9
|
-
def initialize(*args)
|
10
|
-
options = args.last.is_a?(::Hash) ? args.last : {}
|
11
|
-
@custom_methods = options[:custom_methods] || {}
|
12
|
-
super
|
13
|
-
end
|
14
|
-
|
15
|
-
def method_missing(method_sym, *args, &block)
|
16
|
-
if @custom_methods.key? method_sym
|
17
|
-
instance_exec(*args, &custom_methods[method_sym])
|
18
|
-
else
|
19
|
-
super
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def respond_to_missing?(method_name, include_private = false)
|
24
|
-
custom_methods.key?(method_name) || super
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'quby/questionnaires/entities/charting/bar_chart'
|
4
|
-
require_relative 'chart_builder'
|
5
|
-
|
6
|
-
module Quby
|
7
|
-
module Questionnaires
|
8
|
-
module DSL
|
9
|
-
class BarChartBuilder < ChartBuilder
|
10
|
-
set_chart_class(Entities::Charting::BarChart)
|
11
|
-
|
12
|
-
def plotline(value, color)
|
13
|
-
@chart.plotlines << {value: value, color: color, width: 1, zIndex: 3}
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,91 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'quby/questionnaires/entities'
|
4
|
-
|
5
|
-
module Quby
|
6
|
-
module Questionnaires
|
7
|
-
module DSL
|
8
|
-
class ChartBuilder
|
9
|
-
# rubocop:disable AccessorMethodName
|
10
|
-
def self.set_chart_class(chart_class)
|
11
|
-
@chart_class = chart_class
|
12
|
-
end
|
13
|
-
# rubocop:enable AccessorMethodName
|
14
|
-
|
15
|
-
def self.chart_class
|
16
|
-
@chart_class
|
17
|
-
end
|
18
|
-
|
19
|
-
def initialize(questionnaire, key, options = {})
|
20
|
-
@chart = self.class.chart_class.new(key, options)
|
21
|
-
@questionnaire = questionnaire
|
22
|
-
end
|
23
|
-
|
24
|
-
def title(title)
|
25
|
-
@chart.title = title
|
26
|
-
end
|
27
|
-
|
28
|
-
def range(range)
|
29
|
-
@chart.y_range = range
|
30
|
-
end
|
31
|
-
|
32
|
-
def tick_interval(tick_interval)
|
33
|
-
@chart.tick_interval = tick_interval
|
34
|
-
end
|
35
|
-
|
36
|
-
def y_categories(y_categories)
|
37
|
-
@chart.y_categories = y_categories
|
38
|
-
end
|
39
|
-
|
40
|
-
def y_range_categories(*y_range_categories)
|
41
|
-
@chart.y_range_categories = RangeCategories.new(*y_range_categories).as_range_hash
|
42
|
-
end
|
43
|
-
|
44
|
-
def plotband(from, to, color)
|
45
|
-
@chart.plotbands << {from: from, to: to, color: color}
|
46
|
-
end
|
47
|
-
|
48
|
-
def plot(key, options = {})
|
49
|
-
unless plottable = @questionnaire.find_plottable(key)
|
50
|
-
fail "Questionnaire #{@questionnaire.key} chart #{@chart.key} references unknown score or question #{key}"
|
51
|
-
end
|
52
|
-
|
53
|
-
configure_options plottable, options
|
54
|
-
|
55
|
-
@chart.plottables << Entities::Charting::Plottable.new(plottable.key, options)
|
56
|
-
end
|
57
|
-
|
58
|
-
def chart_type(type)
|
59
|
-
@chart.chart_type = type
|
60
|
-
end
|
61
|
-
|
62
|
-
def build(&block)
|
63
|
-
instance_eval(&block)
|
64
|
-
validate!
|
65
|
-
@chart
|
66
|
-
end
|
67
|
-
|
68
|
-
def validate!
|
69
|
-
if @chart.y_categories.present? && @chart.y_range.present? &&
|
70
|
-
@chart.y_range != (0..(@chart.y_categories.count - 1))
|
71
|
-
fail ArgumentError, 'Y_categories size and range do not match'
|
72
|
-
end
|
73
|
-
|
74
|
-
true
|
75
|
-
end
|
76
|
-
|
77
|
-
private
|
78
|
-
|
79
|
-
def configure_options(plottable, options)
|
80
|
-
case plottable
|
81
|
-
when Entities::ScoreCalculation
|
82
|
-
options.reverse_merge! plottable.options
|
83
|
-
when Entities::Question
|
84
|
-
options[:label] ||= plottable.title
|
85
|
-
end
|
86
|
-
options[:questionnaire_key] = @questionnaire.key
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'quby/questionnaires/entities/charting/line_chart'
|
4
|
-
require_relative 'chart_builder'
|
5
|
-
|
6
|
-
module Quby
|
7
|
-
module Questionnaires
|
8
|
-
module DSL
|
9
|
-
class LineChartBuilder < ChartBuilder
|
10
|
-
set_chart_class(Entities::Charting::LineChart)
|
11
|
-
|
12
|
-
def y_axis_label(label)
|
13
|
-
@chart.y_label = label
|
14
|
-
end
|
15
|
-
|
16
|
-
def tonality(value)
|
17
|
-
@chart.tonality = value
|
18
|
-
end
|
19
|
-
|
20
|
-
def baseline(value = nil, &block)
|
21
|
-
unless value.nil? ^ block.nil?
|
22
|
-
fail ArgumentError, "Must give either value or a block"
|
23
|
-
end
|
24
|
-
|
25
|
-
if value
|
26
|
-
@chart.baseline = ->(age, gender) { value }
|
27
|
-
end
|
28
|
-
|
29
|
-
if block
|
30
|
-
if block.arity != 2
|
31
|
-
fail ArgumentError, "Given block must take two arguments"
|
32
|
-
end
|
33
|
-
@chart.baseline = block
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def clinically_relevant_change(value)
|
38
|
-
@chart.clinically_relevant_change = value
|
39
|
-
end
|
40
|
-
|
41
|
-
def validate!
|
42
|
-
fail "Chart #{@chart.key} has no range specified" unless @chart.y_range
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'quby/questionnaires/entities/charting/overview_chart'
|
2
|
-
require_relative 'chart_builder'
|
3
|
-
|
4
|
-
module Quby
|
5
|
-
module Questionnaires
|
6
|
-
module DSL
|
7
|
-
class OverviewChartBuilder < ChartBuilder
|
8
|
-
set_chart_class(Entities::Charting::OverviewChart)
|
9
|
-
|
10
|
-
def initialize(questionnaire, options = {})
|
11
|
-
@questionnaire = questionnaire
|
12
|
-
@chart = self.class.chart_class.new
|
13
|
-
end
|
14
|
-
|
15
|
-
def subscore(key)
|
16
|
-
@chart.subscore = key
|
17
|
-
end
|
18
|
-
|
19
|
-
def y_max(value)
|
20
|
-
@chart.y_max = value
|
21
|
-
end
|
22
|
-
|
23
|
-
def validate!
|
24
|
-
fail ArgumentError, "subscore not specified" unless @chart.subscore.present?
|
25
|
-
fail ArgumentError, "y_max not specified" unless @chart.y_max.present?
|
26
|
-
true
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'quby/questionnaires/entities/charting/radar_chart'
|
4
|
-
require_relative 'chart_builder'
|
5
|
-
|
6
|
-
module Quby
|
7
|
-
module Questionnaires
|
8
|
-
module DSL
|
9
|
-
class RadarChartBuilder < ChartBuilder
|
10
|
-
set_chart_class(Entities::Charting::RadarChart)
|
11
|
-
|
12
|
-
def plotline(value, color)
|
13
|
-
@chart.plotlines << {value: value, color: color, width: 1, zIndex: 3}
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Quby
|
4
|
-
module Questionnaires
|
5
|
-
module DSL
|
6
|
-
module Helpers
|
7
|
-
def image_tag(*args)
|
8
|
-
options = args.extract_options!
|
9
|
-
|
10
|
-
ActionController::Base.helpers.image_tag(
|
11
|
-
*args, options.reverse_merge(alt: image_alt(args.first))
|
12
|
-
)
|
13
|
-
end
|
14
|
-
|
15
|
-
# Copied from ActionController::Base.helpers.image_alt, because it will be removed from Rails 6.0, but we want
|
16
|
-
# to keep using this functionality
|
17
|
-
def image_alt(source)
|
18
|
-
File.basename(source, ".*").sub(/-[[:xdigit:]]{32,64}\z/, "").tr("-_", " ").capitalize
|
19
|
-
end
|
20
|
-
|
21
|
-
def check_question_keys_uniqueness(key, options, questionnaire)
|
22
|
-
keys = QuestionBuilder.build(key, options).claimed_keys
|
23
|
-
if keys.any? { |k| questionnaire.key_in_use? k }
|
24
|
-
fail "#{questionnaire.key}:#{key}: A question or option with input key #{key} is already defined."
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def video_tag(*urls, poster: nil, autoplay: false, loop: false)
|
29
|
-
# assume the file extension is the video format
|
30
|
-
# otherwise, the host's declared mime type is used to figure out compatibility
|
31
|
-
# which is usually wrong
|
32
|
-
sources = urls.map { |url| [url, url.match(/[^\.]*\z/)&.[](0).downcase] }
|
33
|
-
sources.each { |_url, ext| raise 'unknown video url file extension' unless %w[mp4 webm].include?(ext) }
|
34
|
-
|
35
|
-
ActionController::Base.helpers.tag.video\
|
36
|
-
width: '100%',
|
37
|
-
preload: 'none',
|
38
|
-
poster: poster,
|
39
|
-
loop: loop,
|
40
|
-
autoplay: autoplay,
|
41
|
-
muted: autoplay,
|
42
|
-
controls: '' do |tag|
|
43
|
-
sources.map { |url, ext| tag.source src: url, type: "video/#{ext}" }
|
44
|
-
.append(I18n.t('video_not_supported'))
|
45
|
-
.yield_self(&tag.method(:safe_join))
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
@@ -1,80 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'quby/questionnaires/entities'
|
4
|
-
|
5
|
-
module Quby
|
6
|
-
module Questionnaires
|
7
|
-
module DSL
|
8
|
-
class PanelBuilder < Base
|
9
|
-
attr_reader :title
|
10
|
-
attr_reader :questionnaire
|
11
|
-
|
12
|
-
def initialize(title, options = {})
|
13
|
-
@panel = Entities::Panel.new(options.merge(title: title, items: []))
|
14
|
-
@default_question_options = options[:default_question_options] || {}
|
15
|
-
@questionnaire = options[:questionnaire]
|
16
|
-
@custom_methods = options[:custom_methods] || {}
|
17
|
-
end
|
18
|
-
|
19
|
-
def build
|
20
|
-
@panel
|
21
|
-
end
|
22
|
-
|
23
|
-
def title(value)
|
24
|
-
@panel.title = value
|
25
|
-
end
|
26
|
-
|
27
|
-
def text(value, options = {})
|
28
|
-
@panel.items << Entities::Text.new(value.to_s, options)
|
29
|
-
end
|
30
|
-
|
31
|
-
def html(value)
|
32
|
-
@panel.items << Entities::Text.new('', html_content: value.to_s)
|
33
|
-
end
|
34
|
-
|
35
|
-
def raw_html(value)
|
36
|
-
@panel.items << Entities::Text.new('', raw_content: value.to_s)
|
37
|
-
end
|
38
|
-
|
39
|
-
def video(*urls, **options)
|
40
|
-
video_html = video_tag *urls, **options
|
41
|
-
@panel.items << Entities::Text.new('', raw_content: video_html)
|
42
|
-
end
|
43
|
-
|
44
|
-
def default_question_options(options = {})
|
45
|
-
@default_question_options = @default_question_options.merge(options)
|
46
|
-
end
|
47
|
-
|
48
|
-
def question(key, options = {}, &block)
|
49
|
-
options = @default_question_options.merge(options).merge(questionnaire: @panel.questionnaire)
|
50
|
-
|
51
|
-
check_question_keys_uniqueness key, options, @questionnaire
|
52
|
-
|
53
|
-
question = QuestionBuilder.build(key, options, &block)
|
54
|
-
|
55
|
-
@questionnaire.register_question(question)
|
56
|
-
@panel.items << question
|
57
|
-
end
|
58
|
-
|
59
|
-
def table(options = {}, &block)
|
60
|
-
table_builder = TableBuilder.new(@panel, options.merge(questionnaire: @panel.questionnaire,
|
61
|
-
default_question_options: @default_question_options,
|
62
|
-
custom_methods: @custom_methods))
|
63
|
-
table_builder.instance_eval(&block) if block
|
64
|
-
end
|
65
|
-
|
66
|
-
def method_missing(method_sym, *args, &block)
|
67
|
-
if @custom_methods.key? method_sym
|
68
|
-
instance_exec(*args, &@custom_methods[method_sym])
|
69
|
-
else
|
70
|
-
super
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def respond_to_missing?(method_name, include_private = false)
|
75
|
-
@custom_methods.key?(method_name) || super
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|