class Bundler::Definition

def self.from_gemfile(gemfile)

def self.from_gemfile(gemfile)
  gemfile = Pathname.new(gemfile).expand_path
  unless gemfile.file?
    raise GemfileNotFound, "#{gemfile} not found"
  end
  Dsl.evaluate(gemfile)
end

def self.from_lock(lockfile)

def self.from_lock(lockfile)
  locked_definition = Locked.new(YAML.load_file(lockfile))
  hash = Digest::SHA1.hexdigest(File.read("#{Bundler.root}/Gemfile"))
  unless locked_definition.hash == hash
    raise GemfileError, "You changed your Gemfile after locking. Please relock using `bundle lock`"
  end
  locked_definition
end

def groups

def groups
  dependencies.map { |d| d.groups }.flatten.uniq
end

def initialize(dependencies, sources)

def initialize(dependencies, sources)
  @dependencies = dependencies
  @sources = sources
end

def local_index

def local_index
  @local_index ||= begin
    index = Index.new
    sources.each do |source|
      next unless source.respond_to?(:local_specs)
      index = source.local_specs.merge(index)
    end
    index = Index.from_installed_gems.merge(index)
    Index.from_cached_specs("#{Bundler.bundle_path}/cache").merge(index)
  end
end