Sha256: 72dedba0cf32f4fe2eb1f5e8bc2db215380e4ed7556fee9d66a981c8a7676109

Contents?: true

Size: 718 Bytes

Versions: 3

Compression:

Stored size: 718 Bytes

Contents

require "set"
require "rails4_upgrade/gem_dependency"
require "rails4_upgrade/gem"

module Rails4Upgrade
  class Gemfile
    def initialize(lockfile_io)
      @lockfile = Bundler::LockfileParser.new(lockfile_io.read)

      @gems = Hash[@lockfile.specs.map { |spec|
        [
          spec.name,
          Gem.new(
            spec.name,
            spec.version,
            spec.dependencies.map { |dependency| GemDependency.new(dependency.name, dependency.requirement) }
          )
        ]
      }]
    end

    def dependencies
      @dependencies ||= @lockfile.dependencies.map { |dependency|
        self[dependency.name]
      }.compact
    end

    def [](gem_name)
      @gems[gem_name]
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rails4_upgrade-0.5.0 lib/rails4_upgrade/gemfile.rb
rails4_upgrade-0.0.5 lib/rails4_upgrade/gemfile.rb
rails4_upgrade-0.0.4 lib/rails4_upgrade/gemfile.rb