Module: Izzup

Defined in:
lib/izzup.rb,
lib/izzup/izzup.rb,
lib/izzup/version.rb,
lib/izzup/izzup_error.rb,
lib/izzup/izzup_arguments.rb

Defined Under Namespace

Classes: IzzupArguments, IzzupError

Constant Summary collapse

VERSION =
"0.2.0"

Class Method Summary collapse

Class Method Details

.assert(*args) ⇒ Object

see if they are up true/false



11
12
13
14
15
16
17
# File 'lib/izzup/izzup.rb', line 11

def self.assert(*args)
    found = true
    IzzupArguments.new(args).each do |p,n|
        found = found && izzup(p,n)
    end
    found
end

.insist(*args) ⇒ Object

require these or fail with izzup error



4
5
6
7
8
# File 'lib/izzup/izzup.rb', line 4

def self.insist(*args)
    IzzupArguments.new(args).each do |p,n|
        raise IzzupError, "#{self.name} died because #{n} instance(s) of #{p} not available" unless izzup(p,n) 
    end
end

.izzup(process, count = 1) ⇒ Object

test for given number of processes



20
21
22
23
24
# File 'lib/izzup/izzup.rb', line 20

def self.izzup(process, count=1)
    up = %x{ps ax | grep #{process} | grep -v grep | wc -l}.strip()
    not_nix! if up.length == 0 # windows will return "" from ps command
    up.to_i == count
end

.not_nix!Object

Raises:

  • (StandardError)


26
27
28
# File 'lib/izzup/izzup.rb', line 26

def self.not_nix!
    raise StandardError, "#{self.name} will probably only work on a *NIX machine"
end