From b12fb287f233011caf3a0cf67fac8674d4f5da0f Mon Sep 17 00:00:00 2001 From: delano Date: Wed, 7 Oct 2009 11:16:04 -0400 Subject: [PATCH] ADDED: Out of the box support for Regexp (Gibbler::String) --- CHANGES.txt | 2 +- README.rdoc | 16 +++---- lib/gibbler.rb | 97 ++++++++++--------------------------------- lib/gibbler/object.rb | 1 + 4 files changed, 31 insertions(+), 85 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index b9e590d..6625841 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -10,7 +10,7 @@ GIBBLER, CHANGES * CHANGE: Gibbler::Object#gibbler returns the value of gibbler_cache when the object is frozen, without calculation. * ADDED: Gibbler::Object#freeze to create digest before freezing. - +* ADDED: Out of the box support for Regexp (Gibbler::String) #### 0.6.3 (2009-09-30) ################################# diff --git a/README.rdoc b/README.rdoc index c6b86b2..cdbbbe2 100644 --- a/README.rdoc +++ b/README.rdoc @@ -127,12 +127,16 @@ Gibbler::String creates a digest based on the name of the class and the output o This code is hella fresh (est 2009-06-25). It's barely tested and the interface may change, but it's fun to play with. I'll happily accept patches. Some things to keep in mind: * Gibbler history is not suitable for very large objects since it keeps complete copies of the object in memory. This is a very early implementation of this feature so don't rely on it for production code. -* Digest calculation may change between non-trivial releases. -* There has been very little testing for concurrency issues. (Anyone interested?) - +* Digest calculation may change between minor releases (e.g. 0.5 to 0.6, etc) == News +=== 2009-10-07: Support for freezing and Regexp + +In 0.6.4, all Gibbler objects will create a new digest when obj.freeze is called. All subsequent calls to obj.gibbler will return the most recent digest without having to run the calculation again. + +I've also added support for Regexp out of the box. + === 2009-07-20: Digest change for instances of Class, Module, and Proc Digest calculation has changed for Class, Module, and Proc objects. Digests created with Gibbler 0.5.x and earlier will not match the ones created by 0.6. @@ -142,15 +146,11 @@ Digest calculation has changed for Class, Module, and Proc objects. Digests crea Also note that this change affects the digests for Hashes and Arrays that contain instances of Class, Module, or Proc. -=== 2009-07-17: Improved support for Symbol and Fixnum - -With the upgrade to Attic 0.4, the gibbled? method and object history is now available for Symbol and Fixnum objects. - == Known Issues * gibbler or gibbled? must be called at least once before gibbled? will be able to return a useful value (otherwise there is no previous digest value to compare to) -* Digests for Bignum objects are different between Ruby 1.8, 1.9, and JRuby. Does anyone know why? +* Digests for Bignum objects are different between Ruby and JRuby. Does anyone know why? * Digests for Proc objects are different between Ruby 1.8 and 1.9 because Proc.arity returns different values and 1.8 has no lambda? method. diff --git a/lib/gibbler.rb b/lib/gibbler.rb index a0e3486..9d8ea1e 100644 --- a/lib/gibbler.rb +++ b/lib/gibbler.rb @@ -434,84 +434,29 @@ def __gibbler(h=self) end -class Proc - include Gibbler::Block -end - -class Hash - include Gibbler::Hash -end - -class Array - include Gibbler::Array -end - -class String - include Gibbler::String -end - -class Symbol - include Gibbler::String -end +class Proc; include Gibbler::Block; end +class Hash; include Gibbler::Hash; end +class Array; include Gibbler::Array; end +class String; include Gibbler::String; end +class Symbol; include Gibbler::String; end +class Class; include Gibbler::Object; end +class Module; include Gibbler::Object; end +class Fixnum; include Gibbler::String; end +class Bignum; include Gibbler::String; end +class TrueClass; include Gibbler::String; end +class FalseClass; include Gibbler::String; end +class Float; include Gibbler::String; end +class Time; include Gibbler::Time; end +class Date; include Gibbler::String; end +class DateTime < Date; include Gibbler::DateTime; end +class Range; include Gibbler::Range; end +class NilClass; include Gibbler::Nil; end +module URI; class Generic; include Gibbler::String; end; end +class File; include Gibbler::File; end +class TempFile; include Gibbler::File; end +class Regexp; include Gibbler::String; end -class Class - include Gibbler::Object -end -class Module - include Gibbler::Object -end -class Fixnum - include Gibbler::String -end -class Bignum - include Gibbler::String -end -class TrueClass - include Gibbler::String -end - -class FalseClass - include Gibbler::String -end - -class Float - include Gibbler::String -end - -class Time - include Gibbler::Time -end - -class Date - include Gibbler::String -end - -class DateTime < Date - include Gibbler::DateTime -end - -class Range - include Gibbler::Range -end - -class NilClass - include Gibbler::Nil -end - -module URI - class Generic - include Gibbler::String - end -end - -class File - include Gibbler::File -end - -class TempFile - include Gibbler::File -end diff --git a/lib/gibbler/object.rb b/lib/gibbler/object.rb index 915d6df..9d86b85 100644 --- a/lib/gibbler/object.rb +++ b/lib/gibbler/object.rb @@ -62,6 +62,7 @@ def gibbler_debug(*args) def __gibbler(h=self) klass = h.class nom = h.name || '' + a = Gibbler.digest '%s:%s:%s' % [klass, nom.size, nom] gibbler_debug klass, a, [klass, nom.size, nom] a