Skip to content

Commit 3a74376

Browse files
authored
Merge pull request #2288 from ksss/alumni-bundled-gems
Add bundled gems to alumnus
2 parents b9f044f + 0ff8dc1 commit 3a74376

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

lib/rbs/collection/config/lockfile_generator.rb

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,17 @@ module RBS
44
module Collection
55
class Config
66
class LockfileGenerator
7-
ALUMNI_STDLIBS = { "mutex_m" => ">= 0.3.0" }
7+
ALUMNI_STDLIBS = {
8+
"mutex_m" => ">= 0.3.0",
9+
"abbrev" => nil,
10+
"base64" => nil,
11+
"bigdecimal" => nil,
12+
"csv" => nil,
13+
"minitest" => nil,
14+
"net-smtp" => nil,
15+
"nkf" => nil,
16+
"observer" => nil,
17+
}
818

919
class GemfileLockMismatchError < StandardError
1020
def initialize(expected:, actual:)
@@ -161,12 +171,24 @@ def generate
161171
return if lockfile.gems.key?(name)
162172

163173
case name
174+
when 'bigdecimal-math'
175+
# The `bigdecimal-math` is never released as a gem.
176+
# Therefore, `assign_gem` should not be called.
177+
RBS.logger.info {
178+
from = from_gem || "rbs_collection.yaml"
179+
"`#{name}` is included in the RBS dependencies of `#{from}`, but the type definition as a stdlib in rbs-gem is deprecated. Delete `#{name}` from the RBS dependencies of `#{from}`."
180+
}
181+
source = find_source(name: name)
182+
if source&.is_a?(Sources::Stdlib)
183+
lockfile.gems[name] = { name: name, version: "0", source: source }
184+
end
185+
return
164186
when *ALUMNI_STDLIBS.keys
165187
version = ALUMNI_STDLIBS.fetch(name)
166188
if from_gem
167189
# From `dependencies:` of a `manifest.yaml` of a gem
168190
source = find_source(name: name) or raise
169-
if source.is_a?(Sources::Stdlib)
191+
if source.is_a?(Sources::Stdlib) && version
170192
RBS.logger.warn {
171193
"`#{name}` is included in the RBS dependencies of `#{from_gem}`, but the type definition as a stdlib in rbs-gem is deprecated. Add `#{name}` (#{version}) to the dependency of your Ruby program to use the gem-bundled type definition."
172194
}
@@ -180,7 +202,11 @@ def generate
180202
else
181203
# From `gems:` of a `rbs_collection.yaml`
182204
RBS.logger.warn {
183-
"`#{name}` as a stdlib in rbs-gem is deprecated. Add `#{name}` (#{version}) to the dependency of your Ruby program to use the gem-bundled type definition."
205+
if version
206+
"`#{name}` as a stdlib in rbs-gem is deprecated. Add `#{name}` (#{version}) to the dependency of your Ruby program to use the gem-bundled type definition."
207+
else
208+
"`#{name}` as a stdlib in rbs-gem is deprecated. Delete `#{name}` from the RBS dependencies in your rbs_collection.yaml."
209+
end
184210
}
185211
end
186212
end

sig/collection/config/lockfile_generator.rbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module RBS
44
class LockfileGenerator
55
# Name of stdlibs that was rbs-bundled stdlib but is now a gem.
66
#
7-
ALUMNI_STDLIBS: Hash[String, String]
7+
ALUMNI_STDLIBS: Hash[String, String?]
88

99
class GemfileLockMismatchError < StandardError
1010
@expected: Pathname

0 commit comments

Comments
 (0)