class Builderator::Interface

Base class for integration interfaces

Public Class Methods

berkshelf() click to toggle source
# File lib/builderator/interface/berkshelf.rb, line 8
def berkshelf
  @berkshelf ||= Berkshelf.new
end
command(arg = nil) click to toggle source
# File lib/builderator/interface.rb, line 15
def command(arg = nil)
  @command = arg unless arg.nil?
  @command
end
from_gem(arg = nil) click to toggle source
# File lib/builderator/interface.rb, line 20
def from_gem(arg = nil)
  @from_gem = arg unless arg.nil?
  @from_gem || @command
end
packer() click to toggle source
# File lib/builderator/interface/packer.rb, line 7
def packer
  @packer ||= Packer.new
end
template(arg = nil) click to toggle source
# File lib/builderator/interface.rb, line 25
def template(arg = nil)
  @template = arg unless arg.nil?
  @template
end
vagrant() click to toggle source
# File lib/builderator/interface/vagrant.rb, line 7
def vagrant
  @vagrant ||= Vagrant.new
end

Public Instance Methods

bundled?() click to toggle source

Is vagrant in this bundle?

# File lib/builderator/interface.rb, line 32
def bundled?
  Gem.loaded_specs.key?(self.class.from_gem)
end
clean() click to toggle source
# File lib/builderator/interface.rb, line 63
def clean
  source.unlink
end
command()
Alias for: which
directory() click to toggle source
# File lib/builderator/interface.rb, line 44
def directory
  Util.workspace
end
render() click to toggle source
# File lib/builderator/interface.rb, line 48
def render
  ERB.new(Util.source_path(self.class.template).binread,
          nil, '-', '@output_buffer').result(Config.instance_eval('binding'))
end
source() click to toggle source
# File lib/builderator/interface.rb, line 53
def source
  fail 'Interface does not provide a source!'
end
which() click to toggle source
# File lib/builderator/interface.rb, line 36
def which
  return self.class.command if bundled?

  ## Not in the bundle. Use system path
  `which #{self.class.command}`.chomp.tap { |path| fail "Unable to locate a #{self.class.command} executable" if path.empty? }
end
Also aliased as: command
write() click to toggle source
# File lib/builderator/interface.rb, line 57
def write
  directory.mkpath
  source.write(render)
  self
end