rggen-core 0.31.0 → 0.31.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0969d51d5ab39e5bf98ff6d7cb44ae8b9b4a7a9efea6d2c0eb47a8cd9685b4c2'
4
- data.tar.gz: f5e71796fd8de70124491d20b3501680968edf8f12c15f3fc6e729791f7bdfd0
3
+ metadata.gz: 45a9b6397155e93d65c0c171ec0ac17440baac57ec595e26029c657c1f775766
4
+ data.tar.gz: a8da50f308ac9eb4ca9079571b69cbb5c8c630abc59f02962e5547f63605ef98
5
5
  SHA512:
6
- metadata.gz: 9c27bfff2f272e80ca16331a3071560962e80051e0c4e566ae277bff99a5097cd32ccc87519f4c37a466bacd826da60c882b3e032492439d7c282437fc4d4aeb
7
- data.tar.gz: b8b2365ac6de6ec997dbb3054d91a46e5c761218460ec416dcaf126e35549f38643f94d446c3b865bdc9e0346a4d7e7ead38e0665e9b09510ef7d6083013cbd5
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  module RgGen
4
4
  module Core
5
- VERSION = '0.31.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.31.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-09-12 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.17
225
+ rubygems_version: 3.4.19
226
226
  signing_key:
227
227
  specification_version: 4
228
- summary: rggen-core-0.31.0
228
+ summary: rggen-core-0.31.2
229
229
  test_files: []