class Litterbox::CLI

CLI for litterbox

Public Instance Methods

build(path = '.') click to toggle source
# File lib/litterbox.rb, line 45
def build(path = '.')
  Litterbox::Habitat::Build.new(path).build
end
export(exporter = 'docker') click to toggle source
# File lib/litterbox.rb, line 72
def export(exporter = 'docker')
  path ||= find_last_build
  raise "Could not find last_build.env in #{locations}" unless path

  path = File.join(LAST_BUILD) unless path.include?(LAST_BUILD)
  last_build = Litterbox.last_build(
    path
  )

  Litterbox::Habitat::Export.new(
    File.join(plan_dir, 'results', last_build.pkg_artifact),
    exporter
  ).upload
end
upload(path = find_last_build) click to toggle source
# File lib/litterbox.rb, line 55
def upload(path = find_last_build)
  raise "Could not find last_build.env in #{locations}" unless path
  path = File.join(path, LAST_BUILD) unless path.include?(LAST_BUILD)
  last_build = Litterbox.last_build(
    path
  )
  plan_dir = path.dup
  plan_dir.slice! LAST_BUILD
  artifact = File.join(plan_dir, last_build.pkg_artifact)

  Litterbox::Habitat::Upload.new(
    artifact,
    ENV['HAB_AUTH_TOKEN']
  ).upload
end
version() click to toggle source
# File lib/litterbox.rb, line 50
def version
  puts Litterbox::VERSION
end

Private Instance Methods

find_last_build() click to toggle source
# File lib/litterbox.rb, line 89
def find_last_build
  locations = [
    File.join('.', 'results'),
    File.join('habitat', 'results')
  ]
  locations.each do |loc|
    return loc if File.exist?(File.join(loc, LAST_BUILD))
  end
end