izzup 0.0.2 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/izzup/izzup.rb CHANGED
@@ -3,15 +3,17 @@ module Izzup
3
3
 
4
4
  # require these or fail with izzup error
5
5
  def self.demand(*args)
6
- args.each do |p|
7
- raise IzzupError, "#{self.name} dying because #{p} is not up" unless izzup(p)
6
+ IzzupArguments.new(args).each do |p,n|
7
+ raise IzzupError, "#{self.name} dying because #{n} instance(s) of #{p} not discovered" unless izzup(p,n)
8
8
  end
9
9
  end
10
10
 
11
11
  # see if they are up true/false
12
12
  def self.assert(*args)
13
13
  found = true
14
- args.each {|p| found = found && izzup(p)}
14
+ IzzupArguments.new(args).each do |p,n|
15
+ found = found && izzup(p,n)
16
+ end
15
17
  found
16
18
  end
17
19
 
@@ -0,0 +1,36 @@
1
+ module Izzup
2
+
3
+ class IzzupArguments < Hash
4
+
5
+ def initialize(args)
6
+ [args].each{|a|add_item(a)}
7
+ self
8
+ end
9
+
10
+ protected
11
+
12
+ def add_item(item, n=1)
13
+ n.is_a?(Fixnum) ? num = n : n = 1
14
+ if item.is_a?(Array)
15
+ add_array(item)
16
+ elsif item.is_a?(Hash)
17
+ add_hash(item)
18
+ else
19
+ self[item] = 0 unless self[item]
20
+ self[item] = self[item] + n
21
+ end
22
+ end
23
+
24
+ def add_array(array)
25
+ array.each{|a|add_item(a)}
26
+ end
27
+
28
+ def add_hash(hash)
29
+ hash.each do |i,n|
30
+ add_item(i,n)
31
+ end
32
+ end
33
+
34
+ end
35
+
36
+ end
data/lib/izzup/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Izzup
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1.0"
3
3
  end
data/lib/izzup.rb CHANGED
@@ -3,5 +3,6 @@ module Izzup
3
3
 
4
4
  require "izzup/izzup"
5
5
  require "izzup/izzup_error"
6
+ require "izzup/izzup_arguments"
6
7
 
7
8
  end
metadata CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
+ - 1
8
9
  - 0
9
- - 2
10
- version: 0.0.2
10
+ version: 0.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - max sharples
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-05 00:00:00 Z
18
+ date: 2011-09-06 00:00:00 Z
19
19
  dependencies: []
20
20
 
21
21
  description: use to ensure that required *nix processes are up when executing code
@@ -34,6 +34,7 @@ files:
34
34
  - izzup.gemspec
35
35
  - lib/izzup.rb
36
36
  - lib/izzup/izzup.rb
37
+ - lib/izzup/izzup_arguments.rb
37
38
  - lib/izzup/izzup_error.rb
38
39
  - lib/izzup/version.rb
39
40
  homepage: http://github.com/msharp/izzup