Skip to content

Commit 3aa9222

Browse files
feat: load local dependencies from manifest.yaml
this circumvents the need to be explicit about what to require via RBS_TEST_OPT when a manifest.yaml is already present (as it's considered a recommendation for gems as per the collection.md doc page).
1 parent 505bd5c commit 3aa9222

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

lib/rbs/environment_loader.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ def add(path: nil, library: nil, version: nil, resolve_dependencies: true)
4949
case
5050
when path
5151
dirs << path
52+
53+
# search for manifest.yaml
54+
if (manifest = path.each_entry.find { |s| s.basename.to_s == "manifest.yaml" })
55+
local_lib = RBS::Collection::Sources::Local.new(path: path, base_directory: Pathname.pwd)
56+
local_lib.dependencies_of("", "")&.each do |dep|
57+
add(library: dep['name'], version: nil)
58+
end
59+
end
5260
when library
5361
if libs.add?(Library.new(name: library, version: version)) && resolve_dependencies
5462
resolve_dependencies(library: library, version: version)

test/rbs/environment_loader_test.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,22 @@ def test_loading_stdlib
8282
end
8383
end
8484

85+
def test_loading_stdlib_via_manifest
86+
mktmpdir do |path|
87+
path.join("manifest.yaml").write(<<-RBS)
88+
dependencies:
89+
- name: uri
90+
RBS
91+
loader = EnvironmentLoader.new
92+
loader.add(path: path)
93+
94+
env = Environment.new
95+
loader.load(env: env)
96+
97+
assert_operator env.class_decls, :key?, RBS::TypeName.parse("::URI")
98+
end
99+
end
100+
85101
def test_loading_library_from_gem_repo
86102
mktmpdir do |path|
87103
(path + "gems").mkdir

0 commit comments

Comments
 (0)