Sha256: 2f6060793d753a221180521d7821b27b87de4aad9cf8afaefa227981b8b68df0

Contents?: true

Size: 1.79 KB

Versions: 33

Compression:

Stored size: 1.79 KB

Contents

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

      attr_reader :source_pattern
      attr_reader :signature_pattern
      attr_reader :code_diagnostics_config

      def initialize(name:, options:, source_pattern:, signature_pattern:, code_diagnostics_config:)
        @name = name
        @options = options
        @source_pattern = source_pattern
        @signature_pattern = signature_pattern
        @code_diagnostics_config = code_diagnostics_config
      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.paths.customized_stdlib?)

        if options.paths.stdlib_root
          repo.add(project.absolute_path(options.paths.stdlib_root))
        end

        options.paths.repo_paths.each do |path|
          repo.add(project.absolute_path(path))
        end

        core_root_path =
          if options.paths.customized_core?
            if options.paths.core_root
              project.absolute_path(options.paths.core_root)
            end
          else
            RBS::EnvironmentLoader::DEFAULT_CORE_ROOT
          end

        loader = RBS::EnvironmentLoader.new(core_root: core_root_path, repository: repo)

        options.libraries.each do |lib|
          name, version = lib.split(/:/, 2)
          name or raise
          loader.add(library: name, version: version)
        end
        loader.add_collection(options.collection_lock) if options.collection_lock

        loader
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
steep-1.8.3 lib/steep/project/target.rb
steep-1.8.2 lib/steep/project/target.rb
steep-1.8.1 lib/steep/project/target.rb
steep-1.8.0 lib/steep/project/target.rb
steep-1.8.0.pre.2 lib/steep/project/target.rb
steep-1.8.0.pre.1 lib/steep/project/target.rb
steep-1.8.0.dev.2 lib/steep/project/target.rb
steep-1.8.0.dev.1 lib/steep/project/target.rb
steep-1.7.1 lib/steep/project/target.rb
steep-1.7.0 lib/steep/project/target.rb
steep-1.7.0.dev.3 lib/steep/project/target.rb
steep-1.7.0.dev.2 lib/steep/project/target.rb
steep-1.7.0.dev.1 lib/steep/project/target.rb
steep-1.6.0 lib/steep/project/target.rb
steep-1.6.0.pre.4 lib/steep/project/target.rb
steep-1.6.0.pre.3 lib/steep/project/target.rb
steep-1.6.0.pre.2 lib/steep/project/target.rb
steep-1.6.0.pre.1 lib/steep/project/target.rb
steep-1.5.3 lib/steep/project/target.rb
steep-1.5.2 lib/steep/project/target.rb