Sha256: 530195c28cdf264c262ad52c3622ce9b49a47ce1d08eaa55ccc802661b43c51f

Contents?: true

Size: 937 Bytes

Versions: 15

Compression:

Stored size: 937 Bytes

Contents

require 'dply/helper'

module Dply
  class Yum

    include Helper

    def initialize(pkgs, sudo: false)
      @pkgs = pkgs
      @sudo = sudo
    end

    def install
      return if installed?
      command = ""
      command << "sudo -n " if @sudo
      command << "yum install -y #{not_installed_pkgs.join(' ')}"
      cmd command
      not_installed = query_not_installed
      if not_installed.size != 0
        error "following pkgs not installed: #{not_installed.join(" ")}"
      end
    end

    def installed?
      not_installed_pkgs.size == 0
    end

    private

    def pkgs_str
      @pkgs.join " "
    end

    def not_installed_pkgs
      @not_installed_pkgs ||= query_not_installed
    end

    def query_not_installed
      return [] if pkgs_str.strip.empty?
      command = "rpm -V --noscripts --nodeps --nofiles #{pkgs_str}"
      matches = `#{command}`.scan(/^package (.*) is not installed$/)
    end

  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
dply-0.2.19 lib/dply/yum.rb
dply-0.2.18 lib/dply/yum.rb
dply-0.2.17 lib/dply/yum.rb
dply-0.2.16 lib/dply/yum.rb
dply-0.2.15 lib/dply/yum.rb
dply-0.2.14 lib/dply/yum.rb
dply-0.2.13 lib/dply/yum.rb
dply-0.2.11 lib/dply/yum.rb
dply-0.2.10 lib/dply/yum.rb
dply-0.2.9 lib/dply/yum.rb
dply-0.2.8 lib/dply/yum.rb
dply-0.2.7 lib/dply/yum.rb
dply-0.2.6 lib/dply/yum.rb
dply-0.2.5 lib/dply/yum.rb
dply-0.2.4 lib/dply/yum.rb