Class: Pipely::Bundler::Bundle

Inherits:
Object
  • Object
show all
Defined in:
lib/pipely/bundler/bundle.rb

Overview

Provides access to a bundle’s list of gems

Constant Summary collapse

SOURCE_TYPES =
%w[Bundler::Source::Git Bundler::Source::Path]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(vendor_dir, spec_set, locked_sources) ⇒ Bundle

Returns a new instance of Bundle.



25
26
27
28
29
30
31
32
33
# File 'lib/pipely/bundler/bundle.rb', line 25

def initialize(vendor_dir, spec_set, locked_sources)
  @spec_set = spec_set
  @locked_sources = locked_sources
  @vendor_dir = vendor_dir
  unless Dir.exists? @vendor_dir
    FileUtils.mkdir_p(@vendor_dir)
  end

end

Instance Attribute Details

#spec_setObject (readonly)

Returns the value of attribute spec_set.



11
12
13
# File 'lib/pipely/bundler/bundle.rb', line 11

def spec_set
  @spec_set
end

Class Method Details

.build(vendor_dir, groups = [:default], definition = ::Bundler.definition) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/pipely/bundler/bundle.rb', line 15

def self.build(vendor_dir,
               groups=[:default],
               definition=::Bundler.definition)
  new(
    vendor_dir,
    definition.specs_for(groups),
    definition.instance_variable_get(:@locked_sources)
  )
end

Instance Method Details

#gem_files(opts = {}) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/pipely/bundler/bundle.rb', line 35

def gem_files(opts = {})
  gem_packager = opts[:gem_packager] || GemPackager.new(@vendor_dir)
  gems_to_exclude = opts[:gems_to_exclude] || []

  gem_files = {}

  excluded_gems = lambda { |s| gems_to_exclude.include? s.name }
  merge_gem = lambda { |s| gem_files.merge!(gem_file(s, gem_packager)) }

  @spec_set.to_a.reject(&excluded_gems).each(&merge_gem)

  gem_files
end