Class: Yoda::Store::Project::RbsLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/yoda/store/project/rbs_loader.rb

Overview

Find registry file for the current project settings.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project) ⇒ RbsLoader

Returns a new instance of RbsLoader.

Parameters:



12
13
14
# File 'lib/yoda/store/project/rbs_loader.rb', line 12

def initialize(project)
  @project = project
end

Instance Attribute Details

#projectProject (readonly)

Returns:



9
10
11
# File 'lib/yoda/store/project/rbs_loader.rb', line 9

def project
  @project
end

Instance Method Details

#rbs_environmentRBS::Environment

Returns:

  • (RBS::Environment)


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/yoda/store/project/rbs_loader.rb', line 17

def rbs_environment
  @rbs_environment ||= begin
    repository = RBS::Repository.new
    project.config.rbs_repository_paths.each do |repo_path|
      pathname = Pathname(repo_path).expand_path(project.root_path)
      repository.add(pathname)
    end

    loader = RBS::EnvironmentLoader.new(repository: repository)
    project.config.rbs_signature_paths.each do |sig_path|
      pathname = Pathname(sig_path).expand_path(project.root_path)
      loader.add(path: pathname)
    end

    project.config.rbs_libraries.each do |library|
      loader.add(library: library)
    end

    RBS::Environment.from_loader(loader).resolve_type_names
  end
end