Sha256: 855cec83d1f44fee3eb72d8c763950cb67f6dcd1447d704f2532fb47d614a048

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 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
        Target.construct_env_loader(options: options)
      end

      def self.construct_env_loader(options:)
        repo = RBS::Repository.new(no_stdlib: options.vendor_path)
        options.repository_paths.each do |path|
          repo.add(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

1 entries across 1 versions & 1 rubygems

Version Path
steep-0.42.0 lib/steep/project/target.rb