class Buildizer::Buildizer

Attributes

debug[R]
options[R]
package_path[R]
work_path[R]

Public Class Methods

new(cli: nil, **kwargs) click to toggle source
# File lib/buildizer/buildizer.rb, line 30
def initialize(cli: nil, **kwargs)
  @cli = cli
  @options = kwargs
  @package_path = Pathname.new(ENV['BUILDIZER_PATH'] || '.').expand_path
  @work_path = Pathname.new(ENV['BUILDIZER_WORK_PATH'] || '~/.buildizer').expand_path
  @debug = ENV['BUILDIZER_DEBUG'].nil? ? options[:debug] : ENV['BUILDIZER_DEBUG'].to_s.on?
  @color = interactive? ? options[:color] : false
end

Public Instance Methods

build() click to toggle source
# File lib/buildizer/buildizer.rb, line 55
def build
  builder.build
end
builder() click to toggle source
# File lib/buildizer/buildizer.rb, line 75
def builder
  @builder ||= begin
    build_type = buildizer_conf['build_type']
    raise Error, error: :input_error, message: "Buildizer build_type is not defined" unless build_type
    klass = {fpm: Builder::Fpm,
             native: Builder::Native,
             patch: Builder::Patch}[build_type.to_s.to_sym]
    raise Error, error: :input_error, message: "unknown build_type '#{build_type}'" unless klass
    klass.new(self)
  end
end
deploy() click to toggle source
# File lib/buildizer/buildizer.rb, line 67
def deploy
  builder.deploy
end
interactive?() click to toggle source
# File lib/buildizer/buildizer.rb, line 39
def interactive?
  @cli and $stdout.isatty
end
prepare() click to toggle source
# File lib/buildizer/buildizer.rb, line 51
def prepare
  builder.prepare
end
secure_option(name, ask: nil, default: nil) click to toggle source
# File lib/buildizer/buildizer.rb, line 43
def secure_option(name, ask: nil, default: nil)
  if interactive? and ask
    @cli.ask(ask, echo: false, default: default).tap{puts}
  else
    options.fetch(name.to_sym, default)
  end
end
test() click to toggle source
# File lib/buildizer/buildizer.rb, line 59
def test
  raise(
    Error, message: "cannot run test shell in non interactive mode"
  ) if options[:shell] and not interactive?

  builder.test
end
verify() click to toggle source
# File lib/buildizer/buildizer.rb, line 71
def verify
  builder.verify
end