gibbler 0.6.3 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.txt CHANGED
@@ -1,6 +1,29 @@
1
1
  GIBBLER, CHANGES
2
2
 
3
3
 
4
+ #### 0.7.0 (2009-10-07) #################################
5
+
6
+ NOTE: Digest calculation for Proc objects has changed. Procs
7
+ or objects containing Procs will have different digests than
8
+ those created in previous releases.
9
+
10
+ * CHANGE: Proc digests are now based on the values of obj.class
11
+ and obj.name (if available).
12
+
13
+
14
+ #### 0.6.4 (2009-10-07) #################################
15
+
16
+ * FIXED: Now using correct superclass for DateTime (Date)
17
+ * CHANGE: aliases.rb will now require gibbler so you don't need to specify both.
18
+ i.e. require 'gibbler'
19
+ require 'gibbler/aliases'
20
+ * CHANGE: Gibbler::Object#gibbler returns the value of gibbler_cache when
21
+ the object is frozen, without calculation.
22
+ * ADDED: Gibbler::Object#freeze to create digest before freezing.
23
+ * ADDED: Out of the box support for Regexp (Gibbler::String)
24
+ * ADDED: Gibbler::Object#digest_cache alias for gibbler_cache
25
+
26
+
4
27
  #### 0.6.3 (2009-09-30) #################################
5
28
 
6
29
  * FIXED: Won't save digest to cache if the object is frozen
data/README.rdoc CHANGED
@@ -1,11 +1,13 @@
1
- = Gibbler - v0.6 ALPHA
1
+ = Gibbler - v0.7 ALPHA
2
2
 
3
3
  Git-like hashes and history for Ruby objects for Ruby 1.8, 1.9 and JRuby.
4
4
 
