rggen-core 0.33.1 → 0.35.0
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 +4 -4
- data/LICENSE +1 -1
- data/README.md +2 -2
- data/lib/rggen/core/base/component_factory.rb +2 -2
- data/lib/rggen/core/base/feature.rb +5 -4
- data/lib/rggen/core/base/feature_variable.rb +123 -0
- data/lib/rggen/core/base/internal_struct.rb +2 -2
- data/lib/rggen/core/builder/builder.rb +5 -4
- data/lib/rggen/core/builder/component_registry.rb +6 -6
- data/lib/rggen/core/builder/feature_entry_base.rb +4 -4
- data/lib/rggen/core/builder/feature_registry.rb +21 -20
- data/lib/rggen/core/builder/general_feature_entry.rb +5 -6
- data/lib/rggen/core/builder/input_component_registry.rb +2 -2
- data/lib/rggen/core/builder/layer.rb +65 -34
- data/lib/rggen/core/builder/list_feature_entry.rb +12 -9
- data/lib/rggen/core/builder/loader_registry.rb +4 -4
- data/lib/rggen/core/builder/plugin_manager.rb +14 -3
- data/lib/rggen/core/builder/simple_feature_entry.rb +5 -6
- data/lib/rggen/core/configuration/component_factory.rb +2 -2
- data/lib/rggen/core/configuration/feature.rb +0 -2
- data/lib/rggen/core/configuration/feature_factory.rb +0 -1
- data/lib/rggen/core/configuration/input_data.rb +2 -4
- data/lib/rggen/core/configuration/loader.rb +0 -1
- data/lib/rggen/core/core_extensions/kernel.rb +1 -1
- data/lib/rggen/core/core_extensions/object.rb +0 -7
- data/lib/rggen/core/dsl.rb +2 -1
- data/lib/rggen/core/exceptions.rb +3 -3
- data/lib/rggen/core/generator.rb +0 -2
- data/lib/rggen/core/input_base/component_factory.rb +27 -15
- data/lib/rggen/core/input_base/error.rb +1 -1
- data/lib/rggen/core/input_base/feature.rb +68 -72
- data/lib/rggen/core/input_base/feature_factory.rb +2 -1
- data/lib/rggen/core/input_base/input_data.rb +6 -4
- data/lib/rggen/core/input_base/input_vaue_parser.rb +2 -12
- data/lib/rggen/core/input_base/loader.rb +24 -4
- data/lib/rggen/core/input_base/option_hash_parser.rb +1 -1
- data/lib/rggen/core/input_base/property.rb +7 -17
- data/lib/rggen/core/input_base/verifier.rb +11 -4
- data/lib/rggen/core/options.rb +2 -2
- data/lib/rggen/core/output_base/code_generatable.rb +82 -0
- data/lib/rggen/core/output_base/feature.rb +16 -86
- data/lib/rggen/core/register_map/component_factory.rb +9 -4
- data/lib/rggen/core/register_map/feature.rb +0 -1
- data/lib/rggen/core/register_map/feature_factory.rb +0 -1
- data/lib/rggen/core/register_map/input_data.rb +10 -12
- data/lib/rggen/core/utility/attribute_setter.rb +13 -10
- data/lib/rggen/core/utility/code_utility/source_file.rb +1 -1
- data/lib/rggen/core/utility/code_utility.rb +2 -2
- data/lib/rggen/core/utility/regexp_patterns.rb +1 -1
- data/lib/rggen/core/version.rb +1 -1
- data/lib/rggen/core.rb +2 -3
- metadata +7 -11
- data/lib/rggen/core/configuration/error.rb +0 -20
- data/lib/rggen/core/output_base/code_generator.rb +0 -45
- data/lib/rggen/core/register_map/error.rb +0 -20
@@ -73,8 +73,15 @@ module RgGen
|
|
73
73
|
activation && activate_plugins
|
74
74
|
end
|
75
75
|
|
76
|
-
def setup_plugin(plugin_name, &
|
77
|
-
@plugins << PluginSpec.new(plugin_name, &
|
76
|
+
def setup_plugin(plugin_name, &)
|
77
|
+
@plugins << PluginSpec.new(plugin_name, &)
|
78
|
+
end
|
79
|
+
|
80
|
+
def update_plugin(plugin_name)
|
81
|
+
plugin =
|
82
|
+
find_plugin(plugin_name) ||
|
83
|
+
(raise PluginError.new("unknown plugin: #{plugin_name}"))
|
84
|
+
block_given? && yield(plugin)
|
78
85
|
end
|
79
86
|
|
80
87
|
def activate_plugins
|
@@ -83,7 +90,7 @@ module RgGen
|
|
83
90
|
end
|
84
91
|
|
85
92
|
def activate_plugin_by_name(plugin_name)
|
86
|
-
|
93
|
+
find_plugin(plugin_name)
|
87
94
|
&.then do |plugin|
|
88
95
|
plugin.activate(@builder)
|
89
96
|
plugin.activate_additionally(@builder)
|
@@ -103,6 +110,10 @@ module RgGen
|
|
103
110
|
raise Core::PluginError.new("cannot load such plugin: #{info}")
|
104
111
|
end
|
105
112
|
|
113
|
+
def find_plugin(plugin_name)
|
114
|
+
@plugins.find { |plugin| plugin.name == plugin_name }
|
115
|
+
end
|
116
|
+
|
106
117
|
def activate_plugin_gem(info)
|
107
118
|
if (gemspec = find_gemspec(info))
|
108
119
|
gem gemspec.name, gemspec.version
|
@@ -4,8 +4,8 @@ module RgGen
|
|
4
4
|
module Core
|
5
5
|
module Builder
|
6
6
|
class SimpleFeatureEntry < FeatureEntryBase
|
7
|
-
def setup(base_feature, factory, context
|
8
|
-
define_feature(base_feature, context
|
7
|
+
def setup(base_feature, factory, context)
|
8
|
+
define_feature(base_feature, context)
|
9
9
|
@factory = factory
|
10
10
|
end
|
11
11
|
|
@@ -15,18 +15,17 @@ module RgGen
|
|
15
15
|
:simple
|
16
16
|
end
|
17
17
|
|
18
|
-
def define_feature(base, context
|
18
|
+
def define_feature(base, context)
|
19
19
|
@feature = Class.new(base)
|
20
20
|
attach_shared_context(context, @feature)
|
21
|
-
eval_body(&body)
|
22
21
|
end
|
23
22
|
|
24
23
|
def target_feature
|
25
24
|
@feature
|
26
25
|
end
|
27
26
|
|
28
|
-
def eval_body(&
|
29
|
-
block_given? && @feature.class_exec(@name, &
|
27
|
+
def eval_body(&)
|
28
|
+
block_given? && @feature.class_exec(@name, &)
|
30
29
|
end
|
31
30
|
end
|
32
31
|
end
|
@@ -4,10 +4,8 @@ module RgGen
|
|
4
4
|
module Core
|
5
5
|
module Configuration
|
6
6
|
class InputData < InputBase::InputData
|
7
|
-
|
8
|
-
|
9
|
-
def initialize(valid_value_lists, &block)
|
10
|
-
super(nil, valid_value_lists, &block)
|
7
|
+
def initialize(valid_value_lists, &)
|
8
|
+
super(nil, valid_value_lists, &)
|
11
9
|
end
|
12
10
|
|
13
11
|
undef_method :child
|
@@ -1,13 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class Object
|
4
|
-
def export_instance_variable(variable, to)
|
5
|
-
instance_variable_defined?(variable) &&
|
6
|
-
instance_variable_get(variable)
|
7
|
-
.then { |v| block_given? ? yield(v) : v }
|
8
|
-
.then { |v| to.instance_variable_set(variable, v) }
|
9
|
-
end
|
10
|
-
|
11
4
|
def singleton_exec(...)
|
12
5
|
singleton_class.class_exec(...)
|
13
6
|
end
|
data/lib/rggen/core/dsl.rb
CHANGED
@@ -25,13 +25,13 @@ module RgGen
|
|
25
25
|
class PluginError < RgGenError
|
26
26
|
end
|
27
27
|
|
28
|
-
class
|
28
|
+
class LoadError < RgGenError
|
29
29
|
end
|
30
30
|
|
31
|
-
class
|
31
|
+
class SourceError < RgGenError
|
32
32
|
end
|
33
33
|
|
34
|
-
class GeneratorError <
|
34
|
+
class GeneratorError < RgGenError
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
data/lib/rggen/core/generator.rb
CHANGED
@@ -4,6 +4,8 @@ module RgGen
|
|
4
4
|
module Core
|
5
5
|
module InputBase
|
6
6
|
class ComponentFactory < Base::ComponentFactory
|
7
|
+
include RaiseError
|
8
|
+
|
7
9
|
class << self
|
8
10
|
def enable_no_children_error
|
9
11
|
@enable_no_children_error = true
|
@@ -24,26 +26,35 @@ module RgGen
|
|
24
26
|
|
25
27
|
def preprocess(args)
|
26
28
|
if root_factory?
|
27
|
-
[*args[0..-2],
|
29
|
+
[*args[0..-2], load_inputs(args)]
|
28
30
|
else
|
29
31
|
args
|
30
32
|
end
|
31
33
|
end
|
32
34
|
|
33
|
-
def
|
35
|
+
def load_inputs(args)
|
34
36
|
files = args.last
|
35
37
|
create_input_data(*args[0..-2]) do |input_data|
|
36
|
-
files.
|
38
|
+
if files.empty?
|
39
|
+
handle_empty_input(input_data)
|
40
|
+
else
|
41
|
+
files.each { |file| load_file(input_data, file) }
|
42
|
+
end
|
37
43
|
end
|
38
44
|
end
|
39
45
|
|
40
|
-
def
|
41
|
-
|
46
|
+
def handle_empty_input(_input_data)
|
47
|
+
end
|
48
|
+
|
49
|
+
def load_file(input_data, file)
|
50
|
+
loader = find_loader { _1.support?(file) }
|
51
|
+
raise Core::LoadError.new('unsupported file type', file) unless loader
|
52
|
+
|
53
|
+
loader.load_data(input_data, valid_value_lists, file)
|
42
54
|
end
|
43
55
|
|
44
|
-
def find_loader(
|
45
|
-
loaders.reverse_each.find
|
46
|
-
(raise Core::LoadError.new('unsupported file type', file))
|
56
|
+
def find_loader(&)
|
57
|
+
loaders.reverse_each.find(&)
|
47
58
|
end
|
48
59
|
|
49
60
|
def valid_value_lists
|
@@ -51,23 +62,24 @@ module RgGen
|
|
51
62
|
.transform_values(&->(f) { f.valid_value_list })
|
52
63
|
end
|
53
64
|
|
54
|
-
def create_input_data(*_args, &
|
65
|
+
def create_input_data(*_args, &)
|
55
66
|
end
|
56
67
|
|
57
68
|
def create_features(component, *sources)
|
58
|
-
create_active_features(component, sources
|
59
|
-
create_passive_features(component)
|
69
|
+
create_active_features(component, sources)
|
70
|
+
create_passive_features(component, sources)
|
60
71
|
end
|
61
72
|
|
62
|
-
def create_active_features(component,
|
73
|
+
def create_active_features(component, sources)
|
63
74
|
active_feature_factories.each do |name, factory|
|
64
|
-
|
75
|
+
input_data = sources.last[name]
|
76
|
+
create_feature(component, factory, *sources[0..-2], input_data)
|
65
77
|
end
|
66
78
|
end
|
67
79
|
|
68
|
-
def create_passive_features(component)
|
80
|
+
def create_passive_features(component, sources)
|
69
81
|
passive_feature_factories.each_value do |factory|
|
70
|
-
create_feature(component, factory)
|
82
|
+
create_feature(component, factory, *sources[0..-2])
|
71
83
|
end
|
72
84
|
end
|
73
85
|
|
@@ -6,102 +6,86 @@ module RgGen
|
|
6
6
|
class Feature < Base::Feature
|
7
7
|
include Utility::RegexpPatterns
|
8
8
|
include Utility::TypeChecker
|
9
|
+
include RaiseError
|
9
10
|
include ConversionUtility
|
10
11
|
|
11
12
|
class << self
|
12
|
-
def property(name, ...)
|
13
|
-
Property.define(self, name, ...)
|
14
|
-
properties.include?(name) || properties << name
|
15
|
-
end
|
16
|
-
|
17
|
-
alias_method :field, :property
|
18
|
-
|
19
13
|
def properties
|
20
|
-
|
14
|
+
feature_hash_variable_get(:@properties)&.keys
|
21
15
|
end
|
22
16
|
|
23
|
-
def
|
24
|
-
|
25
|
-
@ignore_empty_value
|
17
|
+
def active_feature?
|
18
|
+
!passive_feature?
|
26
19
|
end
|
27
20
|
|
28
|
-
def
|
29
|
-
|
21
|
+
def passive_feature?
|
22
|
+
feature_array_variable_get(:@builders).nil?
|
30
23
|
end
|
31
24
|
|
32
|
-
|
33
|
-
(@builders ||= []) << block
|
34
|
-
end
|
25
|
+
private
|
35
26
|
|
36
|
-
|
27
|
+
def property(name, ...)
|
28
|
+
feature_hash_variable_store(:@properties, name, Property.new(name, ...))
|
29
|
+
return if method_defined?(name)
|
37
30
|
|
38
|
-
|
39
|
-
(@post_builders ||= []) << block
|
31
|
+
public alias_method(name, :property_method)
|
40
32
|
end
|
41
33
|
|
42
|
-
|
43
|
-
|
44
|
-
def active_feature?
|
45
|
-
!passive_feature?
|
46
|
-
end
|
34
|
+
alias_method :field, :property
|
47
35
|
|
48
|
-
def
|
49
|
-
|
36
|
+
def ignore_empty_value(value)
|
37
|
+
@ignore_empty_value = value
|
50
38
|
end
|
51
39
|
|
52
|
-
def
|
53
|
-
|
40
|
+
def build(&block)
|
41
|
+
feature_array_variable_push(:@builders, block)
|
54
42
|
end
|
55
43
|
|
56
|
-
|
57
|
-
|
58
|
-
def verify(scope, &block)
|
59
|
-
@verifiers ||= {}
|
60
|
-
(@verifiers[scope] ||= []) << create_verifier(&block)
|
44
|
+
def post_build(&block)
|
45
|
+
feature_array_variable_push(:@post_builders, block)
|
61
46
|
end
|
62
47
|
|
63
|
-
|
64
|
-
|
65
|
-
def printable(name, &body)
|
66
|
-
(@printables ||= {})[name] = body
|
48
|
+
def input_pattern(pattern_or_patterns, ...)
|
49
|
+
@input_matcher = InputMatcher.new(pattern_or_patterns, ...)
|
67
50
|
end
|
68
51
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
export_instance_variable(:@post_builders, subclass, &:dup)
|
77
|
-
export_instance_variable(:@input_matcher, subclass)
|
78
|
-
export_instance_variable(:@printables, subclass, &:dup)
|
79
|
-
export_verifiers(subclass) if @verifiers
|
52
|
+
def verify(scope, prepend: false, &)
|
53
|
+
verifyier = create_verifier(&)
|
54
|
+
if prepend
|
55
|
+
feature_hash_array_variable_prepend(:@verifiers, scope, verifyier)
|
56
|
+
else
|
57
|
+
feature_hash_array_variable_push(:@verifiers, scope, verifyier)
|
58
|
+
end
|
80
59
|
end
|
81
60
|
|
82
|
-
|
83
|
-
|
84
|
-
def create_verifier(&body)
|
85
|
-
Verifier.new(&body)
|
61
|
+
def create_verifier(&)
|
62
|
+
Verifier.new(&)
|
86
63
|
end
|
87
64
|
|
88
|
-
def
|
89
|
-
|
90
|
-
.instance_variable_set(:@verifiers, @verifiers.transform_values(&:dup))
|
65
|
+
def printable(name, &body)
|
66
|
+
feature_hash_variable_store(:@printables, name, body)
|
91
67
|
end
|
92
68
|
end
|
93
69
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
def_delegator :'self.class', :ignore_empty_value?
|
70
|
+
def properties
|
71
|
+
feature_hash_variable_get(:@properties)&.keys
|
72
|
+
end
|
98
73
|
|
99
74
|
def build(*args)
|
100
|
-
|
75
|
+
builders = feature_array_variable_get(:@builders)
|
76
|
+
return unless builders
|
77
|
+
|
78
|
+
do_build(builders, args)
|
101
79
|
end
|
102
80
|
|
103
81
|
def post_build
|
104
|
-
|
82
|
+
feature_array_variable_get(:@post_builders)
|
83
|
+
&.each { |block| instance_exec(&block) }
|
84
|
+
end
|
85
|
+
|
86
|
+
def ignore_empty_value?
|
87
|
+
feaure_scala_variable_get(:@ignore_empty_value)
|
88
|
+
.then { _1.nil? || _1 }
|
105
89
|
end
|
106
90
|
|
107
91
|
def verify(scope)
|
@@ -109,11 +93,12 @@ module RgGen
|
|
109
93
|
end
|
110
94
|
|
111
95
|
def printables
|
112
|
-
|
96
|
+
feature_hash_variable_get(:@printables)
|
97
|
+
&.map { |name, body| [name, printable(name, &body)] }
|
113
98
|
end
|
114
99
|
|
115
100
|
def printable?
|
116
|
-
!
|
101
|
+
!feature_hash_variable_get(:@printables).nil?
|
117
102
|
end
|
118
103
|
|
119
104
|
def inspect
|
@@ -135,23 +120,31 @@ module RgGen
|
|
135
120
|
|
136
121
|
private
|
137
122
|
|
138
|
-
def
|
123
|
+
def property_method(...)
|
124
|
+
feature_hash_variable_fetch(:@properties, __callee__).evaluate(self, ...)
|
125
|
+
end
|
126
|
+
|
127
|
+
def do_build(builders, args)
|
139
128
|
@position = args.last.position
|
140
129
|
match_automatically? && match_pattern(args.last)
|
141
|
-
execute_build_blocks(args)
|
130
|
+
execute_build_blocks(builders, args)
|
142
131
|
end
|
143
132
|
|
144
|
-
def execute_build_blocks(args)
|
133
|
+
def execute_build_blocks(builders, args)
|
145
134
|
args = [*args, args.last.options] if args.last.with_options?
|
146
|
-
|
135
|
+
builders.each { |builder| instance_exec(*args, &builder) }
|
136
|
+
end
|
137
|
+
|
138
|
+
def input_matcher
|
139
|
+
feaure_scala_variable_get(:@input_matcher)
|
147
140
|
end
|
148
141
|
|
149
142
|
def match_automatically?
|
150
|
-
|
143
|
+
input_matcher&.match_automatically?
|
151
144
|
end
|
152
145
|
|
153
146
|
def match_pattern(rhs)
|
154
|
-
@match_data, @match_index =
|
147
|
+
@match_data, @match_index = input_matcher&.match(rhs)
|
155
148
|
end
|
156
149
|
|
157
150
|
attr_reader :match_data
|
@@ -166,12 +159,15 @@ module RgGen
|
|
166
159
|
end
|
167
160
|
|
168
161
|
def do_verify(scope)
|
169
|
-
|
162
|
+
verifiers = feature_hash_array_variable_get(:@verifiers)
|
163
|
+
return unless verifiers
|
164
|
+
|
165
|
+
verifiers[scope]&.each { |verifier| verifier.verify(self) }
|
170
166
|
(@verified ||= {})[scope] = true
|
171
167
|
end
|
172
168
|
|
173
|
-
def printable(name, &
|
174
|
-
block_given? ? instance_exec(&
|
169
|
+
def printable(name, &)
|
170
|
+
block_given? ? instance_exec(&) : __send__(name)
|
175
171
|
end
|
176
172
|
end
|
177
173
|
end
|
@@ -5,6 +5,7 @@ module RgGen
|
|
5
5
|
module InputBase
|
6
6
|
class FeatureFactory < Base::FeatureFactory
|
7
7
|
include Utility::TypeChecker
|
8
|
+
include RaiseError
|
8
9
|
|
9
10
|
class << self
|
10
11
|
def convert_value(&block)
|
@@ -66,7 +67,7 @@ module RgGen
|
|
66
67
|
|
67
68
|
def parse_input_value(input_value, value_format)
|
68
69
|
format, options = value_format
|
69
|
-
VALUE_PARSERS[format].new(
|
70
|
+
VALUE_PARSERS[format].new(**options).parse(input_value)
|
70
71
|
end
|
71
72
|
|
72
73
|
def override_input_value(input_value, parsed_value, options)
|
@@ -4,6 +4,8 @@ module RgGen
|
|
4
4
|
module Core
|
5
5
|
module InputBase
|
6
6
|
class InputData
|
7
|
+
include RaiseError
|
8
|
+
|
7
9
|
def initialize(layer, valid_value_lists, *_args)
|
8
10
|
@layer = layer
|
9
11
|
@valid_value_lists = valid_value_lists
|
@@ -37,9 +39,9 @@ module RgGen
|
|
37
39
|
|
38
40
|
attr_reader :children
|
39
41
|
|
40
|
-
def child(layer, value_list = nil, &
|
42
|
+
def child(layer, value_list = nil, &)
|
41
43
|
create_child_data(layer) do |child_data|
|
42
|
-
child_data.build_by_block(&
|
44
|
+
child_data.build_by_block(&)
|
43
45
|
child_data.values(value_list)
|
44
46
|
@children << child_data
|
45
47
|
end
|
@@ -98,8 +100,8 @@ module RgGen
|
|
98
100
|
|
99
101
|
protected
|
100
102
|
|
101
|
-
def build_by_block(&
|
102
|
-
block_given? && Docile.dsl_eval(self, &
|
103
|
+
def build_by_block(&)
|
104
|
+
block_given? && Docile.dsl_eval(self, &)
|
103
105
|
end
|
104
106
|
end
|
105
107
|
end
|
@@ -5,9 +5,9 @@ module RgGen
|
|
5
5
|
module InputBase
|
6
6
|
class InputValueParser
|
7
7
|
include Utility::TypeChecker
|
8
|
+
include RaiseError
|
8
9
|
|
9
|
-
def initialize(
|
10
|
-
@exception = exception
|
10
|
+
def initialize(**_options)
|
11
11
|
end
|
12
12
|
|
13
13
|
private
|
@@ -15,16 +15,6 @@ module RgGen
|
|
15
15
|
def split_string(string, separator, limit)
|
16
16
|
string&.split(separator, limit)&.map(&:strip)
|
17
17
|
end
|
18
|
-
|
19
|
-
def error(message, position_or_input_value = nil)
|
20
|
-
position =
|
21
|
-
if position_or_input_value.respond_to?(:position)
|
22
|
-
position_or_input_value.position
|
23
|
-
else
|
24
|
-
position_or_input_value
|
25
|
-
end
|
26
|
-
raise @exception.new(message, position)
|
27
|
-
end
|
28
18
|
end
|
29
19
|
end
|
30
20
|
end
|
@@ -4,11 +4,17 @@ module RgGen
|
|
4
4
|
module Core
|
5
5
|
module InputBase
|
6
6
|
class Loader
|
7
|
+
include RaiseError
|
8
|
+
|
7
9
|
def self.support_types(types = nil)
|
8
10
|
types && (@support_types ||= []).concat(types.map(&:to_sym))
|
9
11
|
@support_types
|
10
12
|
end
|
11
13
|
|
14
|
+
def self.require_no_input_file
|
15
|
+
@require_input_file = false
|
16
|
+
end
|
17
|
+
|
12
18
|
def initialize(extractors, ignore_values)
|
13
19
|
@extractors = extractors
|
14
20
|
@ignore_values = ignore_values
|
@@ -20,19 +26,33 @@ module RgGen
|
|
20
26
|
types&.any? { |type| type.casecmp?(ext) } || false
|
21
27
|
end
|
22
28
|
|
23
|
-
def
|
29
|
+
def require_input_file?
|
30
|
+
loader = self.class
|
31
|
+
!loader.instance_variable_defined?(:@require_input_file) ||
|
32
|
+
loader.instance_variable_get(:@require_input_file)
|
33
|
+
end
|
34
|
+
|
35
|
+
def load_data(input_data, valid_value_lists, file = nil)
|
36
|
+
if require_input_file?
|
37
|
+
load_file(input_data, valid_value_lists, file)
|
38
|
+
else
|
39
|
+
load_builtin_data(input_data)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def load_file(input_data, valid_value_lists, file)
|
24
44
|
File.readable?(file) ||
|
25
45
|
(raise Core::LoadError.new('cannot load such file', file))
|
26
46
|
@input_data = input_data
|
27
47
|
@valid_value_lists = valid_value_lists
|
28
|
-
|
48
|
+
format_data(read_file(file), input_data, input_data.layer, file)
|
29
49
|
end
|
30
50
|
|
31
51
|
private
|
32
52
|
|
33
53
|
attr_reader :input_data
|
34
54
|
|
35
|
-
def
|
55
|
+
def format_data(read_data, input_data, layer, file)
|
36
56
|
layer_data =
|
37
57
|
format_layer_data(read_data, layer, file) ||
|
38
58
|
format_layer_data_by_extractors(read_data, layer)
|
@@ -43,7 +63,7 @@ module RgGen
|
|
43
63
|
|
44
64
|
def format_sub_layer(read_data, input_data, layer, file)
|
45
65
|
format_sub_layer_data(read_data, layer, file)&.each do |(sub_layer, data)|
|
46
|
-
|
66
|
+
format_data(data, input_data.child(sub_layer), sub_layer, file)
|
47
67
|
end
|
48
68
|
end
|
49
69
|
|
@@ -4,7 +4,7 @@ module RgGen
|
|
4
4
|
module Core
|
5
5
|
module InputBase
|
6
6
|
class OptionHashParser < InputValueParser
|
7
|
-
def initialize(
|
7
|
+
def initialize(allowed_options: nil, multiple_values: false)
|
8
8
|
super
|
9
9
|
@allowed_options = allowed_options
|
10
10
|
@multiple_values = multiple_values
|