Sha256: 2d8e7b1fad4a841b00aee493cdd0b9a5aad92e35371d61f0715d286aa70f4bc8

Contents?: true

Size: 1.19 KB

Versions: 2

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true
module Bumbler
  module Bundler
    class << self
      # Returns which gem a require maps to, or nil.
      def gem_for_require(path)
        @require_map[path]
      end

      def require_started(gem_name)
        Bumbler::Progress.item_started(gem_name)
      end

      def require_finished(gem_name, path, time)
        @gem_state[gem_name][path] = true
        if @gem_state[gem_name].values.all?
          Bumbler::Progress.item_finished(gem_name, time)
        end
      end

      def read_bundler_environment
        @require_map = {}
        @gem_state = {}

        ::Bundler.load.current_dependencies.each do |spec|
          gem_name = spec.name
          @gem_state[gem_name] = {}

          # TODO: this is horrible guess-work ... we need to get the gems load-path instead
          paths =
            if !spec.autorequire || spec.autorequire == [true]
              [gem_name]
            else
              spec.autorequire
            end

          paths.each do |path|
            @require_map[path] = gem_name
            @gem_state[gem_name][path] = false
          end

          Bumbler::Progress.register_item(gem_name)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bumbler-0.9.0 lib/bumbler/bundler.rb
bumbler-0.8.0 lib/bumbler/bundler.rb