Sha256: 64a838133551a4a93cb9f5459128d1242eae08e6aab97c1d190df3085651e929

Contents?: true

Size: 811 Bytes

Versions: 14

Compression:

Stored size: 811 Bytes

Contents

require_relative 'helper'

module Dply
  module Yum
    extend Helper

    def self.install(pkgs)
      return if installed?(pkgs)
      cmd install_command(pkgs)
      not_installed = not_installed(pkgs)
      if not_installed.size != 0
        error "following pkgs not installed: #{not_installed.join(" ")}"
      end
    end

    def self.installed?(pkgs)
      not_installed(pkgs).size == 0
    end

    class << self
      private

      def not_installed(pkgs)
        return [] if pkgs.empty?
        command = %w(rpm -V --noscripts --nodeps --nofiles)
        command.concat pkgs
        out = IO.popen(command).read
        out.scan(/^package (.*) is not installed$/).flatten
      end

      def install_command(pkgs)
        %w(yum install -y).concat(not_installed pkgs)
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
dply-0.3.13 lib/dply/yum.rb
dply-0.3.12 lib/dply/yum.rb
dply-0.3.11 lib/dply/yum.rb
dply-0.3.10 lib/dply/yum.rb
dply-0.3.9 lib/dply/yum.rb
dply-0.3.8 lib/dply/yum.rb
dply-0.3.7 lib/dply/yum.rb
dply-0.3.6 lib/dply/yum.rb
dply-0.3.5 lib/dply/yum.rb
dply-0.3.4 lib/dply/yum.rb
dply-0.3.3 lib/dply/yum.rb
dply-0.3.2 lib/dply/yum.rb
dply-0.3.1 lib/dply/yum.rb
dply-0.3.0 lib/dply/yum.rb