Class: Pipely::Bundler::ProjectGem

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

Overview

Builds the project’s gem from gemspec and pulls in its dependencies via the gem’s bundle.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project_spec, vendor_dir) ⇒ ProjectGem

Returns a new instance of ProjectGem.



21
22
23
24
25
26
27
# File 'lib/pipely/bundler/project_gem.rb', line 21

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

Instance Attribute Details

#project_specObject (readonly)

Returns the value of attribute project_spec.



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

def project_spec
  @project_spec
end

Class Method Details

.load(vendor_dir) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/pipely/bundler/project_gem.rb', line 12

def self.load(vendor_dir)
  if gem_spec = Dir.glob("*.gemspec").first
    # project gem spec
    new(Gem::Specification::load(gem_spec), vendor_dir)
  else
    raise "Failed to find gemspec"
  end
end

Instance Method Details

#dependency_gem_files(bundle = Bundle.build(@vendor_dir)) ⇒ Object



34
35
36
37
38
39
# File 'lib/pipely/bundler/project_gem.rb', line 34

def dependency_gem_files(bundle=Bundle.build(@vendor_dir))
  # Always exclude bundler and the project gem
  gems_to_exclude = [ @project_spec.name, 'bundler' ]

  bundle.gem_files(gems_to_exclude: gems_to_exclude)
end

#gem_filesObject



29
30
31
32
# File 'lib/pipely/bundler/project_gem.rb', line 29

def gem_files
  # Project gem should be at the bottom of the dep list
  @gem_files ||= dependency_gem_files.merge(project_gem_file)
end

#project_gem_file(gem_packager = GemPackager.new(@vendor_dir)) ⇒ Object



41
42
43
# File 'lib/pipely/bundler/project_gem.rb', line 41

def project_gem_file(gem_packager=GemPackager.new(@vendor_dir))
  gem_packager.build_from_source(@project_spec.name, Dir.pwd)
end