rggen-core 0.30.0 → 0.31.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 977e436971681e3425cdb967c6a86d7debeb89fac6ab33db6e7ab1d831102b8f
4
- data.tar.gz: 9d49db2290dfdc7b5c7dfc4a0369a2428ed9606f6487cad4c956c7144d46319f
3
+ metadata.gz: 45a9b6397155e93d65c0c171ec0ac17440baac57ec595e26029c657c1f775766
4
+ data.tar.gz: a8da50f308ac9eb4ca9079571b69cbb5c8c630abc59f02962e5547f63605ef98
5
5
  SHA512:
6
- metadata.gz: 999522157b4878363182b31f22a3a12c73c6908409b043c972df3885e9908df66b7093b27bfbe90da30b5dfcebffdcbcdc2ccb1b11da87ebed244f071c991134
7
- data.tar.gz: 61149e6066502b04f73f525304745b7e555355c141944fb3e03a1043a6ab6761cd0637ffa90ca22c7d3e330d65020831031f525fa4a189b54c9834b78eccc551
6
+ metadata.gz: 8d6e431128bdeb4977c546a2911147666aa47f922e396bf2a575efafb569213511bb789ba39d3fbbb89e9fc24838f144fa91ff727118bb5ecaf57a96a3a45a51
7
+ data.tar.gz: afdbe15fec9f8b40ab17054113769b4d4cc3889942da24dc6eeb10aa147bd3e82e39cd69817b09c161ab1ed19b439472562db6d0d58729563756de0a49a9aa71
@@ -18,8 +18,8 @@ module RgGen
18
18
 
19
19
  def parse(path_or_name, version)
20
20
  @name, @path, @gemname, @version =
21
- if plugin_path?(path_or_name)
22
- [nil, path_or_name, *find_gemspec_by_path(path_or_name)]
21
+ if path_or_name == DEFAULT_PLUGSINS || plugin_path?(path_or_name)
22
+ [nil, path_or_name]
23
23
  else
