Sha256: 752bb28e0561167ed46d99c712d17800a7941c561eab4f99177987dd52654048

Contents?: true

Size: 1.07 KB

Versions: 12

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

require 'singleton'

module RBS
  module Collection
    module Sources
      # signatures that are bundled in rbs gem under the stdlib/ directory
      class Stdlib
        include Base
        include Singleton

        REPO = Repository.default

        def has?(name, version)
          lookup(name, version)
        end

        def versions(name)
          REPO.gems[name].versions.keys.map(&:to_s)
        end

        def install(dest:, name:, version:, stdout:)
          # Do nothing because stdlib RBS is available by default
          from = lookup(name, version)
          stdout.puts "Using #{name}:#{version} (#{from})"
        end

        def manifest_of(name, version)
          manifest_path = (lookup(name, version) or raise).join('manifest.yaml')
          YAML.safe_load(manifest_path.read) if manifest_path.exist?
        end

        def to_lockfile
          {
            'type' => 'stdlib',
          }
        end

        private def lookup(name, version)
          REPO.lookup(name, version)
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
rbs-3.1.3 lib/rbs/collection/sources/stdlib.rb
rbs-3.1.2 lib/rbs/collection/sources/stdlib.rb
rbs-3.1.1 lib/rbs/collection/sources/stdlib.rb
rbs-3.1.0 lib/rbs/collection/sources/stdlib.rb
rbs-3.0.4 lib/rbs/collection/sources/stdlib.rb
rbs-3.0.3 lib/rbs/collection/sources/stdlib.rb
rbs-3.0.2 lib/rbs/collection/sources/stdlib.rb
rbs-3.0.1 lib/rbs/collection/sources/stdlib.rb
rbs-3.0.0 lib/rbs/collection/sources/stdlib.rb
rbs-3.0.0.dev.3 lib/rbs/collection/sources/stdlib.rb
rbs-3.0.0.dev.2 lib/rbs/collection/sources/stdlib.rb
rbs-3.0.0.dev.1 lib/rbs/collection/sources/stdlib.rb