Sha256: b60d09b4db9a21835872aecd6644a26e2402a98a26d64325888cc999611f3d07

Contents?: true

Size: 1.24 KB

Versions: 29

Compression:

Stored size: 1.24 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)
          unless path = lookup(name, version)
            RBS.logger.warn "`#{name}` is specified in rbs_collection.lock.yaml. But it is not found in #{REPO.dirs.join(",")}"
            return
          end
          manifest_path = path.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

29 entries across 29 versions & 1 rubygems

Version Path
rbs-3.7.0.dev.1 lib/rbs/collection/sources/stdlib.rb
rbs-3.6.1 lib/rbs/collection/sources/stdlib.rb
rbs-3.6.0 lib/rbs/collection/sources/stdlib.rb
rbs-3.6.0.pre.3 lib/rbs/collection/sources/stdlib.rb
rbs-3.6.0.pre.2 lib/rbs/collection/sources/stdlib.rb
rbs-3.6.0.pre.1 lib/rbs/collection/sources/stdlib.rb
rbs-3.6.0.dev.1 lib/rbs/collection/sources/stdlib.rb
rbs-3.5.3 lib/rbs/collection/sources/stdlib.rb
rbs-3.5.2 lib/rbs/collection/sources/stdlib.rb
rbs-3.5.1 lib/rbs/collection/sources/stdlib.rb
rbs-3.5.1.pre.1 lib/rbs/collection/sources/stdlib.rb
rbs-3.5.0 lib/rbs/collection/sources/stdlib.rb
rbs-3.5.0.pre.2 lib/rbs/collection/sources/stdlib.rb
rbs-3.5.0.pre.1 lib/rbs/collection/sources/stdlib.rb
rbs-3.4.4 lib/rbs/collection/sources/stdlib.rb
rbs-3.4.3 lib/rbs/collection/sources/stdlib.rb
rbs-3.4.2 lib/rbs/collection/sources/stdlib.rb
rbs-3.4.1 lib/rbs/collection/sources/stdlib.rb
rbs-3.4.0 lib/rbs/collection/sources/stdlib.rb
rbs-3.4.0.pre.1 lib/rbs/collection/sources/stdlib.rb