rggen-core 0.33.0 → 0.34.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +1 -1
- 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 +112 -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 +9 -2
- 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/input_base/component_factory.rb +10 -7
- data/lib/rggen/core/input_base/error.rb +1 -1
- data/lib/rggen/core/input_base/feature.rb +63 -72
- data/lib/rggen/core/input_base/feature_factory.rb +2 -1
- data/lib/rggen/core/input_base/input_data.rb +9 -6
- data/lib/rggen/core/input_base/input_vaue_parser.rb +2 -12
- data/lib/rggen/core/input_base/loader.rb +7 -1
- data/lib/rggen/core/input_base/option_hash_parser.rb +1 -1
- data/lib/rggen/core/input_base/property.rb +4 -4
- 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 +77 -0
- data/lib/rggen/core/output_base/feature.rb +16 -86
- data/lib/rggen/core/register_map/component_factory.rb +2 -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 +15 -10
- 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 +7 -7
- 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,11 +4,18 @@ module RgGen
|
|
4
4
|
module Core
|
5
5
|
module Configuration
|
6
6
|
class InputData < InputBase::InputData
|
7
|
-
def initialize(valid_value_lists, &
|
8
|
-
super(nil, valid_value_lists, &
|
7
|
+
def initialize(valid_value_lists, &)
|
8
|
+
super(nil, valid_value_lists, &)
|
9
9
|
end
|
10
10
|
|
11
11
|
undef_method :child
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def raise_unknown_field_error(field_name, position)
|
16
|
+
message = "unknown configuration field is given: #{field_name}"
|
17
|
+
error(message, position)
|
18
|
+
end
|
12
19
|
end
|
13
20
|
end
|
14
21
|
end
|
@@ -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
|
@@ -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
|
@@ -51,23 +53,24 @@ module RgGen
|
|
51
53
|
.transform_values(&->(f) { f.valid_value_list })
|
52
54
|
end
|
53
55
|
|
54
|
-
def create_input_data(*_args, &
|
56
|
+
def create_input_data(*_args, &)
|
55
57
|
end
|
56
58
|
|
57
59
|
def create_features(component, *sources)
|
58
|
-
create_active_features(component, sources
|
59
|
-
create_passive_features(component)
|
60
|
+
create_active_features(component, sources)
|
61
|
+
create_passive_features(component, sources)
|
60
62
|
end
|
61
63
|
|
62
|
-
def create_active_features(component,
|
64
|
+
def create_active_features(component, sources)
|
63
65
|
active_feature_factories.each do |name, factory|
|
64
|
-
|
66
|
+
input_data = sources.last[name]
|
67
|
+
create_feature(component, factory, *sources[0..-2], input_data)
|
65
68
|
end
|
66
69
|
end
|
67
70
|
|
68
|
-
def create_passive_features(component)
|
71
|
+
def create_passive_features(component, sources)
|
69
72
|
passive_feature_factories.each_value do |factory|
|
70
|
-
create_feature(component, factory)
|
73
|
+
create_feature(component, factory, *sources[0..-2])
|
71
74
|
end
|
72
75
|
end
|
73
76
|
|
@@ -6,102 +6,85 @@ 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_array_variable_get(:@properties)
|
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
|
-
|
25
|
+
private
|
26
|
+
|
27
|
+
def property(name, ...)
|
28
|
+
Property.define(self, name, ...)
|
29
|
+
properties&.include?(name) ||
|
30
|
+
feature_array_variable_push(:@properties, name)
|
34
31
|
end
|
35
32
|
|
36
|
-
|
33
|
+
alias_method :field, :property
|
37
34
|
|
38
|
-
def
|
39
|
-
|
35
|
+
def ignore_empty_value(value)
|
36
|
+
@ignore_empty_value = value
|
40
37
|
end
|
41
38
|
|
42
|
-
|
43
|
-
|
44
|
-
def active_feature?
|
45
|
-
!passive_feature?
|
39
|
+
def build(&block)
|
40
|
+
feature_array_variable_push(:@builders, block)
|
46
41
|
end
|
47
42
|
|
48
|
-
def
|
49
|
-
|
43
|
+
def post_build(&block)
|
44
|
+
feature_array_variable_push(:@post_builders, block)
|
50
45
|
end
|
51
46
|
|
52
47
|
def input_pattern(pattern_or_patterns, ...)
|
53
48
|
@input_matcher = InputMatcher.new(pattern_or_patterns, ...)
|
54
49
|
end
|
55
50
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
attr_reader :verifiers
|
64
|
-
|
65
|
-
def printable(name, &body)
|
66
|
-
(@printables ||= {})[name] = body
|
51
|
+
def verify(scope, prepend: false, &)
|
52
|
+
verifyier = create_verifier(&)
|
53
|
+
if prepend
|
54
|
+
feature_hash_array_variable_prepend(:@verifiers, scope, verifyier)
|
55
|
+
else
|
56
|
+
feature_hash_array_variable_push(:@verifiers, scope, verifyier)
|
57
|
+
end
|
67
58
|
end
|
68
59
|
|
69
|
-
|
70
|
-
|
71
|
-
def inherited(subclass)
|
72
|
-
super
|
73
|
-
export_instance_variable(:@properties, subclass, &:dup)
|
74
|
-
export_instance_variable(:@ignore_empty_value, subclass)
|
75
|
-
export_instance_variable(:@builders, subclass, &:dup)
|
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
|
60
|
+
def create_verifier(&)
|
61
|
+
Verifier.new(&)
|
80
62
|
end
|
81
63
|
|
82
|
-
|
83
|
-
|
84
|
-
def create_verifier(&body)
|
85
|
-
Verifier.new(&body)
|
86
|
-
end
|
87
|
-
|
88
|
-
def export_verifiers(subclass)
|
89
|
-
subclass
|
90
|
-
.instance_variable_set(:@verifiers, @verifiers.transform_values(&:dup))
|
64
|
+
def printable(name, &body)
|
65
|
+
feature_hash_variable_store(:@printables, name, body)
|
91
66
|
end
|
92
67
|
end
|
93
68
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
def_delegator :'self.class', :ignore_empty_value?
|
69
|
+
def properties
|
70
|
+
feature_array_variable_get(:@properties)
|
71
|
+
end
|
98
72
|
|
99
73
|
def build(*args)
|
100
|
-
|
74
|
+
builders = feature_array_variable_get(:@builders)
|
75
|
+
return unless builders
|
76
|
+
|
77
|
+
do_build(builders, args)
|
101
78
|
end
|
102
79
|
|
103
80
|
def post_build
|
104
|
-
|
81
|
+
feature_array_variable_get(:@post_builders)
|
82
|
+
&.each { |block| instance_exec(&block) }
|
83
|
+
end
|
84
|
+
|
85
|
+
def ignore_empty_value?
|
86
|
+
feaure_scala_variable_get(:@ignore_empty_value)
|
87
|
+
.then { _1.nil? || _1 }
|
105
88
|
end
|
106
89
|
|
107
90
|
def verify(scope)
|
@@ -109,11 +92,12 @@ module RgGen
|
|
109
92
|
end
|
110
93
|
|
111
94
|
def printables
|
112
|
-
|
95
|
+
feature_hash_variable_get(:@printables)
|
96
|
+
&.map { |name, body| [name, printable(name, &body)] }
|
113
97
|
end
|
114
98
|
|
115
99
|
def printable?
|
116
|
-
!
|
100
|
+
!feature_hash_variable_get(:@printables).nil?
|
117
101
|
end
|
118
102
|
|
119
103
|
def inspect
|
@@ -135,23 +119,27 @@ module RgGen
|
|
135
119
|
|
136
120
|
private
|
137
121
|
|
138
|
-
def do_build(args)
|
122
|
+
def do_build(builders, args)
|
139
123
|
@position = args.last.position
|
140
124
|
match_automatically? && match_pattern(args.last)
|
141
|
-
execute_build_blocks(args)
|
125
|
+
execute_build_blocks(builders, args)
|
142
126
|
end
|
143
127
|
|
144
|
-
def execute_build_blocks(args)
|
128
|
+
def execute_build_blocks(builders, args)
|
145
129
|
args = [*args, args.last.options] if args.last.with_options?
|
146
|
-
|
130
|
+
builders.each { |builder| instance_exec(*args, &builder) }
|
131
|
+
end
|
132
|
+
|
133
|
+
def input_matcher
|
134
|
+
feaure_scala_variable_get(:@input_matcher)
|
147
135
|
end
|
148
136
|
|
149
137
|
def match_automatically?
|
150
|
-
|
138
|
+
input_matcher&.match_automatically?
|
151
139
|
end
|
152
140
|
|
153
141
|
def match_pattern(rhs)
|
154
|
-
@match_data, @match_index =
|
142
|
+
@match_data, @match_index = input_matcher&.match(rhs)
|
155
143
|
end
|
156
144
|
|
157
145
|
attr_reader :match_data
|
@@ -166,12 +154,15 @@ module RgGen
|
|
166
154
|
end
|
167
155
|
|
168
156
|
def do_verify(scope)
|
169
|
-
|
157
|
+
verifiers = feature_hash_array_variable_get(:@verifiers)
|
158
|
+
return unless verifiers
|
159
|
+
|
160
|
+
verifiers[scope]&.each { |verifier| verifier.verify(self) }
|
170
161
|
(@verified ||= {})[scope] = true
|
171
162
|
end
|
172
163
|
|
173
|
-
def printable(name, &
|
174
|
-
block_given? ? instance_exec(&
|
164
|
+
def printable(name, &)
|
165
|
+
block_given? ? instance_exec(&) : __send__(name)
|
175
166
|
end
|
176
167
|
end
|
177
168
|
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
|
@@ -17,8 +19,9 @@ module RgGen
|
|
17
19
|
|
18
20
|
def value(value_name, value, position = nil)
|
19
21
|
symbolized_name = value_name.to_sym
|
20
|
-
valid_value?(symbolized_name)
|
21
|
-
|
22
|
+
valid_value?(symbolized_name) ||
|
23
|
+
raise_unknown_field_error(symbolized_name, position)
|
24
|
+
assign_value(symbolized_name, value, position)
|
22
25
|
end
|
23
26
|
|
24
27
|
def []=(value_name, position = nil, value)
|
@@ -36,9 +39,9 @@ module RgGen
|
|
36
39
|
|
37
40
|
attr_reader :children
|
38
41
|
|
39
|
-
def child(layer, value_list = nil, &
|
42
|
+
def child(layer, value_list = nil, &)
|
40
43
|
create_child_data(layer) do |child_data|
|
41
|
-
child_data.build_by_block(&
|
44
|
+
child_data.build_by_block(&)
|
42
45
|
child_data.values(value_list)
|
43
46
|
@children << child_data
|
44
47
|
end
|
@@ -97,8 +100,8 @@ module RgGen
|
|
97
100
|
|
98
101
|
protected
|
99
102
|
|
100
|
-
def build_by_block(&
|
101
|
-
block_given? && Docile.dsl_eval(self, &
|
103
|
+
def build_by_block(&)
|
104
|
+
block_given? && Docile.dsl_eval(self, &)
|
102
105
|
end
|
103
106
|
end
|
104
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,6 +4,8 @@ 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
|
@@ -68,7 +70,11 @@ module RgGen
|
|
68
70
|
end
|
69
71
|
|
70
72
|
def filter_layer_data(layer_data, layer)
|
71
|
-
|
73
|
+
if @ignore_values.key?(layer)
|
74
|
+
layer_data.except(*@ignore_values[layer])
|
75
|
+
else
|
76
|
+
layer_data
|
77
|
+
end
|
72
78
|
end
|
73
79
|
|
74
80
|
def format_sub_layer_data(_read_data, _layer, _file)
|
@@ -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
|
@@ -4,18 +4,18 @@ module RgGen
|
|
4
4
|
module Core
|
5
5
|
module InputBase
|
6
6
|
class Property
|
7
|
-
def self.define(feature, name, **options, &
|
8
|
-
new(name, options, &
|
7
|
+
def self.define(feature, name, **options, &)
|
8
|
+
new(name, options, &).define(feature)
|
9
9
|
end
|
10
10
|
|
11
|
-
def initialize(name, options, &
|
11
|
+
def initialize(name, options, &)
|
12
12
|
@name = name
|
13
13
|
@options = options
|
14
14
|
@costom_property =
|
15
15
|
if options[:body]
|
16
16
|
create_costom_property(&options[:body])
|
17
17
|
elsif block_given?
|
18
|
-
create_costom_property(&
|
18
|
+
create_costom_property(&)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -4,8 +4,8 @@ module RgGen
|
|
4
4
|
module Core
|
5
5
|
module InputBase
|
6
6
|
class Verifier
|
7
|
-
def initialize(&
|
8
|
-
instance_eval(&
|
7
|
+
def initialize(&)
|
8
|
+
instance_eval(&)
|
9
9
|
end
|
10
10
|
|
11
11
|
def check_error(&block)
|
@@ -20,6 +20,10 @@ module RgGen
|
|
20
20
|
@message = block
|
21
21
|
end
|
22
22
|
|
23
|
+
def position(&block)
|
24
|
+
@position = block
|
25
|
+
end
|
26
|
+
|
23
27
|
def verify(feature, *values)
|
24
28
|
if @error_checker
|
25
29
|
feature.instance_exec(*values, &@error_checker)
|
@@ -31,8 +35,11 @@ module RgGen
|
|
31
35
|
private
|
32
36
|
|
33
37
|
def default_error_check(feature, values)
|
34
|
-
feature.instance_exec(*values, &@condition)
|
35
|
-
|
38
|
+
return unless feature.instance_exec(*values, &@condition)
|
39
|
+
|
40
|
+
message = feature.instance_exec(*values, &@message)
|
41
|
+
position = @position && feature.instance_exec(*values, &@position)
|
42
|
+
feature.__send__(:error, message, position)
|
36
43
|
end
|
37
44
|
end
|
38
45
|
end
|
data/lib/rggen/core/options.rb
CHANGED
@@ -67,8 +67,8 @@ module RgGen
|
|
67
67
|
@options ||= {}
|
68
68
|
end
|
69
69
|
|
70
|
-
def self.add_option(option_name, &
|
71
|
-
options[option_name] = Option.new(option_name, &
|
70
|
+
def self.add_option(option_name, &)
|
71
|
+
options[option_name] = Option.new(option_name, &)
|
72
72
|
end
|
73
73
|
|
74
74
|
def initialize
|