Sha256: 9265b976992d062c6c069f10b404a20dff9fa69288d7d111860147bbbb5d7e0e

Contents?: true

Size: 869 Bytes

Versions: 1

Compression:

Stored size: 869 Bytes

Contents

module Grub
  class SpecFinder

    attr_reader :gem_lines

    def initialize(gem_lines)
      @gem_lines = gem_lines
    end

    def find_specs
      gem_lines.each do |line|
        matching_specs = Gem::Dependency.new(line.name).matching_specs
        line.spec = matching_specs.first if matching_specs.any?
      end

      gems_to_fetch = gem_lines.select { |gem_line| gem_line.spec.nil? }

      if gems_to_fetch.any?
        fetcher = Bundler::Fetcher.new(Gem.sources.first.uri)
        versions, _ = fetcher.send(:fetch_dependency_remote_specs, gems_to_fetch.collect(&:name))
        gems_to_fetch.each do |gem_line|
          print "."
          version = versions.find{ |v| v.first == gem_line.name }[1]
          spec = fetcher.fetch_spec([gem_line.name, version])
          gem_line.spec = spec
        end
        print "\n"
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
grub-0.0.1 lib/grub/spec_finder.rb