rggen-core 0.28.0 → 0.29.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 +1 -1
- data/lib/rggen/core/base/component.rb +2 -2
- data/lib/rggen/core/builder/builder.rb +10 -1
- data/lib/rggen/core/builder/feature_entry_base.rb +42 -0
- data/lib/rggen/core/builder/feature_registry.rb +14 -13
- data/lib/rggen/core/builder/general_feature_entry.rb +40 -0
- data/lib/rggen/core/builder/layer.rb +10 -0
- data/lib/rggen/core/builder/list_feature_entry.rb +10 -23
- data/lib/rggen/core/builder/simple_feature_entry.rb +9 -17
- data/lib/rggen/core/configuration/error.rb +6 -0
- data/lib/rggen/core/core_extensions/object.rb +2 -2
- data/lib/rggen/core/dsl.rb +1 -0
- data/lib/rggen/core/input_base/feature_factory.rb +22 -36
- data/lib/rggen/core/input_base/hash_list_parser.rb +38 -0
- data/lib/rggen/core/input_base/input_vaue_parser.rb +26 -0
- data/lib/rggen/core/input_base/property.rb +6 -6
- data/lib/rggen/core/input_base/value_with_options_parser.rb +33 -0
- data/lib/rggen/core/input_base/yaml_loader.rb +13 -16
- data/lib/rggen/core/register_map/error.rb +6 -0
- data/lib/rggen/core/utility/code_utility/source_file.rb +25 -0
- data/lib/rggen/core/version.rb +1 -1
- data/lib/rggen/core.rb +5 -0
- metadata +10 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18a9718f8b5e18dc5fff8f27e29df34c94017f3964cd63d2f6fa09eb5627a7de
|
4
|
+
data.tar.gz: 21993e58645d31298ec8a8044f1eb05d436a2a05b10215b8f93f5e91443daf03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92e3f06ffd5182911e805c145b08ebea4e74e2e07e618eb7311be527b2abc8e2fdc41b50f82e1565d38798b109d12d325ce15da3262b4ac9aabcad0df077b824
|
7
|
+
data.tar.gz: fc15825417a32f84cddcc5b776b24a51c2f2bc495e82001ca3912a4e7f992e5bfa0b366a19d6ae37f080d3bad9258213a8701c9b9c5b8bff1332f0835fde4377
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -45,7 +45,7 @@ Feedbacks, bug reports, questions and etc. are wellcome! You can post them by us
|
|
45
45
|
|
46
46
|
## Copyright & License
|
47
47
|
|
48
|
-
Copyright © 2017-
|
48
|
+
Copyright © 2017-2023 Taichi Ishitani. RgGen::Core is licensed under the [MIT License](https://opensource.org/licenses/MIT), see [LICENSE](LICENSE) for futher details.
|
49
49
|
|
50
50
|
## Code of Conduct
|
51
51
|
|
@@ -75,9 +75,9 @@ module RgGen
|
|
75
75
|
|
76
76
|
def define_proxy_call(receiver, method_name)
|
77
77
|
(@proxy_receivers ||= {})[method_name.to_sym] = receiver
|
78
|
-
define_singleton_method(method_name) do |*args, &block|
|
78
|
+
define_singleton_method(method_name) do |*args, **keywords, &block|
|
79
79
|
name = __method__
|
80
|
-
@proxy_receivers[name].__send__(name, *args, &block)
|
80
|
+
@proxy_receivers[name].__send__(name, *args, **keywords, &block)
|
81
81
|
end
|
82
82
|
end
|
83
83
|
end
|
@@ -47,6 +47,7 @@ module RgGen
|
|
47
47
|
end
|
48
48
|
|
49
49
|
[
|
50
|
+
:define_feature,
|
50
51
|
:define_simple_feature,
|
51
52
|
:define_list_feature,
|
52
53
|
:define_list_item_feature
|
@@ -73,7 +74,7 @@ module RgGen
|
|
73
74
|
if targets.empty?
|
74
75
|
@component_registries[type]
|
75
76
|
else
|
76
|
-
|
77
|
+
collect_component_factories(type, targets)
|
77
78
|
end
|
78
79
|
registries.each_value.map(&:build_factory)
|
79
80
|
end
|
@@ -127,6 +128,14 @@ module RgGen
|
|
127
128
|
(registries[name] = COMPONENT_REGISTRIES[type].new(name, self))
|
128
129
|
body && Docile.dsl_eval(registries[name], &body) || registries[name]
|
129
130
|
end
|
131
|
+
|
132
|
+
def collect_component_factories(type, targets)
|
133
|
+
unknown_components = targets - @component_registries[type].keys
|
134
|
+
unknown_components.empty? ||
|
135
|
+
(raise BuilderError.new("unknown component: #{unknown_components.first}"))
|
136
|
+
|
137
|
+
@component_registries[type].slice(*targets)
|
138
|
+
end
|
130
139
|
end
|
131
140
|
end
|
132
141
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RgGen
|
4
|
+
module Core
|
5
|
+
module Builder
|
6
|
+
class FeatureEntryBase
|
7
|
+
def initialize(registry, name)
|
8
|
+
@registry = registry
|
9
|
+
@name = name
|
10
|
+
end
|
11
|
+
|
12
|
+
attr_reader :registry
|
13
|
+
attr_reader :name
|
14
|
+
|
15
|
+
def match_entry_type?(entry_type)
|
16
|
+
entry_type == entry_type_name
|
17
|
+
end
|
18
|
+
|
19
|
+
def build_factory(targets)
|
20
|
+
@factory.new(name) do |f|
|
21
|
+
f.target_features(target_features(targets))
|
22
|
+
f.target_feature(target_feature)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def attach_shared_context(context, *targets)
|
29
|
+
(context && targets)&.each do |target|
|
30
|
+
target.attach_context(context)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def target_features(_tergets)
|
35
|
+
end
|
36
|
+
|
37
|
+
def target_feature
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -11,6 +11,10 @@ module RgGen
|
|
11
11
|
@enabled_features = {}
|
12
12
|
end
|
13
13
|
|
14
|
+
def define_feature(name, context = nil, &body)
|
15
|
+
create_new_entry(:general, name, context, &body)
|
16
|
+
end
|
17
|
+
|
14
18
|
def define_simple_feature(name, context = nil, &body)
|
15
19
|
create_new_entry(:simple, name, context, &body)
|
16
20
|
end
|
@@ -51,21 +55,11 @@ module RgGen
|
|
51
55
|
end
|
52
56
|
end
|
53
57
|
|
54
|
-
def simple_feature?(feature_name)
|
55
|
-
@feature_entries[feature_name]&.match_entry_type?(:simple) || false
|
56
|
-
end
|
57
|
-
|
58
|
-
def list_feature?(list_name, feature_name = nil)
|
59
|
-
return false unless @feature_entries[list_name]&.match_entry_type?(:list)
|
60
|
-
return true unless feature_name
|
61
|
-
@feature_entries[list_name].feature?(feature_name)
|
62
|
-
end
|
63
|
-
|
64
58
|
def feature?(feature_or_list_name, feature_name = nil)
|
65
59
|
if feature_name
|
66
60
|
list_feature?(feature_or_list_name, feature_name)
|
67
61
|
else
|
68
|
-
|
62
|
+
@feature_entries.key?(feature_or_list_name)
|
69
63
|
end
|
70
64
|
end
|
71
65
|
|
@@ -89,7 +83,9 @@ module RgGen
|
|
89
83
|
private
|
90
84
|
|
91
85
|
FEATURE_ENTRIES = {
|
92
|
-
|
86
|
+
general: GeneralFeatureEntry,
|
87
|
+
simple: SimpleFeatureEntry,
|
88
|
+
list: ListFeatureEntry
|
93
89
|
}.freeze
|
94
90
|
|
95
91
|
def create_new_entry(type, name, context, &body)
|
@@ -105,7 +101,7 @@ module RgGen
|
|
105
101
|
end
|
106
102
|
|
107
103
|
def enabled_list?(list_name)
|
108
|
-
return false unless
|
104
|
+
return false unless @feature_entries[list_name]&.match_entry_type?(:list)
|
109
105
|
return true if @enabled_features.empty?
|
110
106
|
return true if @enabled_features.key?(list_name)
|
111
107
|
false
|
@@ -114,6 +110,11 @@ module RgGen
|
|
114
110
|
def build_factory(entry)
|
115
111
|
entry.build_factory(@enabled_features[entry.name])
|
116
112
|
end
|
113
|
+
|
114
|
+
def list_feature?(list_name, feature_name)
|
115
|
+
@feature_entries[list_name]&.match_entry_type?(:list) &&
|
116
|
+
@feature_entries[list_name]&.feature?(feature_name) || false
|
117
|
+
end
|
117
118
|
end
|
118
119
|
end
|
119
120
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RgGen
|
4
|
+
module Core
|
5
|
+
module Builder
|
6
|
+
class GeneralFeatureEntry < FeatureEntryBase
|
7
|
+
include Base::SharedContext
|
8
|
+
|
9
|
+
def setup(base_feature, base_factory, context, &body)
|
10
|
+
@feature = Class.new(base_feature)
|
11
|
+
@factory = Class.new(base_factory)
|
12
|
+
attach_shared_context(context, @feature, @factory, self)
|
13
|
+
block_given? && Docile.dsl_eval(self, @name, &body)
|
14
|
+
end
|
15
|
+
|
16
|
+
def define_factory(&body)
|
17
|
+
@factory.class_exec(&body)
|
18
|
+
end
|
19
|
+
|
20
|
+
alias_method :factory, :define_factory
|
21
|
+
|
22
|
+
def define_feature(&body)
|
23
|
+
@feature.class_exec(&body)
|
24
|
+
end
|
25
|
+
|
26
|
+
alias_method :feature, :define_feature
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def entry_type_name
|
31
|
+
:general
|
32
|
+
end
|
33
|
+
|
34
|
+
def target_feature
|
35
|
+
@feature
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -53,6 +53,16 @@ module RgGen
|
|
53
53
|
current_shared_context(false)
|
54
54
|
end
|
55
55
|
|
56
|
+
def define_feature(feature_names, &body)
|
57
|
+
Array(feature_names).each do |feature_name|
|
58
|
+
do_proxy_call do |proxy|
|
59
|
+
proxy.body(body)
|
60
|
+
proxy.method_name(__method__)
|
61
|
+
proxy.feature_name(feature_name)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
56
66
|
def define_simple_feature(feature_names, &body)
|
57
67
|
Array(feature_names).each do |feature_name|
|
58
68
|
do_proxy_call do |proxy|
|
@@ -3,42 +3,27 @@
|
|
3
3
|
module RgGen
|
4
4
|
module Core
|
5
5
|
module Builder
|
6
|
-
class ListFeatureEntry
|
6
|
+
class ListFeatureEntry < FeatureEntryBase
|
7
7
|
include Base::SharedContext
|
8
8
|
|
9
9
|
def initialize(registry, name)
|
10
|
-
|
11
|
-
@name = name
|
10
|
+
super(registry, name)
|
12
11
|
@features = {}
|
13
12
|
end
|
14
13
|
|
15
|
-
attr_reader :registry
|
16
|
-
attr_reader :name
|
17
|
-
|
18
14
|
def setup(base_feature, base_factory, context, &body)
|
19
15
|
@base_feature = Class.new(base_feature)
|
20
16
|
@factory = Class.new(base_factory)
|
21
|
-
context
|
17
|
+
attach_shared_context(context, @base_feature, @factory, self)
|
22
18
|
block_given? && Docile.dsl_eval(self, @name, &body)
|
23
19
|
end
|
24
20
|
|
25
|
-
def match_entry_type?(entry_type)
|
26
|
-
entry_type == :list
|
27
|
-
end
|
28
|
-
|
29
21
|
def define_factory(&body)
|
30
22
|
@factory.class_exec(&body)
|
31
23
|
end
|
32
24
|
|
33
25
|
alias_method :factory, :define_factory
|
34
26
|
|
35
|
-
def build_factory(targets)
|
36
|
-
@factory.new(@name) do |f|
|
37
|
-
f.target_features(target_features(targets))
|
38
|
-
f.target_feature(@default_feature)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
27
|
def define_base_feature(&body)
|
43
28
|
body && @base_feature.class_exec(&body)
|
44
29
|
end
|
@@ -51,7 +36,7 @@ module RgGen
|
|
51
36
|
if context
|
52
37
|
feature.method_defined?(:shared_context) &&
|
53
38
|
(raise BuilderError.new('shared context has already been set'))
|
54
|
-
|
39
|
+
attach_shared_context(context, feature)
|
55
40
|
end
|
56
41
|
body && feature.class_exec(feature_name, &body)
|
57
42
|
end
|
@@ -83,15 +68,17 @@ module RgGen
|
|
83
68
|
|
84
69
|
private
|
85
70
|
|
86
|
-
def
|
87
|
-
|
88
|
-
target.attach_context(context)
|
89
|
-
end
|
71
|
+
def entry_type_name
|
72
|
+
:list
|
90
73
|
end
|
91
74
|
|
92
75
|
def target_features(targets)
|
93
76
|
targets && @features.slice(*targets) || @features
|
94
77
|
end
|
78
|
+
|
79
|
+
def target_feature
|
80
|
+
@default_feature
|
81
|
+
end
|
95
82
|
end
|
96
83
|
end
|
97
84
|
end
|
@@ -3,36 +3,28 @@
|
|
3
3
|
module RgGen
|
4
4
|
module Core
|
5
5
|
module Builder
|
6
|
-
class SimpleFeatureEntry
|
7
|
-
def initialize(registry, name)
|
8
|
-
@registry = registry
|
9
|
-
@name = name
|
10
|
-
end
|
11
|
-
|
12
|
-
attr_reader :registry
|
13
|
-
attr_reader :name
|
14
|
-
|
6
|
+
class SimpleFeatureEntry < FeatureEntryBase
|
15
7
|
def setup(base_feature, factory, context, &body)
|
16
8
|
@feature = define_feature(base_feature, context, &body)
|
17
9
|
@factory = factory
|
18
10
|
end
|
19
11
|
|
20
|
-
|
21
|
-
entry_type == :simple
|
22
|
-
end
|
12
|
+
private
|
23
13
|
|
24
|
-
def
|
25
|
-
|
14
|
+
def entry_type_name
|
15
|
+
:simple
|
26
16
|
end
|
27
17
|
|
28
|
-
private
|
29
|
-
|
30
18
|
def define_feature(base, context, &body)
|
31
19
|
feature = Class.new(base)
|
32
|
-
context
|
20
|
+
attach_shared_context(context, feature)
|
33
21
|
block_given? && feature.class_exec(@name, &body)
|
34
22
|
feature
|
35
23
|
end
|
24
|
+
|
25
|
+
def target_feature
|
26
|
+
@feature
|
27
|
+
end
|
36
28
|
end
|
37
29
|
end
|
38
30
|
end
|
@@ -7,6 +7,12 @@ module RgGen
|
|
7
7
|
end
|
8
8
|
|
9
9
|
module RaiseError
|
10
|
+
private
|
11
|
+
|
12
|
+
def error_exception
|
13
|
+
ConfigurationError
|
14
|
+
end
|
15
|
+
|
10
16
|
def error(message, input_value = nil)
|
11
17
|
position = input_value.position if input_value.respond_to?(:position)
|
12
18
|
raise ConfigurationError.new(message, position || @position)
|
data/lib/rggen/core/dsl.rb
CHANGED
@@ -18,12 +18,9 @@ module RgGen
|
|
18
18
|
@default_value
|
19
19
|
end
|
20
20
|
|
21
|
-
def
|
22
|
-
@
|
23
|
-
|
24
|
-
|
25
|
-
def allow_options?
|
26
|
-
@allow_options || false
|
21
|
+
def value_format(format = nil)
|
22
|
+
@value_format = format if format
|
23
|
+
@value_format
|
27
24
|
end
|
28
25
|
end
|
29
26
|
|
@@ -48,50 +45,39 @@ module RgGen
|
|
48
45
|
def process_input_value(input_value)
|
49
46
|
if passive_feature_factory?
|
50
47
|
input_value
|
51
|
-
elsif self.class.allow_options?
|
52
|
-
process_input_value_with_options(input_value)
|
53
48
|
else
|
54
|
-
|
49
|
+
process_active_input_value(input_value)
|
55
50
|
end
|
56
51
|
end
|
57
52
|
|
58
|
-
def
|
59
|
-
|
60
|
-
if
|
61
|
-
|
62
|
-
else
|
63
|
-
Array(input_value).then { |values| [values.first, values[1..]] }
|
53
|
+
def process_active_input_value(input_value)
|
54
|
+
parseed_value, options =
|
55
|
+
if self.class.value_format
|
56
|
+
parse_input_value(input_value, self.class.value_format)
|
64
57
|
end
|
65
|
-
|
66
|
-
InputValue.new(value, options || [], input_value.position)
|
67
|
-
end
|
68
|
-
|
69
|
-
def parse_string_value(input_value)
|
70
|
-
value, options = split_string(input_value, ':', 2)
|
71
|
-
[value, parse_option_string(options)]
|
58
|
+
override_input_value(input_value, parseed_value, options) || input_value
|
72
59
|
end
|
73
60
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
end
|
79
|
-
end
|
61
|
+
VALUE_PARSERS = {
|
62
|
+
value_with_options: ValueWithOptionsParser,
|
63
|
+
hash_list: HashListParser
|
64
|
+
}.freeze
|
80
65
|
|
81
|
-
def
|
82
|
-
|
66
|
+
def parse_input_value(input_value, value_format)
|
67
|
+
VALUE_PARSERS[value_format].new(error_exception).parse(input_value)
|
83
68
|
end
|
84
69
|
|
85
|
-
def
|
86
|
-
|
87
|
-
|
70
|
+
def override_input_value(input_value, parseed_value, options)
|
71
|
+
(convert_value(input_value, parseed_value) || parseed_value)
|
72
|
+
&.then { |v| InputValue.new(v, options, input_value.position) }
|
88
73
|
end
|
89
74
|
|
90
|
-
def convert_value(
|
75
|
+
def convert_value(input_value, parseed_value)
|
76
|
+
value = parseed_value || input_value.value
|
91
77
|
if empty_value?(value)
|
92
|
-
evaluate_defalt_value(position)
|
78
|
+
evaluate_defalt_value(input_value.position)
|
93
79
|
else
|
94
|
-
convert(value, position)
|
80
|
+
convert(value, input_value.position)
|
95
81
|
end
|
96
82
|
end
|
97
83
|
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RgGen
|
4
|
+
module Core
|
5
|
+
module InputBase
|
6
|
+
class HashListParser < InputValueParser
|
7
|
+
def parse(input_value)
|
8
|
+
list =
|
9
|
+
if string?(input_value)
|
10
|
+
split_string(input_value, /^\s*$/, 0)
|
11
|
+
elsif hash?(input_value) && !input_value.empty?
|
12
|
+
[input_value]
|
13
|
+
else
|
14
|
+
Array(input_value)
|
15
|
+
end
|
16
|
+
[list.map { |item| parse_hash(item, input_value) }]
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def parse_hash(item, input_value)
|
22
|
+
if string?(item)
|
23
|
+
parse_string_hash(item)
|
24
|
+
else
|
25
|
+
Hash(item)
|
26
|
+
end
|
27
|
+
rescue TypeError, ArgumentError
|
28
|
+
error "cannot convert #{item.inspect} into hash", input_value
|
29
|
+
end
|
30
|
+
|
31
|
+
def parse_string_hash(item)
|
32
|
+
split_string(item, /[,\n]/, 0)
|
33
|
+
.to_h { |element| split_string(element, ':', 2) }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RgGen
|
4
|
+
module Core
|
5
|
+
module InputBase
|
6
|
+
class InputValueParser
|
7
|
+
include Utility::TypeChecker
|
8
|
+
|
9
|
+
def initialize(exception)
|
10
|
+
@exception = exception
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def split_string(string, separator, limit)
|
16
|
+
string&.split(separator, limit)&.map(&:strip)
|
17
|
+
end
|
18
|
+
|
19
|
+
def error(message, input_value = nil)
|
20
|
+
position = input_value.position if input_value.respond_to?(:position)
|
21
|
+
raise @exception.new(message, position)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -23,16 +23,16 @@ module RgGen
|
|
23
23
|
|
24
24
|
def define(feature)
|
25
25
|
feature.class_exec(self) do |property|
|
26
|
-
define_method(property.name) do |*args, &block|
|
27
|
-
property.evaluate(self, args, &block)
|
26
|
+
define_method(property.name) do |*args, **keywords, &block|
|
27
|
+
property.evaluate(self, *args, **keywords, &block)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
def evaluate(feature, args, &block)
|
32
|
+
def evaluate(feature, *args, **keywords, &block)
|
33
33
|
feature.verify(@options[:verify]) if @options.key?(:verify)
|
34
34
|
if proxy_property?
|
35
|
-
proxy_property(feature, args, &block)
|
35
|
+
proxy_property(feature, *args, **keywords, &block)
|
36
36
|
else
|
37
37
|
default_property(feature)
|
38
38
|
end
|
@@ -55,7 +55,7 @@ module RgGen
|
|
55
55
|
].any?
|
56
56
|
end
|
57
57
|
|
58
|
-
def proxy_property(feature, args, &block)
|
58
|
+
def proxy_property(feature, *args, **keywords, &block)
|
59
59
|
receiver, method =
|
60
60
|
if @costom_property
|
61
61
|
[@costom_property.bind(feature), :call]
|
@@ -64,7 +64,7 @@ module RgGen
|
|
64
64
|
else
|
65
65
|
[feature, @options[:forward_to]]
|
66
66
|
end
|
67
|
-
receiver.__send__(method, *args, &block)
|
67
|
+
receiver.__send__(method, *args, **keywords, &block)
|
68
68
|
end
|
69
69
|
|
70
70
|
def default_property(feature)
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RgGen
|
4
|
+
module Core
|
5
|
+
module InputBase
|
6
|
+
class ValueWithOptionsParser < InputValueParser
|
7
|
+
def parse(input_value)
|
8
|
+
value, options =
|
9
|
+
if string?(input_value)
|
10
|
+
parse_string_value(input_value)
|
11
|
+
else
|
12
|
+
Array(input_value).then { |v| [v.first, v[1..]] }
|
13
|
+
end
|
14
|
+
[value, options || []]
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def parse_string_value(input_value)
|
20
|
+
value, option_string = split_string(input_value, ':', 2)
|
21
|
+
[value, parse_option_string(option_string)]
|
22
|
+
end
|
23
|
+
|
24
|
+
def parse_option_string(option_string)
|
25
|
+
split_string(option_string, /[,\n]/, 0)&.map do |option|
|
26
|
+
name_value = split_string(option, ':', 2)
|
27
|
+
name_value.size == 2 && name_value || name_value.first
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -55,18 +55,16 @@ module RgGen
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
def
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
end
|
69
|
-
super(node, obj)
|
58
|
+
def accept(node)
|
59
|
+
object = super
|
60
|
+
if override_object?(node)
|
61
|
+
file = node.filename
|
62
|
+
line = node.start_line + 1
|
63
|
+
column = node.start_column + 1
|
64
|
+
InputValue.new(object, Position.new(file, line, column))
|
65
|
+
else
|
66
|
+
object
|
67
|
+
end
|
70
68
|
end
|
71
69
|
|
72
70
|
private
|
@@ -100,10 +98,9 @@ module RgGen
|
|
100
98
|
return result if ::Psych::VERSION >= '3.2.0'
|
101
99
|
|
102
100
|
if result.match_class?(Hash)
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
end
|
101
|
+
result
|
102
|
+
.transform_keys!(&:to_sym)
|
103
|
+
.transform_values!(&method(:symbolize_names))
|
107
104
|
elsif result.match_class?(Array)
|
108
105
|
result.map! { |value| symbolize_names(value) }
|
109
106
|
end
|
@@ -7,6 +7,12 @@ module RgGen
|
|
7
7
|
end
|
8
8
|
|
9
9
|
module RaiseError
|
10
|
+
private
|
11
|
+
|
12
|
+
def error_exception
|
13
|
+
RegisterMapError
|
14
|
+
end
|
15
|
+
|
10
16
|
def error(message, input_value = nil)
|
11
17
|
position = input_value.position if input_value.respond_to?(:position)
|
12
18
|
raise RegisterMapError.new(message, position || @position)
|
@@ -4,6 +4,8 @@ module RgGen
|
|
4
4
|
module Core
|
5
5
|
module Utility
|
6
6
|
module CodeUtility
|
7
|
+
MacroDefinition = Struct.new(:name, :value)
|
8
|
+
|
7
9
|
class SourceFile
|
8
10
|
include CodeUtility
|
9
11
|
|
@@ -43,6 +45,15 @@ module RgGen
|
|
43
45
|
include_files([file])
|
44
46
|
end
|
45
47
|
|
48
|
+
def macro_definitions(macros)
|
49
|
+
@macro_definitions ||= []
|
50
|
+
@macro_definitions.concat(Array(macros))
|
51
|
+
end
|
52
|
+
|
53
|
+
def macro_definition(macro)
|
54
|
+
macro_definitions([macro])
|
55
|
+
end
|
56
|
+
|
46
57
|
def body(&block)
|
47
58
|
@bodies ||= []
|
48
59
|
@bodies << block
|
@@ -65,6 +76,7 @@ module RgGen
|
|
65
76
|
@file_header,
|
66
77
|
include_guard_header,
|
67
78
|
include_file_block,
|
79
|
+
macro_definition_block,
|
68
80
|
*Array(@bodies),
|
69
81
|
include_guard_footer
|
70
82
|
].compact
|
@@ -94,6 +106,19 @@ module RgGen
|
|
94
106
|
end
|
95
107
|
end
|
96
108
|
|
109
|
+
def macro_definition_block
|
110
|
+
@macro_definitions && lambda do
|
111
|
+
keyword = self.class.define_keyword
|
112
|
+
@macro_definitions.flat_map do |macro|
|
113
|
+
if macro.value.nil?
|
114
|
+
[keyword, space, macro.name, nl]
|
115
|
+
else
|
116
|
+
[keyword, space, macro.name, space, macro.value, nl]
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
97
122
|
def include_guard_footer
|
98
123
|
@guard_macro && (-> { self.class.endif_keyword })
|
99
124
|
end
|
data/lib/rggen/core/version.rb
CHANGED
data/lib/rggen/core.rb
CHANGED
@@ -52,6 +52,9 @@ require_relative 'core/input_base/input_matcher'
|
|
52
52
|
require_relative 'core/input_base/verifier'
|
53
53
|
require_relative 'core/input_base/property'
|
54
54
|
require_relative 'core/input_base/feature'
|
55
|
+
require_relative 'core/input_base/input_vaue_parser'
|
56
|
+
require_relative 'core/input_base/value_with_options_parser'
|
57
|
+
require_relative 'core/input_base/hash_list_parser'
|
55
58
|
require_relative 'core/input_base/feature_factory'
|
56
59
|
|
57
60
|
require_relative 'core/configuration/input_data'
|
@@ -99,6 +102,8 @@ require_relative 'core/builder/component_registry'
|
|
99
102
|
require_relative 'core/builder/loader_registry'
|
100
103
|
require_relative 'core/builder/input_component_registry'
|
101
104
|
require_relative 'core/builder/output_component_registry'
|
105
|
+
require_relative 'core/builder/feature_entry_base'
|
106
|
+
require_relative 'core/builder/general_feature_entry'
|
102
107
|
require_relative 'core/builder/simple_feature_entry'
|
103
108
|
require_relative 'core/builder/list_feature_entry'
|
104
109
|
require_relative 'core/builder/feature_registry'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rggen-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.29.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Taichi Ishitani
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: docile
|
@@ -111,7 +111,9 @@ files:
|
|
111
111
|
- lib/rggen/core/builder/builder.rb
|
112
112
|
- lib/rggen/core/builder/component_entry.rb
|
113
113
|
- lib/rggen/core/builder/component_registry.rb
|
114
|
+
- lib/rggen/core/builder/feature_entry_base.rb
|
114
115
|
- lib/rggen/core/builder/feature_registry.rb
|
116
|
+
- lib/rggen/core/builder/general_feature_entry.rb
|
115
117
|
- lib/rggen/core/builder/input_component_registry.rb
|
116
118
|
- lib/rggen/core/builder/layer.rb
|
117
119
|
- lib/rggen/core/builder/list_feature_entry.rb
|
@@ -144,14 +146,17 @@ files:
|
|
144
146
|
- lib/rggen/core/input_base/component_factory.rb
|
145
147
|
- lib/rggen/core/input_base/feature.rb
|
146
148
|
- lib/rggen/core/input_base/feature_factory.rb
|
149
|
+
- lib/rggen/core/input_base/hash_list_parser.rb
|
147
150
|
- lib/rggen/core/input_base/input_data.rb
|
148
151
|
- lib/rggen/core/input_base/input_matcher.rb
|
149
152
|
- lib/rggen/core/input_base/input_value.rb
|
150
153
|
- lib/rggen/core/input_base/input_value_extractor.rb
|
154
|
+
- lib/rggen/core/input_base/input_vaue_parser.rb
|
151
155
|
- lib/rggen/core/input_base/json_loader.rb
|
152
156
|
- lib/rggen/core/input_base/loader.rb
|
153
157
|
- lib/rggen/core/input_base/property.rb
|
154
158
|
- lib/rggen/core/input_base/toml_loader.rb
|
159
|
+
- lib/rggen/core/input_base/value_with_options_parser.rb
|
155
160
|
- lib/rggen/core/input_base/verifier.rb
|
156
161
|
- lib/rggen/core/input_base/yaml_loader.rb
|
157
162
|
- lib/rggen/core/options.rb
|
@@ -207,15 +212,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
207
212
|
requirements:
|
208
213
|
- - ">="
|
209
214
|
- !ruby/object:Gem::Version
|
210
|
-
version: '2.
|
215
|
+
version: '2.7'
|
211
216
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
212
217
|
requirements:
|
213
218
|
- - ">="
|
214
219
|
- !ruby/object:Gem::Version
|
215
220
|
version: '0'
|
216
221
|
requirements: []
|
217
|
-
rubygems_version: 3.
|
222
|
+
rubygems_version: 3.4.1
|
218
223
|
signing_key:
|
219
224
|
specification_version: 4
|
220
|
-
summary: rggen-core-0.
|
225
|
+
summary: rggen-core-0.29.0
|
221
226
|
test_files: []
|