Module: Bumbler::Bundler

Defined in:
lib/bumbler/bundler.rb

Class Method Summary collapse

Class Method Details

.gem_for_require(path) ⇒ Object

Returns which gem a require maps to, or nil.



6
7
8
# File 'lib/bumbler/bundler.rb', line 6

def gem_for_require(path)
  @require_map[path]
end

.read_bundler_environmentObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/bumbler/bundler.rb', line 21

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

  ::Bundler.environment.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

.require_finished(gem_name, path, time) ⇒ Object



14
15
16
17
18
19
# File 'lib/bumbler/bundler.rb', line 14

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

.require_started(gem_name) ⇒ Object



10
11
12
# File 'lib/bumbler/bundler.rb', line 10

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