5
- <b>NOTE: Digests changed in the 0.6 release for Class, Module, and Proc objects. See "News" below for more info.</b>
6
-
7
5
  Check out the screencast[http://www.rubypulse.com/episode-0.3-gibbler.html] created by Alex Peuchert.
8
6
 
7
+ === Important Information Regarding Your Digests
8
+
9
+ <i>Digest calculation changed in the 0.7 release for Proc objects. See "News" below for more info.</i>
10
+
9
11
 
10
12
  == Example 1 -- Basic Usage
11
13
 
@@ -70,8 +72,7 @@ http://delano.github.com/gibbler/img/whoababy.gif
70
72
  == Example 3 -- Method Aliases
71
73
 
72
74
  If you have control over the namespaces of your objects, you can use the method aliases to tighten up your code a bit. The "gibbler" and "gibbled?" methods can be accessed via "digest" and "changed?", respectively. (The reason they're not enabled by default is to avoid conflicts.)
73
-
74
- require 'gibbler'
75
+
75
76
  require 'gibbler/aliases'
76
77
 
77
78
  "kimmy".digest # => c8027100ecc54945ab15ddac529230e38b1ba6a1
@@ -84,11 +85,9 @@ If you have control over the namespaces of your objects, you can use the method
84
85
 
85
86
 
86
87
  The history methods also have aliases which remove the "gibbler_".
87
-
88
- require 'gibbler'
89
- require 'gibbler/history'
90
- require 'gibbler/aliases'
91
88
 
89
+ require 'gibbler/aliases'
90
+ require 'gibbler/history'
92
91
 
93
92
  a = { :magic => :original }
94
93
  a.commit
@@ -121,18 +120,36 @@ If you want to support all Ruby objects, add the following to your application:
121
120
 
122
121
  Gibbler::String creates a digest based on the name of the class and the output of the to_s method. This is a reasonable default for most objects however any object that includes the object address in to_s (e.g. "Object:0x0x4ac9f0...") will produce unreliable digests (because the address can change).
123
122
 
123
+ As of 0.7 all Proc objects have the same digest: <tt>12075835e94be34438376cd7a54c8db7e746f15d</tt>.
124
+
124
125
 
125
126
  == ALPHA Notice
126
127
 
127
- 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:
128
+ This code is fresh so the interface may change. Some things to keep in mind:
128
129
 
129
130
  * 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.
130
- * Digest calculation may change between non-trivial releases.
131
- * There has been very little testing for concurrency issues. (Anyone interested?)
131
+ * Digest calculation may change between minor releases (e.g. 0.6 to 0.7, etc)
132
+ * Don't forget to enjoy what you do!
132
133
 
133
134
 
134
135
  == News
135
136
 
137
+ === 2009-10-07: Digest calculation for Proc objects has changed.
138
+
139
+ Proc digests are now based on the name of the class and the value of Proc#name (if available). Procs or objects containing Procs will have different digests than those created in previous releases.
140
+
141
+ After much deliberation, I realized that Gibbler cares about the data and not the code. Procs are code, but a reference to a Proc in an instance variable is data. With this change all Proc objects have the same digest. This decision has the side benefit of increasing compatibility between Ruby 1.8, 1.9 & JRuby.
142
+
143
+ This is the only change between 0.6.4 and 0.7.0 so if you prefer the previous calculation for Procs you can find it in that version.
144
+
145
+ Happy Digesting!
146
+
147
+ === 2009-10-07: Support for freezing and Regexp
148
+
149
+ In 0.6.4, all Gibbler objects will create a new digest when <tt>obj.freeze</tt> is called. All subsequent calls to <tt>obj.gibbler</tt> will return the most recent digest without having to run the calculation again.
150
+
151
+ I've also added support for Regexp out of the box.
152
+
136
153
  === 2009-07-20: Digest change for instances of Class, Module, and Proc
137
154
 
138
155
  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 +159,11 @@ Digest calculation has changed for Class, Module, and Proc objects. Digests crea
142
159
 
143
160
  Also note that this change affects the digests for Hashes and Arrays that contain instances of Class, Module, or Proc.
144
161
 
145
- === 2009-07-17: Improved support for Symbol and Fixnum
146
-
147
- With the upgrade to Attic 0.4, the gibbled? method and object history is now available for Symbol and Fixnum objects.
148
-
149
162
 
150
163
  == Known Issues
151
164
 
152
165
  * 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)
153
- * Digests for Bignum objects are different between Ruby 1.8, 1.9, and JRuby. Does anyone know why?
166
+ * Digests for Bignum objects are different between Ruby and JRuby. Does anyone know why?
154
167
  * 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.
155
168
 
156
169
 
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.3"
4
+ s.version = "0.7.0"
5
5
  s.summary = "Gibbler: Git-like hashes for Ruby objects"
6
6
  s.description = s.summary
7
7
  s.author = "Delano Mandelbaum"
@@ -41,9 +41,14 @@
41
41
  lib/gibbler/mixins/string.rb
42
42
  lib/gibbler/object.rb
43
43
  tryouts/01_mixins_tryouts.rb
44
+ tryouts/02_compat_tryouts.rb
44
45
  tryouts/05_gibbler_digest_tryouts.rb
45
46
  tryouts/10_basic_tryouts.rb
46
47
  tryouts/11_basic_sha256_tryouts.rb
48
+ tryouts/14_extended_tryouts.rb
49
+ tryouts/15_file_tryouts.rb
50
+ tryouts/16_uri_tryouts.rb
51
+ tryouts/20_time_tryouts.rb
47
52
  tryouts/50_history_tryouts.rb
48
53
  tryouts/51_hash_history_tryouts.rb
49
54
  tryouts/52_array_history_tryouts.rb
@@ -1,11 +1,13 @@
1
1
 
2
+ require 'gibbler'
2
3
 
3
4
  module Gibbler
4
5
 
5
-
6
6
  module Object
7
- alias :digest :gibbler
8
- alias :changed? :gibbled?
7
+ alias :digest :gibbler
8
+ alias :changed? :gibbled?
9
+ # The cache is in the Attic.
10
+ def digest_cache; gibbler_cache; end
9
11
  end
10
12
 
11
13
  #--
@@ -14,12 +14,21 @@ module Gibbler
14
14
  # Calculates a digest for the current object instance.
15
15
  # Objects that are a kind of Hash or Array are processed
16
16
  # recursively. The length of the returned String depends
17
- # on the digest type.
17
+ # on the digest type. Also stores the value in the attic.
18
+ #
19
+ # obj.gibbler # => a5b1191a
20
+ # obj.gibbler_cache # => a5b1191a
21
+ #
22
+ # Calling gibbler_cache returns the most recent digest
23
+ # without calculation.
24
+ #
25
+ # If the object is frozen, this will return the value of
26
+ # <tt>gibbler_cache</tt>.
27
+ #
18
28
  def gibbler
19
29
  gibbler_debug :GIBBLER, self.class, self
20
- digest = Gibbler::Digest.new self.__gibbler
21
- self.gibbler_cache = digest unless self.frozen?
22
- digest
30
+ return self.gibbler_cache if self.frozen?
31
+ self.gibbler_cache = Gibbler::Digest.new self.__gibbler
23
32
  end
24
33
 
25
34
  # Has this object been modified?
@@ -42,7 +51,7 @@ module Gibbler
42
51
 
43
52
  # Creates a digest for the current state of self based on:
44
53
  # * Object#class
45
- # * Length of Object#name || ''
54
+ # * Length of Object#name || 0
46
55
  # * Object#name || ''
47
56
  #
48
57
  # e.g. Digest::SHA1.hexdigest "Class:6:Object" #=>
@@ -52,11 +61,19 @@ module Gibbler
52
61
  #
53
62
  def __gibbler(h=self)
54
63
  klass = h.class
55
- nom = h.name || ''
64
+ nom = h.name if h.respond_to?(:name)
65
+ nom ||= ''
56
66
  a = Gibbler.digest '%s:%s:%s' % [klass, nom.size, nom]
57
67
  gibbler_debug klass, a, [klass, nom.size, nom]
58
68
  a
59
69
  end
70
+
71
+ # A simple override on Object#freeze to create a digest
72
+ # before the object is frozen. Once the object is frozen
73
+ # <tt>obj.gibbler</tt> will return the cached value with
74
+ # out calculation.
75
+ def freeze() self.gibbler; super; self end
76
+
60
77
  end
61
78
 
62
79
  end
data/lib/gibbler.rb CHANGED
@@ -1,22 +1,18 @@
1
1
 
2
- local_libs = %w{attic}
3
- local_libs.each { |dir| $:.unshift File.join(File.dirname(__FILE__), '..', '..', dir, 'lib') }
4
-
5
- require 'digest/sha1'
2
+ require 'thread'
6
3
  require 'attic'
4
+ require 'digest/sha1'
7
5
 
8
6
  # = Gibbler
9
7
  #
10
8
  # "Hola, Tanneritos"
11
9
  #
12
10
  module Gibbler
13
- #include Attic
14
- extend Attic
15
11
 
16
- VERSION = "0.6.3"
12
+ VERSION = "0.7.0"
17
13
 
18
- require 'gibbler/object'
19
14
  require 'gibbler/digest'
15
+ require 'gibbler/object'
20
16
  require 'gibbler/mixins'
21
17
 
22
18
  class Error < RuntimeError
@@ -225,40 +221,6 @@ module Gibbler
225
221
  end
226
222
  end
227
223
 
228
- # Return the digest for <tt>class:arity:binding</tt>, where:
229
- # * class is the current class name (e.g. Proc)
230
- # * arity is the value returned by <tt>Proc#arity</tt>
231
- # * value of lambda? if available (Ruby 1.9) or false otherwise
232
- #
233
- # This method can be used by any subclass of Proc.
234
- #
235
- # NOTE: This is named "Block" because for some reason if this is
236
- # named "Proc" (as in Gibbler::Proc) and the Rye library is also
237
- # required, a runtime error is raised (Ruby 1.9.1 only):
238
- #
239
- # undefined method `new' for Gibbler::Proc:Module
240
- # /usr/local/lib/ruby/1.9.1/tempfile.rb:169:in `callback'
241
- # /usr/local/lib/ruby/1.9.1/tempfile.rb:61:in `initialize'
242
- # /Users/delano/Projects/opensource/rye/lib/rye.rb:210:in `new'
243
- #
244
- module Block
245
- include Gibbler::Object
246
-
247
- def self.included(obj)
248
- obj.extend Attic
249
- obj.attic :gibbler_cache
250
- end
251
-
252
- # Creates a digest for the current state of self.
253
- def __gibbler(h=self)
254
- klass = h.class
255
- is_lambda = h.respond_to?(:lambda?) ? h.lambda? : false
256
- a = Gibbler.digest '%s:%s:%s' % [klass, h.arity, is_lambda]
257
- gibbler_debug klass, a, [klass, h.arity, is_lambda]
258
- a
259
- end
260
- end
261
-
262
224
  # Creates a digest based on: <tt>CLASS:LENGTH:TIME</tt>.
263
225
  # Times are calculated based on the equivalent time in UTC.
264
226
  # e.g.
@@ -439,84 +401,32 @@ module Gibbler
439
401
 
440
402
  end
441
403
 
442
- class Proc
443
- include Gibbler::Block
444
- end
445
-
446
- class Hash
447
- include Gibbler::Hash
448
- end
449
-
450
- class Array
451
- include Gibbler::Array
452
- end
453
-
454
- class String
455
- include Gibbler::String
456
- end
457
-
458
- class Symbol
459
- include Gibbler::String
460
- end
461
-
462
- class Class
463
- include Gibbler::Object
464
- end
465
-
466
- class Module
467
- include Gibbler::Object
468
- end
469
-
470
- class Fixnum
471
- include Gibbler::String
472
- end
473
-
474
- class Bignum
475
- include Gibbler::String
476
- end
477
-
478
- class TrueClass
479
- include Gibbler::String
480
- end
481
-
482
- class FalseClass
483
- include Gibbler::String
484
- end
485
-
486
- class Float
487
- include Gibbler::String
488
- end
489
-
490
- class Time
491
- include Gibbler::Time
492
- end
493
-
494
- class Date
495
- include Gibbler::String
496
- end
404
+ class NilClass; include Gibbler::Nil; end
405
+ class Class; include Gibbler::Object; end
406
+ class Module; include Gibbler::Object; end
407
+ class Proc; include Gibbler::Object; end
408
+ class String; include Gibbler::String; end
409
+ class Regexp; include Gibbler::String; end
410
+ class Fixnum; include Gibbler::String; end
411
+ class Bignum; include Gibbler::String; end
412
+ class TrueClass; include Gibbler::String; end
413
+ class FalseClass; include Gibbler::String; end
414
+ class Float; include Gibbler::String; end
415
+ class Symbol; include Gibbler::String; end
416
+ class Date; include Gibbler::String; end
417
+ class Hash; include Gibbler::Hash; end
418
+ class Array; include Gibbler::Array; end
419
+ class Time; include Gibbler::Time; end
420
+ class DateTime < Date; include Gibbler::DateTime; end
421
+ class Range; include Gibbler::Range; end
422
+ class File; include Gibbler::File; end
423
+ class TempFile; include Gibbler::File; end
497
424
 
498
- class DateTime
499
- include Gibbler::DateTime
500
- end
425
+ # URI::Generic must be included towards the
426
+ # end b/c it runs Object#freeze statically.
427
+ module URI; class Generic; include Gibbler::String; end; end
501
428
 
502
- class Range
503
- include Gibbler::Range
504
- end
505
429
 
506
- class NilClass
507
- include Gibbler::Nil
508
- end
509
430
 
510
- module URI
511
- class Generic
512
- include Gibbler::String
513
- end
514
- end
515
431
 
516
- class File
517
- include Gibbler::File
518
- end
519
432
 
520
- class TempFile
521
- include Gibbler::File
522
- end
@@ -0,0 +1,25 @@
1
+
2
+ library :gibbler, 'lib'
3
+
4
+ group "Gibbler::Digest"
5
+
6
+ tryouts "Backwards compatability" do
7
+
8
+ dream true
9
+ drill "Gibbler Objects have gibbler_cache method" do
10
+ "kimmy".respond_to? :gibbler_cache
11
+ end
12
+
13
+ dream true
14
+ drill "Gibbler Objects have __gibbler_cache method" do
15
+ "kimmy".respond_to? :__gibbler_cache
16
+ end
17
+
18
+ dream true
19
+ drill "__gibbler_cache returns the same value as gibbler_cache" do
20
+ a = "kimmy" and a.gibbler
21
+ a.__gibbler_cache == a.gibbler_cache
22
+ end
23
+
24
+ end
25
+
@@ -39,7 +39,7 @@ tryouts "Basic syntax with SHA1" do
39
39
  1
40
40
  end
41
41
 
42
- dream :gibbler, '259afadb4ef8abaeb367db97d0c3015c8a4a504a'
42
+ dream :gibbler, '608256db120251843843bba57e9b2c7adb7342aa'
43
43
  drill "Bignum instance" do
44
44
  100000000000
45
45
  end
@@ -103,6 +103,15 @@ tryouts "Basic syntax with SHA1" do
103
103
  Hash.attic_vars
104
104
  end
105
105
 
106
+ drill "Freezing an object will update the digest", true do
107
+ a = { :a => 1 }
108
+ pre = a.gibbler;
109
+ a[:a] = 2
110
+ post = a.freeze.gibbler
111
+ stash :pre, pre
112
+ stash :post, post
113
+ pre != post && post == a.gibbler_cache
114
+ end
106
115
 
107
116
  dream :gibbler, "6ea546919dc4caa2bab69799b71d48810a1b48fa"
108
117
  drill "works on arbitrary objects" do
@@ -0,0 +1,97 @@
1
+
2
+ library :gibbler, 'lib'
3
+ group "Gibbler Gazette"
4
+
5
+ Gibbler.enable_debug if Tryouts.verbose > 3
6
+ Gibbler.digest_type = Digest::SHA1
7
+
8
+ tryouts "Extended object tryouts" do
9
+
10
+ dream :gibbler, 'f2b0150c84c5c834406ec9cdec989a0fa938b4ad'
11
+ drill "true can gibbler", true
12
+
13
+ dream :gibbler, 'abee839edf5f9c101c505c28987ca35c31c7fc8d'
14
+ drill "false can gibbler", false
15
+
16
+ dream :gibbler, '583fb214ec50d2c4a123cc52de0c65e801d13516'
17
+ drill "TrueClass can gibbler", TrueClass
18
+
19
+ dream :gibbler, '11f262be475ddf38a25888e9f6ec82f384a7c58b'
20
+ drill "FalseClass can gibbler", FalseClass
21
+
22
+ dream :gibbler, '25ac269ae3ef18cdb4143ad02ca315afb5026de9'
23
+ drill "Class can gibbler", Class
24
+
25
+ dream :gibbler, '5620e4a8b10ec6830fece61d33f5d3e9a349b4c2'
26
+ drill "Object can gibbler", Object
27
+
28
+ dream :gibbler, '083feec632e6cd5347e3fb3c7048365c3a0d710e'
29
+ drill "Class instance can gibbler", Class.new
30
+
31
+ dream :gibbler, '7295241e929ffd7cc974cf8d4481291e070937fc'
32
+ drill "Module can gibbler", Module
33
+
34
+ dream :gibbler, '6b5a192fd377dfc5c2828a3ad6105b68b6db33d5'
35
+ drill "Module instance can gibbler", Module.new
36
+
37
+ dream :gibbler, '8640f7abcbcb80e3825ed827bf36819e26119e16'
38
+ drill "Proc can gibbler", Proc
39
+
40
+ dream :gibbler, 'd73ae2a7bc2058b05dbc1952d8abf004167109e0'
41
+ drill "Range instance (..) can gibbler", 1..100
42
+
43
+ dream :gibbler, '46c8a7d0163144819c440bf6734a8101cd72c04a'
44
+ drill "Range instance (...) can gibbler", 1...100
45
+
46
+ drill "Range (..) doesn't equal range (...)", true do
47
+ ('a'..'e').gibbler != ('a'...'e').gibbler
48
+ end
49
+
50
+ dream '06fdf26b2a64e90cd35ea9162d9cc48c9f6bb13c'
51
+ drill "nil has a gibbler", nil.gibbler
52
+
53
+
54
+ dream :gibbler, '7295241e929ffd7cc974cf8d4481291e070937fc'
55
+ drill "Module can gibbler", Module
56
+
57
+ dream :gibbler, '6b5a192fd377dfc5c2828a3ad6105b68b6db33d5'
58
+ drill "Module instance can gibbler", Module.new
59
+
60
+ dream :gibbler, '25ac269ae3ef18cdb4143ad02ca315afb5026de9'
61
+ drill "Class can gibbler", Class
62
+
63
+ end
64
+
65
+
66
+ tryouts "Proc" do
67
+
68
+ setup do
69
+ class ::MyProc < Proc; end
70
+ end
71
+
72
+ dream :gibbler, '12075835e94be34438376cd7a54c8db7e746f15d'
73
+ drill "Proc.new can gibbler", Proc.new() { }
74
+
75
+ dream :gibbler, '8640f7abcbcb80e3825ed827bf36819e26119e16'
76
+ drill "Proc can gibbler", Proc
77
+
78
+ dream :gibbler, '12075835e94be34438376cd7a54c8db7e746f15d'
79
+ drill "proc can gibbler", proc {}
80
+
81
+ dream :gibbler, '12075835e94be34438376cd7a54c8db7e746f15d'
82
+ drill "lambda can gibbler", lambda {}
83
+
84
+ dream :gibbler, '12075835e94be34438376cd7a54c8db7e746f15d'
85
+ drill "lambda gibbler is not aware of arity", lambda { |v| }
86
+
87
+ dream :gibbler, '12075835e94be34438376cd7a54c8db7e746f15d'
88
+ drill "proc gibbler is not aware of arity", proc { |v| }
89
+
90
+ dream :gibbler, '12075835e94be34438376cd7a54c8db7e746f15d'
91
+ drill "Proc gibbler is not aware of proc payload", proc { |v| 1; }
92
+
93
+ dream :gibbler, "c979a45653acaddcb9c1581a7de49c94ac96e128"
94
+ drill "MyProc has a different digest" do
95
+ MyProc.new() { }
96
+ end
97
+ end
@@ -0,0 +1,47 @@
1
+ require 'tempfile'
2
+
3
+ library :gibbler, 'lib'
4
+ group "Gibbler Gazette"
5
+
6
+ Gibbler.enable_debug if Tryouts.verbose > 3
7
+ Gibbler.digest_type = Digest::SHA1
8
+
9
+ tryouts "File object tryouts" do
10
+ set :tempfile, "tryouts-9000-awesome.txt"
11
+
12
+ clean do
13
+ File.unlink tempfile if File.exists? tempfile
14
+ end
15
+
16
+ dream :gibbler, '33027386bd95e91efc4711648d488519062d828f'
17
+ drill "File can gibbler" do
18
+ path = File.join(File.dirname(__FILE__), '..', 'CHANGES.txt')
19
+ File.new(File.expand_path(path))
20
+ end
21
+
22
+ dream :gibbler, '4c131b7e5f9e7b841b4501d2d002785d3730ae19'
23
+ drill "Gibbler is different for each path" do
24
+ path = File.join(File.dirname(__FILE__), '..', 'README.rdoc')
25
+ File.new(File.expand_path(path))
26
+ end
27
+
28
+ ## JRuby doesn't like to use File.new with directories
29
+ ##dream :gibbler, '92cbcb7de73d7748b28d9e911f461013de34410f'
30
+ ##drill "File gibbler cares about trailing slash (/tmp/)", File.new(__FILE__)
31
+
32
+ dream :respond_to?, :gibbler
33
+ drill "TempFile can gibbler", Tempfile.new('gibbler')
34
+
35
+ drill "TempFile digests change", false do
36
+ Tempfile.new('gibbler').gibbler == Tempfile.new('gibbler').gibbler
37
+ end
38
+
39
+ dream :gibbler, '6d93f752fc23f36bffa5ddf9ee97d04be82efbdb'
40
+ drill "File doesn't care about file contents" do
41
+ f = File.open tempfile, 'w'
42
+ f.puts "World's Finest Number: " << "#{rand}"
43
+ f.close
44
+ stash :file_contents, File.read(tempfile)
45
+ File.new tempfile
46
+ end
47
+ end
@@ -0,0 +1,41 @@
1
+ require 'uri'
2
+
3
+ library :gibbler, 'lib'
4
+ group "Gibbler Gazette"
5
+
6
+ Gibbler.enable_debug if Tryouts.verbose > 3
7
+ Gibbler.digest_type = Digest::SHA1
8
+
9
+ tryouts "URI object tryouts" do
10
+
11
+ dream :gibbler, "9efe60a5db66aecf9b5fb8655b0bab0fcc7bd0c5"
12
+ drill "URI::HTTP can gibbler" do
13
+ uri = URI.parse "http://localhost:3114/spaceship"
14
+ uri
15
+ end
16
+
17
+ dream :gibbler, "b75d3c34e60d6feafa796ddbb51e45710f6b106d"
18
+ drill "URI::HTTPS can gibbler" do
19
+ uri = URI.parse "https://localhost:3114/spaceship"
20
+ uri
21
+ end
22
+
23
+ dream :gibbler, "191b0072b95ca0c79ed75e6deb5b28562dd9e5b9"
24
+ drill "URI::HTTP is trailing slash sensitive" do
25
+ uri = URI.parse "http://localhost:3114/spaceship/"
26
+ uri
27
+ end
28
+
29
+ dream :gibbler, "d378372934326947113489d1f36f4853bef90a65"
30
+ drill "URI::Generic can gibbler" do
31
+ uri = URI.parse "localhost:3114/spaceship"
32
+ uri
33
+ end
34
+
35
+ dream :gibbler, "9d0543b31afebac9e8d38c56a0cf12070779f790"
36
+ drill "URI::FTP can gibbler" do
37
+ uri = URI.parse "ftp://localhost:3114/spaceship"
38
+ uri
39
+ end
40
+
41
+ end
@@ -0,0 +1,35 @@
1
+ require 'date'
2
+
3
+ library :gibbler, 'lib'
4
+ group "Gibbler Gazette"
5
+
6
+ Gibbler.enable_debug if Tryouts.verbose > 3
7
+ Gibbler.digest_type = Digest::SHA1
8
+
9
+ tryouts "Time tryouts" do
10
+
11
+ dream :gibbler, 'c8403fc35481fdf7f6f4a0e7262b1c9610bdebaa'
12
+ drill "Date instance can gibbler", Date.parse('2009-08-25')
13
+
14
+ dream :gibbler, '73b4635fc63b8dd32b622776201f98a37478be90'
15
+ drill "Time instance can gibbler", Time.parse('2009-08-25 16:43:53 UTC')
16
+
17
+ dream :gibbler, 'd35546d6517c02f2a219ecfa2261a5274d217cb7'
18
+ drill "Time instance can gibbler with single digit values" do
19
+ Time.parse('2009-01-01 01:01:01 UTC')
20
+ end
21
+
22
+ dream :gibbler, 'ad64c7694a50becf55c53485dce5d0013ff65785'
23
+ drill "DateTime instance can gibbler", DateTime.parse('2009-08-25T17:00:40+00:00')
24
+
25
+ dream Time.parse('2009-08-25 12:43:53 -04:00').gibbler
26
+ drill "Time digest is based on UTC" do
27
+ Time.parse('2009-08-25 16:43:53 UTC').gibbler
28
+ end
29
+
30
+ dream DateTime.parse('2009-08-25T13:00:40-04:00').gibbler
31
+ drill "DateTime digest is based on UTC" do
32
+ DateTime.parse('2009-08-25T17:00:40+00:00').gibbler
33
+ end
34
+
35
+ end
@@ -11,6 +11,11 @@ tryouts "Gibbler::Object Aliases" do
11
11
  :kimmy.gibbler == :kimmy.digest
12
12
  end
13
13
 
14
+ drill "has digest_cache", true do
15
+ a = :kimmy.gibbler
16
+ a.gibbler_cache == a.digest_cache
17
+ end
18
+
14
19
  drill "has changed?", true do
15
20
  a = "kimmy"
16
21
  a.digest
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.3
4
+ version: 0.7.0
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-09-30 00:00:00 -04:00
12
+ date: 2009-10-07 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -45,9 +45,14 @@ files:
45
45
  - lib/gibbler/mixins/string.rb
46
46
  - lib/gibbler/object.rb
47
47
  - tryouts/01_mixins_tryouts.rb
48
+ - tryouts/02_compat_tryouts.rb
48
49
  - tryouts/05_gibbler_digest_tryouts.rb
49
50
  - tryouts/10_basic_tryouts.rb
50
51
  - tryouts/11_basic_sha256_tryouts.rb
52
+ - tryouts/14_extended_tryouts.rb
53
+ - tryouts/15_file_tryouts.rb
54
+ - tryouts/16_uri_tryouts.rb
55
+ - tryouts/20_time_tryouts.rb
51
56
  - tryouts/50_history_tryouts.rb
52
57
  - tryouts/51_hash_history_tryouts.rb
53
58
  - tryouts/52_array_history_tryouts.rb