gibbler 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.txt +5 -0
- data/README.rdoc +10 -7
- data/gibbler.gemspec +1 -1
- data/lib/gibbler/history.rb +9 -9
- data/lib/gibbler.rb +2 -2
- data/tryouts/51_hash_history_tryouts.rb +4 -4
- data/tryouts/52_array_history_tryouts.rb +1 -1
- data/tryouts/53_string_history_tryouts.rb +1 -1
- data/tryouts/57_arbitrary_history_tryouts.rb +1 -1
- data/tryouts/59_history_exceptions_tryouts.rb +3 -3
- metadata +2 -2
data/CHANGES.txt
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
GIBBLER, CHANGES
|
2
2
|
|
3
3
|
|
4
|
+
#### 0.5.1 (2009-07-06) #################################
|
5
|
+
|
6
|
+
* CHANGE: Renamed gibbler_revert to gibbler_revert! (Thanks ivey)
|
7
|
+
|
8
|
+
|
4
9
|
#### 0.5 (2009-07-01) #################################
|
5
10
|
|
6
11
|
NOTE: This is a significant change from 0.4. Many method names
|
data/README.rdoc
CHANGED
@@ -6,6 +6,9 @@ Git-like hashes and history for Ruby objects.
|
|
6
6
|
|
7
7
|
require 'gibbler'
|
8
8
|
|
9
|
+
"kimmy".gibbler # => c8027100ecc54945ab15ddac529230e38b1ba6a1
|
10
|
+
:kimmy.gibbler # => 52be7494a602d85ff5d8a8ab4ffe7f1b171587df
|
11
|
+
|
9
12
|
config = {}
|
10
13
|
config.gibbler # => 4fdcadc66a38feb9c57faf3c5a18d5e76a6d29bf
|
11
14
|
config.gibbled? # => false
|
@@ -42,13 +45,13 @@ Gibbler can also keep track of the history of changes to an object. By default G
|
|
42
45
|
|
43
46
|
a.gibbler_history # => d7049916, b668098e, 0b11c377
|
44
47
|
|
45
|
-
a.gibbler_revert 'd7049916'
|
48
|
+
a.gibbler_revert! 'd7049916' # Return to a specific commit
|
46
49
|
a.gibbler # => d7049916ddb25e6cc438b1028fb957e5139f9910
|
47
50
|
a # => { :magic => :original }
|
48
51
|
|
49
52
|
a.delete :magic
|
50
53
|
|
51
|
-
a.gibbler_revert
|
54
|
+
a.gibbler_revert! # Return to the previous commit
|
52
55
|
a.gibbler # => 0b11c377fccd44554a601e5d2b135c46dc1c4cb1
|
53
56
|
a # => { :magic => :changed }
|
54
57
|
|
@@ -82,7 +85,7 @@ If you want to support all Ruby objects, add the following to your application:
|
|
82
85
|
include Gibbler::String
|
83
86
|
end
|
84
87
|
|
85
|
-
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. "
|
88
|
+
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).
|
86
89
|
|
87
90
|
|
88
91
|
== ALPHA Notice
|
@@ -94,14 +97,14 @@ NOTE: Gibbler history is not suitable for very large objects since it keeps comp
|
|
94
97
|
|
95
98
|
== News
|
96
99
|
|
97
|
-
=== 2009-07-
|
100
|
+
=== 2009-07-06: Renamed gibbler_revert to gibbler_revert!
|
98
101
|
|
99
|
-
|
102
|
+
The gibbler_revert! modifies the object in place so this was an important change to follow the Ruby convention of appending the exclamation mark. Thanks to ivey[http://news.ycombinator.com/item?id=689750] for pointing this out.
|
100
103
|
|
101
104
|
|
102
|
-
=== 2009-
|
105
|
+
=== 2009-07-01: Major namespace reorganization
|
103
106
|
|
104
|
-
|
107
|
+
Many method names have been modified so this release is not backwards compatible with previous releases. This clears up ambiguity regarding "gibbles". They're now rightly referred to as digests.
|
105
108
|
|
106
109
|
|
107
110
|
== Known Issues
|
data/gibbler.gemspec
CHANGED
data/lib/gibbler/history.rb
CHANGED
@@ -89,19 +89,19 @@ module Gibbler
|
|
89
89
|
# will revert to that point.
|
90
90
|
#
|
91
91
|
# Ruby does not support replacing self (<tt>self = previous_self</tt>) so each
|
92
|
-
# object type needs to implement its own __gibbler_revert method. This default
|
93
|
-
# run some common checks and then defers to self.__gibbler_revert
|
92
|
+
# object type needs to implement its own __gibbler_revert! method. This default
|
93
|
+
# run some common checks and then defers to self.__gibbler_revert!.
|
94
94
|
#
|
95
95
|
# Raise the following exceptions:
|
96
|
-
# * NoRevert: if this object doesn't have a __gibbler_revert method
|
96
|
+
# * NoRevert: if this object doesn't have a __gibbler_revert! method
|
97
97
|
# * NoHistory: This object has no commits
|
98
98
|
# * BadDigest: The given digest is not in the history for this object
|
99
99
|
#
|
100
100
|
# If +g+ matches the current digest value this method does nothing.
|
101
101
|
#
|
102
102
|
# Returns the new digest (+g+).
|
103
|
-
def gibbler_revert(g=nil)
|
104
|
-
raise NoRevert unless self.respond_to?(:__gibbler_revert)
|
103
|
+
def gibbler_revert!(g=nil)
|
104
|
+
raise NoRevert unless self.respond_to?(:__gibbler_revert!)
|
105
105
|
raise NoHistory, self.class unless gibbler_history?
|
106
106
|
raise BadDigest, g if !g.nil? && !gibbler_valid?(g)
|
107
107
|
|
@@ -114,7 +114,7 @@ module Gibbler
|
|
114
114
|
@@mutex.synchronize {
|
115
115
|
# Always make sure @__gibbler_digest__ is a Gibbler::Digest
|
116
116
|
@__gibbler_digest__ = g.is_a?(Gibbler::Digest) ? g : Gibbler::Digest.new(g)
|
117
|
-
self.__gibbler_revert
|
117
|
+
self.__gibbler_revert!
|
118
118
|
}
|
119
119
|
end
|
120
120
|
|
@@ -145,7 +145,7 @@ end
|
|
145
145
|
|
146
146
|
class Hash
|
147
147
|
include Gibbler::History
|
148
|
-
def __gibbler_revert
|
148
|
+
def __gibbler_revert!
|
149
149
|
self.clear
|
150
150
|
self.merge! self.gibbler_object @__gibbler_digest__
|
151
151
|
end
|
@@ -153,7 +153,7 @@ end
|
|
153
153
|
|
154
154
|
class Array
|
155
155
|
include Gibbler::History
|
156
|
-
def __gibbler_revert
|
156
|
+
def __gibbler_revert!
|
157
157
|
self.clear
|
158
158
|
self.push *(self.gibbler_object @__gibbler_digest__)
|
159
159
|
end
|
@@ -161,7 +161,7 @@ end
|
|
161
161
|
|
162
162
|
class String
|
163
163
|
include Gibbler::History
|
164
|
-
def __gibbler_revert
|
164
|
+
def __gibbler_revert!
|
165
165
|
self.clear
|
166
166
|
self << (self.gibbler_object @__gibbler_digest__)
|
167
167
|
end
|
data/lib/gibbler.rb
CHANGED
@@ -6,7 +6,7 @@ require 'digest/sha1'
|
|
6
6
|
# "Hola, Tanneritos"
|
7
7
|
#
|
8
8
|
module Gibbler
|
9
|
-
VERSION = "0.5.
|
9
|
+
VERSION = "0.5.1"
|
10
10
|
|
11
11
|
require 'gibbler/digest'
|
12
12
|
require 'gibbler/mixins'
|
@@ -122,7 +122,7 @@ module Gibbler
|
|
122
122
|
a
|
123
123
|
end
|
124
124
|
|
125
|
-
def __gibbler_revert
|
125
|
+
def __gibbler_revert!
|
126
126
|
state = self.gibbler_object @__gibbler_digest__
|
127
127
|
state.instance_variables do |n|
|
128
128
|
v = state.instance_variable_get n
|
@@ -44,7 +44,7 @@ tryouts "Hash History" do
|
|
44
44
|
a = { :magic => :original }
|
45
45
|
a.gibbler_commit
|
46
46
|
a[:magic] = :updated
|
47
|
-
a.gibbler_revert
|
47
|
+
a.gibbler_revert!
|
48
48
|
end
|
49
49
|
|
50
50
|
drill "knows a valid gibble", true do
|
@@ -67,7 +67,7 @@ tryouts "Hash History" do
|
|
67
67
|
a.gibbler_commit
|
68
68
|
a[:magic] = :changed
|
69
69
|
a.gibbler_commit
|
70
|
-
a.gibbler_revert 'd7049916ddb25e6cc438b1028fb957e5139f9910'
|
70
|
+
a.gibbler_revert! 'd7049916ddb25e6cc438b1028fb957e5139f9910'
|
71
71
|
a
|
72
72
|
end
|
73
73
|
|
@@ -76,7 +76,7 @@ tryouts "Hash History" do
|
|
76
76
|
drill "revert does nothing if digest is the same as current one" do
|
77
77
|
a = { :magic => :original }
|
78
78
|
a.gibbler_commit
|
79
|
-
a.gibbler_revert
|
79
|
+
a.gibbler_revert!
|
80
80
|
a
|
81
81
|
end
|
82
82
|
|
@@ -85,7 +85,7 @@ tryouts "Hash History" do
|
|
85
85
|
a = { :magic => :original }
|
86
86
|
a.gibbler_commit
|
87
87
|
a[:magic] = :updated
|
88
|
-
a.gibbler_revert 'd7049916'
|
88
|
+
a.gibbler_revert! 'd7049916'
|
89
89
|
end
|
90
90
|
|
91
91
|
end
|
@@ -13,18 +13,18 @@ tryouts "Exceptions" do
|
|
13
13
|
drill "raises exception when reverting to unknown gibble" do
|
14
14
|
a = {}
|
15
15
|
a.gibbler_commit
|
16
|
-
a.gibbler_revert '2222222222222222222222222222222222222222'
|
16
|
+
a.gibbler_revert! '2222222222222222222222222222222222222222'
|
17
17
|
end
|
18
18
|
|
19
19
|
dream :exception, Gibbler::NoHistory
|
20
20
|
drill "raises exception when reverting and there's no history" do
|
21
21
|
a = []
|
22
|
-
a.gibbler_revert
|
22
|
+
a.gibbler_revert!
|
23
23
|
end
|
24
24
|
|
25
25
|
dream :exception, NoMethodError
|
26
26
|
drill "raises exception when reverting an unsupported object" do
|
27
|
-
:kimmy.gibbler_revert
|
27
|
+
:kimmy.gibbler_revert!
|
28
28
|
end
|
29
29
|
|
30
30
|
end
|
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.5.
|
4
|
+
version: 0.5.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-
|
12
|
+
date: 2009-07-06 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|