Sha256: 08c3c0de6f62d9bef5dfa4faf404ab8b26deb4193015a721984e3baf704e4300

Contents?: true

Size: 1.2 KB

Versions: 14

Compression:

Stored size: 1.2 KB

Contents

require 'singleton'

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

        def has?(config_entry)
          gem_dir(config_entry).exist?
        end

        def versions(config_entry)
          gem_dir(config_entry).glob('*/').map { |path| path.basename.to_s }
        end

        def install(dest:, config_entry:, stdout:)
          # Do nothing because stdlib RBS is available by default
          name = config_entry['name']
          version = config_entry['version'] or raise
          from = gem_dir(config_entry) / version
          stdout.puts "Using #{name}:#{version} (#{from})"
        end

        def manifest_of(config_entry)
          version = config_entry['version'] or raise
          manifest_path = gem_dir(config_entry).join(version, 'manifest.yaml')
          YAML.safe_load(manifest_path.read) if manifest_path.exist?
        end

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

        private def gem_dir(config_entry)
          Repository::DEFAULT_STDLIB_ROOT.join(config_entry['name'])
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
rbs-2.6.0 lib/rbs/collection/sources/stdlib.rb
rbs-2.5.1 lib/rbs/collection/sources/stdlib.rb
rbs-2.5.0 lib/rbs/collection/sources/stdlib.rb
rbs-2.4.0 lib/rbs/collection/sources/stdlib.rb
rbs-2.3.2 lib/rbs/collection/sources/stdlib.rb
rbs-2.3.1 lib/rbs/collection/sources/stdlib.rb
rbs-2.3.0 lib/rbs/collection/sources/stdlib.rb
rbs-2.2.2 lib/rbs/collection/sources/stdlib.rb
rbs-2.2.1 lib/rbs/collection/sources/stdlib.rb
rbs-2.2.0 lib/rbs/collection/sources/stdlib.rb
rbs-2.1.0 lib/rbs/collection/sources/stdlib.rb
rbs-2.0.0 lib/rbs/collection/sources/stdlib.rb
rbs-2.0.0.pre2 lib/rbs/collection/sources/stdlib.rb
rbs-2.0.0.pre1 lib/rbs/collection/sources/stdlib.rb