class Akabei::Omakase::Config

Constants

FILE_NAME
REQUIRED_ATTRIBUTES
REQUIRED_BUILD_ATTRIBUTES

Public Class Methods

load() click to toggle source
# File lib/akabei/omakase/config.rb, line 14
def self.load
  config = new
  config.load(FILE_NAME)
  config
end
new() click to toggle source
# File lib/akabei/omakase/config.rb, line 24
def initialize
  @config = {}
end

Public Instance Methods

abs_path(arch) click to toggle source
# File lib/akabei/omakase/config.rb, line 108
def abs_path(arch)
  repo_path(arch).join("#{@config['name']}.abs.tar.gz")
end
builds() click to toggle source
# File lib/akabei/omakase/config.rb, line 92
def builds
  @config['builds']
end
db_path(arch) click to toggle source
# File lib/akabei/omakase/config.rb, line 100
def db_path(arch)
  repo_path(arch).join("#{@config['name']}.db")
end
files_path(arch) click to toggle source
# File lib/akabei/omakase/config.rb, line 104
def files_path(arch)
  repo_path(arch).join("#{@config['name']}.files")
end
load(path) click to toggle source
# File lib/akabei/omakase/config.rb, line 28
def load(path)
  @config.merge!(SafeYAML.load_file(path, deserialize_symbols: true))
  true
rescue Errno::ENOENT
  false
end
logdest() click to toggle source
# File lib/akabei/omakase/config.rb, line 72
def logdest
  Pathname.new(@config['logdest'])
end
name() click to toggle source
# File lib/akabei/omakase/config.rb, line 64
def name
  @config['name']
end
package_dir(package_name) click to toggle source
# File lib/akabei/omakase/config.rb, line 80
def package_dir(package_name)
  pkgbuild.join(package_name)
end
package_signer() click to toggle source
# File lib/akabei/omakase/config.rb, line 84
def package_signer
  Signer.get(@config['package_key'])
end
pkgbuild() click to toggle source
# File lib/akabei/omakase/config.rb, line 76
def pkgbuild
  Pathname.new(@config['pkgbuild'])
end
repo_path(arch) click to toggle source
# File lib/akabei/omakase/config.rb, line 96
def repo_path(arch)
  Pathname.new(@config['name']).join('os', arch)
end
repo_signer() click to toggle source
# File lib/akabei/omakase/config.rb, line 88
def repo_signer
  Signer.get(@config['repo_key'])
end
srcdest() click to toggle source
# File lib/akabei/omakase/config.rb, line 68
def srcdest
  Pathname.new(@config['srcdest'])
end
validate!() click to toggle source
# File lib/akabei/omakase/config.rb, line 45
def validate!
  REQUIRED_ATTRIBUTES.each do |attr|
    unless @config.has_key?(attr)
      raise InvalidConfig.new("#{attr.inspect} is required")
    end
  end
  unless @config['builds'].is_a?(Hash)
    raise InvalidConfig.new('"builds" must be a Hash')
  end
  @config['builds'].each do |arch, config_file|
    REQUIRED_BUILD_ATTRIBUTES.each do |attr|
      unless config_file.has_key?(attr)
        raise InvalidConfig.new("builds.#{arch}: #{attr.inspect} is required")
      end
    end
  end
  true
end