Sha256: 496170c6084986967a25f83ddab2e5e6f94acdc329f72af422eb194bf0927170

Contents?: true

Size: 1.7 KB

Versions: 1

Compression:

Stored size: 1.7 KB

Contents

# DO NOT MODIFY THIS FILE

require 'digest/sha1'
require "rubygems"

<%= shared_helpers %>

module Bundler
  LOCKED_BY    = '<%= Bundler::VERSION %>'
  FINGERPRINT  = <%= gemfile_fingerprint.inspect %>
  SPECS        = [
    <% specs_for_lock_file.each do |spec| -%>
    <%= spec.inspect %>,
    <% end -%>
  ]
  AUTOREQUIRES = <%= autorequires_for_groups.inspect %>

  extend SharedHelpers

  def self.cripple_ruby_gems
    reverse_rubygems_kernel_mixin
    patch_rubygems
  end

  def self.match_fingerprint
    print = Digest::SHA1.hexdigest(File.read(File.expand_path('../../Gemfile', __FILE__)))
    unless print == FINGERPRINT
      abort 'Gemfile changed since you last locked. Please `bundle lock` to relock.'
    end
  end

  def self.setup(*groups)
    match_fingerprint
    SPECS.each do |spec|
      spec[:load_paths].each { |path| $LOAD_PATH.unshift path }
    end
  end

  def self.require(*groups)
    groups = [:default] if groups.empty?
    groups.each do |group|
      (AUTOREQUIRES[group] || []).each do |file, explicit|
        if explicit
          Kernel.require file
        else
          begin
            Kernel.require file
          rescue LoadError
          end
        end
      end
    end
  end

  def self.patch_rubygems
    specs = SPECS

    ::Kernel.send(:define_method, :gem) do |dep, *reqs|
      opts = reqs.last.is_a?(Hash) ? reqs.pop : {}

      dep  = dep.name if dep.respond_to?(:name)
      unless specs.any?  { |s| s[:name] == dep }
        e = Gem::LoadError.new "#{dep} is not part of the bundle. Add it to Gemfile."
        e.name = dep
        e.version_requirement = reqs
        raise e
      end

      true
    end
  end

  # Setup bundle when it's required.
  cripple_ruby_gems
  setup
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bundler-0.9.5 lib/bundler/templates/environment.erb