Module: Proscenium::BundledGems

Defined in:
lib/proscenium/bundled_gems.rb

Class Method Summary collapse

Class Method Details

.pathname_for(name) ⇒ Object



25
26
27
# File 'lib/proscenium/bundled_gems.rb', line 25

def pathname_for(name)
  (path = paths[name]) ? Pathname(path) : nil
end

.pathname_for!(name) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/proscenium/bundled_gems.rb', line 29

def pathname_for!(name)
  unless (path = pathname_for(name))
    raise "Gem `#{name}` not found in your Gemfile"
  end

  path
end

.pathsObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/proscenium/bundled_gems.rb', line 7

def paths
  @paths ||= begin
    specs = Bundler.load.specs.reject { |s| s.name == 'bundler' }.sort_by(&:name)

    raise 'No gems in your Gemfile' if specs.empty?

    bundle = {}
    specs.each do |s|
      bundle[s.name] = if s.name == 'proscenium'
                         Pathname(s.full_gem_path).join('lib/proscenium').to_s
                       else
                         s.full_gem_path
                       end
    end
    bundle
  end
end