gibbler 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.txt CHANGED
@@ -1,5 +1,16 @@
1
1
  GIBBLER, CHANGES
2
2
 
3
+ TODO: Calculate Proc based on running quietly executing it in a container
4
+ which implements method_missing. Tally the order, number, and names
5
+ of method calls.
6
+
7
+
8
+ #### 0.6.1 (2009-08-25) #################################
9
+
10
+ * ADDED: Support for Date, Time, and DateTime. Time and DateTime
11
+ refers to times in UTC.
12
+ * ADDED: Support for Range.
13
+
3
14
 
4
15
  #### 0.6.0 (2009-07-20) #################################
5
16
 
data/README.rdoc CHANGED
@@ -4,6 +4,9 @@ Git-like hashes and history for Ruby objects for Ruby 1.8, 1.9 and JRuby.
4
4
 
5
5
  <b>NOTE: Digests changed in the 0.6 release for Class, Module, and Proc objects. See "News" below for more info.</b>
6
6
 
7
+ Check out the screencast[http://www.rubypulse.com/episode-0.3-gibbler.html] created by Alex Peuchert.
8
+
9
+
7
10
  == Example 1 -- Basic Usage
8
11
 
9
12
  require 'gibbler'
@@ -182,6 +185,7 @@ or via download:
182
185
  == Thanks
183
186
 
184
187
  * Kalin Harvey (krrh[http://github.com/krrh]) for the early feedback and artistic direction.
188
+ * Alex Peuchert (aaalex[http://github.com/aaalex]) for creating the screencast.
185
189
 
186
190
 
187
191
  == Credits
data/gibbler.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  @spec = Gem::Specification.new do |s|
2
2
  s.name = "gibbler"
3
3
  s.rubyforge_project = "gibbler"
4
- s.version = "0.6.0"
4
+ s.version = "0.6.1"
5
5
  s.summary = "Gibbler: Git-like hashes for Ruby objects"
6
6
  s.description = s.summary
7
7
  s.author = "Delano Mandelbaum"
@@ -78,7 +78,7 @@ module Gibbler
78
78
  end
79
79
 
80
80
  @@mutex.synchronize {
81
- now, digest, point = Time.now, self.gibbler, self.clone
81
+ now, digest, point = ::Time.now, self.gibbler, self.clone
82
82
  self.__gibbler_history[:history] << digest
83
83
  self.__gibbler_history[:stamp][digest] = now
84
84
  self.__gibbler_history[:objects][digest] = point
data/lib/gibbler.rb CHANGED
@@ -13,7 +13,7 @@ module Gibbler
13
13
  #include Attic
14
14
  extend Attic
15
15
 
16
- VERSION = "0.6.0"
16
+ VERSION = "0.6.1"
17
17
 
18
18
  require 'gibbler/object'
19
19
  require 'gibbler/digest'
@@ -259,6 +259,104 @@ module Gibbler
259
259
  end
260
260
  end
261
261
 
262
+ # Creates a digest based on: <tt>CLASS:LENGTH:TIME</tt>.
263
+ # Times are calculated based on the equivalent time in UTC.
264
+ # e.g.
265
+ #
266
+ # Time.parse('2009-08-25 16:43:53 UTC') => 73b4635f
267
+ # Time.parse('2009-08-25 12:43:53 -04:00') => 73b4635f
268
+ #
269
+ # To use use method in other classes simply:
270
+ #
271
+ # class ClassLikeTime
272
+ # include Gibbler::Time
273
+ # end
274
+ #
275
+ module Time
276
+ include Gibbler::Object
277
+
278
+ def self.included(obj)
279
+ obj.extend Attic
280
+ obj.attic :__gibbler_cache
281
+ end
282
+
283
+ # Creates a digest for the current state of self.
284
+ def __gibbler(h=self)
285
+ klass = h.class
286
+ value = h.nil? ? "\0" : h.utc.to_s
287
+ a = Gibbler.digest "%s:%d:%s" % [klass, value.size, value]
288
+ gibbler_debug klass, a, [klass, value.size, value]
289
+ a
290
+ end
291
+ end
292
+
293
+ # Creates a digest based on: <tt>CLASS:LENGTH:DATETIME</tt>.
294
+ # Dates are calculated based on the equivalent datetime in UTC.
295
+ # e.g.
296
+ #
297
+ # DateTime.parse('2009-08-25T17:00:40+00:00') => ad64c769
298
+ # DateTime.parse('2009-08-25T13:00:40-04:00') => ad64c769
299
+ #
300
+ # To use use method in other classes simply:
301
+ #
302
+ # class ClassLikeTime
303
+ # include Gibbler::Time
304
+ # end
305
+ #
306
+ module DateTime
307
+ include Gibbler::Object
308
+
309
+ def self.included(obj)
310
+ obj.extend Attic
311
+ obj.attic :__gibbler_cache
312
+ end
313
+
314
+ # Creates a digest for the current state of self.
315
+ def __gibbler(h=self)
316
+ klass = h.class
317
+ value = h.nil? ? "\0" : h.new_offset(0).to_s
318
+ a = Gibbler.digest "%s:%d:%s" % [klass, value.size, value]
319
+ gibbler_debug klass, a, [klass, value.size, value]
320
+ a
321
+ end
322
+
323
+ end
324
+
325
+ # Creates a digest based on: <tt>CLASS:LENGTH:VALUE</tt>
326
+ # where LENGTH is the number of elements in the range
327
+ # and VALUE is the string representation of the range.
328
+ # e.g.
329
+ #
330
+ # (1..100) => Range:100:1..100 =>
331
+ #
332
+ #
333
+ # To use use method in other classes simply:
334
+ #
335
+ # class ClassLikeRange
336
+ # include Gibbler::Range
337
+ # end
338
+ #
339
+ module Range
340
+ include Gibbler::Object
341
+
342
+ def self.included(obj)
343
+ obj.extend Attic
344
+ obj.attic :__gibbler_cache
345
+ end
346
+
347
+ # Creates a digest for the current state of self.
348
+ def __gibbler(h=self)
349
+ klass = h.class
350
+ value = h.nil? ? "\0" : h.to_s
351
+ size = h.nil? ? 0 : h.to_a.size
352
+ a = Gibbler.digest "%s:%d:%s" % [klass, size, value]
353
+ gibbler_debug klass, a, [klass, size, value]
354
+ a
355
+ end
356
+
357
+ end
358
+
359
+
262
360
 
263
361
  ##--
264
362
  ## NOTE: this was used when Gibbler supported "include Gibbler". We
@@ -332,6 +430,20 @@ class Float
332
430
  include Gibbler::String
333
431
  end
334
432
 
433
+ class Time
434
+ include Gibbler::Time
435
+ end
335
436
 
437
+ class Date
438
+ include Gibbler::String
439
+ end
440
+
441
+ class DateTime
442
+ include Gibbler::DateTime
443
+ end
444
+
445
+ class Range
446
+ include Gibbler::Range
447
+ end
336
448
 
337
449
 
@@ -115,6 +115,7 @@ tryouts "Basic syntax with SHA1" do
115
115
  a
116
116
  end
117
117
 
118
+ # TODO: Update for Attic 0.4
118
119
  drill "doesn't reveal @__gibbler_digest__ instance variable", false do
119
120
  a = {}
120
121
  a.gibbler # We need to gibbler first so it sets a value to the instance var
@@ -138,3 +139,6 @@ tryouts "Basic syntax with SHA1" do
138
139
 
139
140
  end
140
141
 
142
+
143
+
144
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gibbler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Delano Mandelbaum
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-07-20 00:00:00 -04:00
12
+ date: 2009-08-25 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency