rggen-core 0.25.2 → 0.26.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 +1 -1
- data/lib/rggen/core/builder/component_registry.rb +1 -1
- data/lib/rggen/core/builder/plugin_manager.rb +71 -50
- data/lib/rggen/core/facets.rb +1 -0
- data/lib/rggen/core/input_base/input_data.rb +1 -3
- data/lib/rggen/core/input_base/loader.rb +3 -5
- data/lib/rggen/core/input_base/yaml_loader.rb +6 -15
- data/lib/rggen/core/options.rb +2 -2
- data/lib/rggen/core/output_base/file_writer.rb +1 -1
- data/lib/rggen/core/register_map/hash_loader.rb +5 -4
- data/lib/rggen/core/version.rb +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe3a65999b49b800216dea110ca47e81c71cf4fe0a65626f50526be374647713
|
4
|
+
data.tar.gz: 160dbda800f4fef46bbe18ef34810851082d09271eb7754b6b4508eb4f56c8fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eae55af6cdaa6eff67f15ef508dcd32af950d72f18621d0b8769011957c9c6a72c9f3c41557d197a0c1e9fec25ecaff34364f3518cd04c12f22bdb6ee8efa6af
|
7
|
+
data.tar.gz: 3d030a72ade1067dbb7450ff30ef4cffc3d97430e73a4ea96f9fb310a5cb633e314f1a9b280d4c4e615b1fce2ace5f5456f2881bd76a18fa05cef60420989ada
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -44,7 +44,7 @@ Feedbacks, bug reports, questions and etc. are wellcome! You can post them by us
|
|
44
44
|
|
45
45
|
## Copyright & License
|
46
46
|
|
47
|
-
Copyright © 2017-
|
47
|
+
Copyright © 2017-2022 Taichi Ishitani. RgGen::Core is licensed under the [MIT License](https://opensource.org/licenses/MIT), see [LICENSE](LICENSE) for futher details.
|
48
48
|
|
49
49
|
## Code of Conduct
|
50
50
|
|
@@ -22,26 +22,80 @@ module RgGen
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
class PluginInfo
|
26
|
+
attr_reader :name
|
27
|
+
attr_reader :setup_path
|
28
|
+
attr_reader :gem_name
|
29
|
+
attr_reader :version
|
30
|
+
|
31
|
+
def parse(setup_path_or_name, version)
|
32
|
+
setup_path_or_name = setup_path_or_name.to_s.strip
|
33
|
+
@name, @setup_path, @gem_name, @version =
|
34
|
+
if setup_file_directly_given?(setup_path_or_name)
|
35
|
+
[nil, setup_path_or_name, *find_plugin_gem(setup_path_or_name)]
|
36
|
+
else
|
37
|
+
[
|
38
|
+
setup_path_or_name, get_setup_path(setup_path_or_name),
|
39
|
+
extract_gem_name(setup_path_or_name), version
|
40
|
+
]
|
41
|
+
end
|
42
|
+
self
|
43
|
+
end
|
44
|
+
|
45
|
+
def to_s
|
46
|
+
if name && version
|
47
|
+
"#{name} (#{version})"
|
48
|
+
elsif name
|
49
|
+
name
|
50
|
+
else
|
51
|
+
setup_path
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def setup_file_directly_given?(setup_path_or_name)
|
58
|
+
File.ext(setup_path_or_name) == 'rb' ||
|
59
|
+
File.basename(setup_path_or_name, '.*') == 'setup'
|
60
|
+
end
|
61
|
+
|
62
|
+
def find_plugin_gem(setup_path)
|
63
|
+
gemspec =
|
64
|
+
Gem::Specification
|
65
|
+
.each.find { |spec| match_gemspec?(spec, setup_path) }
|
66
|
+
gemspec && [gemspec.name, gemspec.version]
|
67
|
+
end
|
68
|
+
|
69
|
+
def match_gemspec?(gemspec, setup_path)
|
70
|
+
gemspec.full_require_paths.any?(&setup_path.method(:start_with?))
|
71
|
+
end
|
72
|
+
|
73
|
+
def extract_gem_name(plugin_name)
|
74
|
+
plugin_name.split('/', 2).first
|
75
|
+
end
|
76
|
+
|
77
|
+
def get_setup_path(plugin_name)
|
78
|
+
base, sub_directory = plugin_name.split('/', 2)
|
79
|
+
base = base.sub(/^rggen[-_]/, '').tr('-', '_')
|
80
|
+
File.join(*['rggen', base, sub_directory, 'setup'].compact)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
25
84
|
class PluginManager
|
26
85
|
def initialize(builder)
|
27
86
|
@builder = builder
|
28
87
|
@plugins = []
|
29
88
|
end
|
30
89
|
|
31
|
-
def load_plugin(setup_path_or_name)
|
32
|
-
|
33
|
-
|
34
|
-
if setup_file_directly_given?(setup_path_or_name)
|
35
|
-
[setup_path_or_name, extract_root_dir(setup_path_or_name)]
|
36
|
-
else
|
37
|
-
[get_setup_path(setup_path_or_name), nil]
|
38
|
-
end
|
39
|
-
read_setup_file(setup_path, setup_path_or_name, root_dir)
|
90
|
+
def load_plugin(setup_path_or_name, version = nil)
|
91
|
+
info = PluginInfo.new.parse(setup_path_or_name, version)
|
92
|
+
read_setup_file(info)
|
40
93
|
end
|
41
94
|
|
42
95
|
def load_plugins(plugins, no_default_plugins, activation = true)
|
43
96
|
RgGen.builder(@builder)
|
44
|
-
merge_plugins(plugins, no_default_plugins)
|
97
|
+
merge_plugins(plugins, no_default_plugins)
|
98
|
+
.each { |plugin| load_plugin(*plugin) }
|
45
99
|
activation && activate_plugins
|
46
100
|
end
|
47
101
|
|
@@ -64,45 +118,11 @@ module RgGen
|
|
64
118
|
|
65
119
|
private
|
66
120
|
|
67
|
-
def
|
68
|
-
|
69
|
-
|
70
|
-
end
|
71
|
-
|
72
|
-
def extract_root_dir(setup_path)
|
73
|
-
Pathname
|
74
|
-
.new(setup_path)
|
75
|
-
.ascend.find(&method(:rggen_dir?))
|
76
|
-
&.parent
|
77
|
-
&.to_s
|
78
|
-
end
|
79
|
-
|
80
|
-
def rggen_dir?(path)
|
81
|
-
path.each_filename.to_a[-2..-1] == ['lib', 'rggen']
|
82
|
-
end
|
83
|
-
|
84
|
-
def get_setup_path(name)
|
85
|
-
base, sub_directory = name.split('/', 2)
|
86
|
-
base = base.sub(/^rggen[-_]/, '').tr('-', '_')
|
87
|
-
File.join(*['rggen', base, sub_directory, 'setup'].compact)
|
88
|
-
end
|
89
|
-
|
90
|
-
def read_setup_file(setup_path, setup_path_or_name, root_dir)
|
91
|
-
if setup_path == DEFAULT_PLUGSINS
|
92
|
-
gem 'rggen', DEFAULT_PLUGSINS_VERSION
|
93
|
-
elsif root_dir
|
94
|
-
$LOAD_PATH.unshift(root_dir)
|
95
|
-
end
|
96
|
-
|
97
|
-
require setup_path
|
121
|
+
def read_setup_file(info)
|
122
|
+
info.gem_name && gem(info.gem_name, info.version)
|
123
|
+
require info.setup_path
|
98
124
|
rescue ::LoadError
|
99
|
-
|
100
|
-
if setup_path_or_name == setup_path
|
101
|
-
"cannot load such plugin: #{setup_path_or_name}"
|
102
|
-
else
|
103
|
-
"cannot load such plugin: #{setup_path_or_name} (#{setup_path})"
|
104
|
-
end
|
105
|
-
raise Core::PluginError.new(message)
|
125
|
+
raise Core::PluginError.new("cannot load such plugin: #{info}")
|
106
126
|
end
|
107
127
|
|
108
128
|
def merge_plugins(plugins, no_default_plugins)
|
@@ -114,7 +134,6 @@ module RgGen
|
|
114
134
|
end
|
115
135
|
|
116
136
|
DEFAULT_PLUGSINS = 'rggen/setup'
|
117
|
-
DEFAULT_PLUGSINS_VERSION = "~> #{MAJOR}.#{MINOR}.0"
|
118
137
|
|
119
138
|
def default_plugins(no_default_plugins)
|
120
139
|
load_default_plugins?(no_default_plugins) && DEFAULT_PLUGSINS || nil
|
@@ -129,7 +148,9 @@ module RgGen
|
|
129
148
|
|
130
149
|
def plugins_from_env
|
131
150
|
ENV['RGGEN_PLUGINS']
|
132
|
-
&.split(':')
|
151
|
+
&.split(':')
|
152
|
+
&.reject(&:blank?)
|
153
|
+
&.map { |entry| entry.split(',', 2) }
|
133
154
|
end
|
134
155
|
|
135
156
|
def plugin?(plugin_module)
|
data/lib/rggen/core/facets.rb
CHANGED
@@ -42,11 +42,9 @@ module RgGen
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def format_sub_layer(read_data, input_data, layer, file)
|
45
|
-
format_sub_layer_data(read_data, layer, file)
|
46
|
-
|
47
|
-
|
48
|
-
format(data, input_data.child(sub_layer), sub_layer, file)
|
49
|
-
end
|
45
|
+
format_sub_layer_data(read_data, layer, file)&.each do |(sub_layer, data)|
|
46
|
+
format(data, input_data.child(sub_layer), sub_layer, file)
|
47
|
+
end
|
50
48
|
end
|
51
49
|
|
52
50
|
def format_layer_data(_read_data, _layer, _file)
|
@@ -6,22 +6,13 @@ module RgGen
|
|
6
6
|
module YAMLLoader
|
7
7
|
private
|
8
8
|
|
9
|
-
if RUBY_VERSION >= '2.6.0'
|
10
|
-
def yaml_safe_load(yaml, file)
|
11
|
-
YAML.safe_load(
|
12
|
-
yaml,
|
13
|
-
permitted_classes: [Symbol], aliases: true, filename: file,
|
14
|
-
symbolize_names: true
|
15
|
-
)
|
16
|
-
end
|
17
|
-
else
|
18
|
-
def yaml_safe_load(yaml, file)
|
19
|
-
YAML.safe_load(yaml, [Symbol], [], true, file, symbolize_names: true)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
9
|
def load_yaml(file)
|
24
|
-
|
10
|
+
yaml = File.binread(file)
|
11
|
+
YAML.safe_load(
|
12
|
+
yaml,
|
13
|
+
permitted_classes: [Symbol], aliases: true,
|
14
|
+
filename: file, symbolize_names: true
|
15
|
+
)
|
25
16
|
end
|
26
17
|
end
|
27
18
|
end
|
data/lib/rggen/core/options.rb
CHANGED
@@ -109,9 +109,9 @@ module RgGen
|
|
109
109
|
end
|
110
110
|
|
111
111
|
Options.add_option(:plugins) do |option|
|
112
|
-
option.long_option '--plugin PLUGIN'
|
112
|
+
option.long_option '--plugin PLUGIN[:VERSION]'
|
113
113
|
option.default { [] }
|
114
|
-
option.action { |value, options| options[:plugins] << value }
|
114
|
+
option.action { |value, options| options[:plugins] << value.split(':', 2) }
|
115
115
|
option.description 'Load a RgGen plugin ' \
|
116
116
|
"(name of plugin/path to 'setup.rb' file)"
|
117
117
|
end
|
@@ -47,12 +47,12 @@ module RgGen
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def format_array_sub_layer_data(read_data, layer, file)
|
50
|
-
read_data.each_with_object(
|
50
|
+
read_data.each_with_object([]) do |data, sub_layer_data|
|
51
51
|
format_hash_sub_layer_data(data, layer, file, sub_layer_data)
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
-
def format_hash_sub_layer_data(read_data, layer, file, sub_layer_data =
|
55
|
+
def format_hash_sub_layer_data(read_data, layer, file, sub_layer_data = [])
|
56
56
|
convert_to_hash(read_data, file)
|
57
57
|
.slice(*SUB_LAYER_KEYS[layer])
|
58
58
|
.each { |k, v| merge_sub_layer_data(sub_layer_data, layer, k, v) }
|
@@ -61,9 +61,10 @@ module RgGen
|
|
61
61
|
|
62
62
|
def merge_sub_layer_data(sub_layer_data, layer, key, value)
|
63
63
|
if SUB_LAYER_KEY_MAP[layer].key?(key)
|
64
|
-
|
64
|
+
sub_layer_data
|
65
|
+
.concat([SUB_LAYER_KEY_MAP[layer][key]].product(value))
|
65
66
|
else
|
66
|
-
|
67
|
+
sub_layer_data << [key, value]
|
67
68
|
end
|
68
69
|
end
|
69
70
|
|
data/lib/rggen/core/version.rb
CHANGED
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.26.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: 2022-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: docile
|
@@ -195,6 +195,7 @@ licenses:
|
|
195
195
|
metadata:
|
196
196
|
bug_tracker_uri: https://github.com/rggen/rggen-core/issues
|
197
197
|
mailing_list_uri: https://groups.google.com/d/forum/rggen
|
198
|
+
rubygems_mfa_required: 'true'
|
198
199
|
source_code_uri: https://github.com/rggen/rggen-core
|
199
200
|
wiki_uri: https://github.com/rggen/rggen/wiki
|
200
201
|
post_install_message:
|
@@ -205,15 +206,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
205
206
|
requirements:
|
206
207
|
- - ">="
|
207
208
|
- !ruby/object:Gem::Version
|
208
|
-
version: '2.
|
209
|
+
version: '2.6'
|
209
210
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
210
211
|
requirements:
|
211
212
|
- - ">="
|
212
213
|
- !ruby/object:Gem::Version
|
213
214
|
version: '0'
|
214
215
|
requirements: []
|
215
|
-
rubygems_version: 3.
|
216
|
+
rubygems_version: 3.3.3
|
216
217
|
signing_key:
|
217
218
|
specification_version: 4
|
218
|
-
summary: rggen-core-0.
|
219
|
+
summary: rggen-core-0.26.0
|
219
220
|
test_files: []
|