Permalink
Browse files

Gibbler.digest now returns nil for an empty Array

  • Loading branch information...
1 parent 9da8329 commit 0133d513c574bb76e3b1bbedb6b43e091679965c @delano committed Apr 20, 2012
Showing with 3 additions and 1 deletion.
  1. +1 −0 CHANGES.txt
  2. +2 −1 lib/gibbler.rb
View
@@ -6,6 +6,7 @@ GIBBLER, CHANGES
* CHANGE: Gibbler is now a class which supplies the default standalone usage
* CHANGE: Ruby object mixins must now be explicitly loaded via "require 'gibbler/mixins'"
* CHANGE: Removed Gibbler.enable_debug/disable_debug
+* CHANGE: Gibbler.digest now returns nil for an empty Array
* ADDED: Gibbler.delimiter
View
@@ -233,7 +233,7 @@ def initialize *input
super input.first
else
input.collect!(&:to_s)
- super Gibbler.digest(input)
+ super Gibbler.digest(input) || ''
end
end
def digest_type
@@ -278,6 +278,7 @@ def debug?; @debug != false; end
# See: digest_type
def self.digest(input, digest_type=nil)
input = input.flatten.collect(&:to_s).join(delimiter) if ::Array === input
+ return if input.empty?
digest_type ||= @digest_type
input = [Gibbler.secret, input].join(delimiter) unless Gibbler.secret.nil?
dig = digest_type.hexdigest(input)

0 comments on commit 0133d51

Please sign in to comment.