Skip to content

Commit 0ff8dc1

Browse files
committed
Add bundled gems to alumnus
See also ruby/gem_rbs_collection#782
1 parent cbf08cf commit 0ff8dc1

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

lib/rbs/collection/config/lockfile_generator.rb

Lines changed: 23 additions & 4 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:)
@@ -165,15 +175,20 @@ def generate
165175
# The `bigdecimal-math` is never released as a gem.
166176
# Therefore, `assign_gem` should not be called.
167177
RBS.logger.info {
168-
"`#{name}` is included in the RBS dependencies of `#{from_gem}`, but the type definition as a stdlib in rbs-gem is deprecated. Delete `#{name}` from the RBS dependencies of `#{from_gem}`."
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}`."
169180
}
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
170185
return
171186
when *ALUMNI_STDLIBS.keys
172187
version = ALUMNI_STDLIBS.fetch(name)
173188
if from_gem
174189
# From `dependencies:` of a `manifest.yaml` of a gem
175190
source = find_source(name: name) or raise
176-
if source.is_a?(Sources::Stdlib)
191+
if source.is_a?(Sources::Stdlib) && version
177192
RBS.logger.warn {
178193
"`#{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."
179194
}
@@ -187,7 +202,11 @@ def generate
187202
else
188203
# From `gems:` of a `rbs_collection.yaml`
189204
RBS.logger.warn {
190-
"`#{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
191210
}
192211
end
193212
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)