24
24
  [
25
25
  path_or_name, get_plugin_path(path_or_name),
@@ -41,17 +41,7 @@ module RgGen
41
41
  private
42
42
 
43
43
  def plugin_path?(path_or_name)
44
- path_or_name == DEFAULT_PLUGSINS || File.ext(path_or_name) == 'rb'
45
- end
46
-
47
- def find_gemspec_by_path(path)
48
- Gem::Specification
49
- .each.find { |spec| match_gemspec_path?(spec, path) }
50
- .then { |spec| spec && [spec.name, spec.version] }
51
- end
52
-
53
- def match_gemspec_path?(gemspec, path)
54
- gemspec.full_require_paths.any?(&path.method(:start_with?))
44
+ File.ext(path_or_name) == 'rb'
55
45
  end
56
46
 
57
47
  def get_plugin_path(name)
@@ -93,9 +83,11 @@ module RgGen
93
83
  end
94
84
 
95
85
  def activate_plugin_by_name(plugin_name)
96
- target_plugin = @plugins.find { |plugin| plugin.name == plugin_name }
97
- target_plugin&.activate(@builder)
98
- target_plugin&.activate_additionally(@builder)
86
+ @plugins.find { |plugin| plugin.name == plugin_name }
87
+ &.then do |plugin|
88
+ plugin.activate(@builder)
89
+ plugin.activate_additionally(@builder)
90
+ end
99
91
  end
100
92
 
101
93
  def version_info
@@ -105,12 +97,46 @@ module RgGen
105
97
  private
106
98
 
107
99
  def read_plugin_file(info)
108
- info.gemname && gem(info.gemname, info.version)
100
+ activate_plugin_gem(info)
109
101
  require info.path
110
102
  rescue ::LoadError
111
103
  raise Core::PluginError.new("cannot load such plugin: #{info}")
112
104
  end
113
105
 
106
+ def activate_plugin_gem(info)
107
+ if (gemspec = find_gemspec(info))
108
+ gem gemspec.name, gemspec.version
109
+ elsif info.gemname
110
+ gem info.gemname, info.version
111
+ end
112
+ end
113
+
114
+ def find_gemspec(info)
115
+ if info.path == DEFAULT_PLUGSINS
116
+ find_default_plugins_gemspec
117
+ elsif info.gemname
118
+ find_gemspec_by_name(info.gemname, info.version)
119
+ else
120
+ find_gemspec_by_path(info.path)
121
+ end
122
+ end
123
+
124
+ def find_default_plugins_gemspec
125
+ find_gemspec_by_name('rggen', "~> #{MAJOR}.#{MINOR}.0")
126
+ end
127
+
128
+ def find_gemspec_by_name(name, version)
129
+ Gem::Specification
130
+ .find_all_by_name(name, version)
131
+ .find { |s| !s.has_conflicts? }
132
+ end
133
+
134
+ def find_gemspec_by_path(path)
135
+ Gem::Specification
136
+ .each
137
+ .find { |spec| spec.full_require_paths.any?(&path.method(:start_with?)) }
138
+ end
139
+
114
140
  def merge_plugins(plugins, no_default_plugins)
115
141
  [
116
142
  *default_plugins(no_default_plugins),
@@ -126,8 +152,7 @@ module RgGen
126
152
  def load_default_plugins?(no_default_plugins)
127
153
  return false if no_default_plugins
128
154
  return false if ENV.key?('RGGEN_NO_DEFAULT_PLUGINS')
129
- return false if Gem.find_files(DEFAULT_PLUGSINS).empty?
130
- true
155
+ !find_default_plugins_gemspec.nil?
131
156
  end
132
157
 
133
158
  def plugins_from_env
@@ -6,7 +6,7 @@ module RgGen
6
6
  class ComponentFactory < InputBase::ComponentFactory
7
7
  private
8
8
 
9
- def create_input_data(&block)
9
+ def create_input_data(*_args, &block)
10
10
  InputData.new(valid_value_lists, &block)
11
11
  end
12
12
  end
@@ -24,14 +24,15 @@ module RgGen
24
24
 
25
25
  def preprocess(args)
26
26
  if root_factory?
27
- [*args[0..-2], load_files(args.last)]
27
+ [*args[0..-2], load_files(args)]
28
28
  else
29
29
  args
30
30
  end
31
31
  end
32
32
 
33
- def load_files(files)
34
- create_input_data do |input_data|
33
+ def load_files(args)
34
+ files = args.last
35
+ create_input_data(*args[0..-2]) do |input_data|
35
36
  files.each { |file| load_file(file, input_data) }
36
37
  end
37
38
  end
@@ -50,7 +51,7 @@ module RgGen
50
51
  .transform_values(&->(f) { f.valid_value_list })
51
52
  end
52
53
 
53
- def create_input_data(&block)
54
+ def create_input_data(*_args, &block)
54
55
  end
55
56
 
56
57
  def create_features(component, *sources)
@@ -4,7 +4,7 @@ module RgGen
4
4
  module Core
5
5
  module InputBase
6
6
  class InputData
7
- def initialize(layer, valid_value_lists)
7
+ def initialize(layer, valid_value_lists, *_args)
8
8
  @layer = layer
9
9
  @valid_value_lists = valid_value_lists
10
10
  @values = Hash.new(NAValue)
@@ -87,8 +87,8 @@ module RgGen
87
87
  caller_location.path.include?('docile')
88
88
  end
89
89
 
90
- def create_child_data(layer, &block)
91
- child_data_class.new(layer, @valid_value_lists, &block)
90
+ def create_child_data(layer, *args, &block)
91
+ child_data_class.new(layer, @valid_value_lists, *args, &block)
92
92
  end
93
93
 
94
94
  def child_data_class
@@ -12,8 +12,8 @@ module RgGen
12
12
  configuration
13
13
  end
14
14
 
15
- def create_input_data(&block)
16
- InputData.new(:root, valid_value_lists, &block)
15
+ def create_input_data(configuration, &block)
16
+ InputData.new(:root, valid_value_lists, configuration, &block)
17
17
  end
18
18
 
19
19
  def find_child_factory(_configuration, register_map)
@@ -38,9 +38,18 @@ module RgGen
38
38
  bit_field: BitField
39
39
  }.freeze
40
40
 
41
- def initialize(layer, valid_value_list)
41
+ def initialize(layer, valid_value_list, configuration)
42
42
  extend(LAYER_EXTENSIONS[layer])
43
- super
43
+ @configuration = configuration
44
+ super(layer, valid_value_list)
45
+ end
46
+
47
+ attr_reader :configuration
48
+
49
+ private
50
+
51
+ def create_child_data(layer, &block)
52
+ super(layer, @configuration, &block)
44
53
  end
45
54
  end
46
55
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module RgGen
4
4
  module Core
5
- VERSION = '0.30.0'
5
+ VERSION = '0.31.2'
6
6
  MAJOR, MINOR, PATCH = VERSION.split('.').map(&:to_i)
7
7
  end
8
8
  end
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.30.0
4
+ version: 0.31.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taichi Ishitani
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-28 00:00:00.000000000 Z
11
+ date: 2023-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docile
@@ -222,8 +222,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
222
222
  - !ruby/object:Gem::Version
223
223
  version: '0'
224
224
  requirements: []
225
- rubygems_version: 3.4.10
225
+ rubygems_version: 3.4.19
226
226
  signing_key:
227
227
  specification_version: 4
228
- summary: rggen-core-0.30.0
228
+ summary: rggen-core-0.31.2
229
229
  test_files: []