Sha256: 0c81c0750abaaaf5e1cf14d937aaead570959226ba6c62e0361e369a5f89ce5d

Contents?: true

Size: 1.37 KB

Versions: 5

Compression:

Stored size: 1.37 KB

Contents

module Steep
  class Project
    class Target
      attr_reader :name
      attr_reader :options

      attr_reader :source_pattern
      attr_reader :signature_pattern

      def initialize(name:, options:, source_pattern:, signature_pattern:)
        @name = name
        @options = options
        @source_pattern = source_pattern
        @signature_pattern = signature_pattern

        @source_files = {}
        @signature_files = {}
      end

      def possible_source_file?(path)
        source_pattern =~ path
      end

      def possible_signature_file?(path)
        signature_pattern =~ path
      end

      def new_env_loader(project:)
        Target.construct_env_loader(options: options, project: project)
      end

      def self.construct_env_loader(options:, project:)
        repo = RBS::Repository.new(no_stdlib: options.vendor_path)
        options.repository_paths.each do |path|
          repo.add(project.absolute_path(path))
        end

        loader = RBS::EnvironmentLoader.new(
          core_root: options.vendor_path ? nil : RBS::EnvironmentLoader::DEFAULT_CORE_ROOT,
          repository: repo
        )
        loader.add(path: options.vendor_path) if options.vendor_path
        options.libraries.each do |lib|
          name, version = lib.split(/:/, 2)
          loader.add(library: name, version: version)
        end

        loader
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
steep-0.45.0 lib/steep/project/target.rb
steep-0.44.1 lib/steep/project/target.rb
steep-0.44.0 lib/steep/project/target.rb
steep-0.43.1 lib/steep/project/target.rb
steep-0.43.0 lib/steep/project/target.rb