Sha256: 11210952f0b13e358a45ccc4ec29be977786939919420e4ac31786d45cd90b63

Contents?: true

Size: 1.25 KB

Versions: 14

Compression:

Stored size: 1.25 KB

Contents

require 'singleton'

module RBS
  module Collection
    module Sources
      # Signatures that are inclduded in gem package as sig/ directory.
      class Rubygems
        include Singleton

        def has?(config_entry)
          gem_sig_path(config_entry)
        end

        def versions(config_entry)
          spec, _ = gem_sig_path(config_entry)
          spec or raise
          [spec.version.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_sig_path(config_entry)
          stdout.puts "Using #{name}:#{version} (#{from})"
        end

        def manifest_of(config_entry)
          _, sig_path = gem_sig_path(config_entry)
          sig_path or raise
          manifest_path = sig_path.join('manifest.yaml')
          YAML.safe_load(manifest_path.read) if manifest_path.exist?
        end

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

        private def gem_sig_path(config_entry)
          RBS::EnvironmentLoader.gem_sig_path(config_entry['name'], config_entry['version'])
        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/rubygems.rb
rbs-2.5.1 lib/rbs/collection/sources/rubygems.rb
rbs-2.5.0 lib/rbs/collection/sources/rubygems.rb
rbs-2.4.0 lib/rbs/collection/sources/rubygems.rb
rbs-2.3.2 lib/rbs/collection/sources/rubygems.rb
rbs-2.3.1 lib/rbs/collection/sources/rubygems.rb
rbs-2.3.0 lib/rbs/collection/sources/rubygems.rb
rbs-2.2.2 lib/rbs/collection/sources/rubygems.rb
rbs-2.2.1 lib/rbs/collection/sources/rubygems.rb
rbs-2.2.0 lib/rbs/collection/sources/rubygems.rb
rbs-2.1.0 lib/rbs/collection/sources/rubygems.rb
rbs-2.0.0 lib/rbs/collection/sources/rubygems.rb
rbs-2.0.0.pre2 lib/rbs/collection/sources/rubygems.rb
rbs-2.0.0.pre1 lib/rbs/collection/sources/rubygems.rb