Sha256: 5809d4b72800649e8425d7e40e52447e6abb8a2936c787cbcc06ec9a568f8771

Contents?: true

Size: 802 Bytes

Versions: 1

Compression:

Stored size: 802 Bytes

Contents

# -*- ruby-indent-level: 2; -*-

require_relative "../lib/hysh"

def dpkg_installed1(package_names = nil)
  Hysh.out_lines ->{
    Hysh.pipe ['dpkg', '-l'],
      if package_names
	['egrep', "(#{package_names.join '|'})"]
      else
	['cat']
      end
  }
end

def dpkg_installed2(package_names = nil)
  Hysh.out_lines ->{
    Hysh.pipe ['dpkg', '-l'] {
      proc_line = if package_names
		    ->l{
		      if package_names.any? { |pkg|
			   l.index pkg
			 }
			l
		      end
		    }
		  else
		    ->l{ l }
		  end
      Hysh.filter_line &proc_line
    }
  }
end

def dpkg_installed3(package_names = nil)
  hysh_script {
    if package_names
      pipe ['dpkg', '-l'] {
	filter_line { |l|
	  package_names.any? { |pkg|
	    l.index pkg
	  } && l
	}
      }
    else
      dpkg '-l'
    end
  }
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hysh-0.0.2 test/dpkg_test.rb