Sha256: 77b276ffc563fa6b70bf0572bbca2497575f0f247d61260636d8fa83375b48a4
Contents?: true
Size: 1.19 KB
Versions: 16
Compression:
Stored size: 1.19 KB
Contents
require 'yaml' require_relative 'helper' require_relative 'yum' module Dply class Pkgs include Helper attr_reader :runtime, :build, :all def initialize(pkgs_yml) @pkgs_yml = pkgs_yml read_config end def install(build_mode: false) pkgs = build_mode ? @all : @runtime Yum.install pkgs end def installed?(build_mode: false) pkgs = build_mode ? @all : @runtime Yum.installed? pkgs end private def read_config @read ||= begin config = load_yml error "data from pkgs.yml not a hash" if not config.is_a? Hash @runtime = config["pkgs"] || [] @build = config["build_pkgs"] || [] @all = @runtime + @build @all.each { |i| validate! i } true end end def load_yml if not File.readable? @pkgs_yml logger.debug "skipping yum pkgs" return {} end YAML.safe_load(File.read(@pkgs_yml)) || {} rescue error "error loading pkgs list" end def validate!(pkg) msg = "invalid pkg name #{pkg}" error msg if pkg =~ /\.rpm\z/i error msg if not pkg =~ /\A[A-Za-z_0-9\.\-]+\z/ return true end end end
Version data entries
16 entries across 16 versions & 1 rubygems