Skip to content

Commit

Permalink
gibbler aliases to allow shorter methods by request.
Browse files Browse the repository at this point in the history
  • Loading branch information
delano committed Jul 7, 2009
1 parent 6590ae5 commit 92cd3ea
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGES.txt
Expand Up @@ -3,8 +3,9 @@ GIBBLER, CHANGES

#### 0.5.2 (2009-07-??) #################################

* ADDED: Proc.gibbler which is included by default
* CHANGE: Moved Gibbler instance methods to Gibbler::Object
* ADDED: Proc.gibbler which is included by default
* ADDED: gibbler aliases to allow shorter methods by request.


#### 0.5.1 (2009-07-06) #################################
Expand Down
29 changes: 29 additions & 0 deletions lib/gibbler/aliases.rb
@@ -0,0 +1,29 @@


module Gibbler


module Object
alias :digest :gibbler
alias :changed? :gibbled?
end

#--
# Aliases for Gibbler::History methods
#
# NOTE: we explicitly define the methods rather than use "alias"
# in the event that the require 'gibbler/aliases' appears before
# require 'gibbler/history' (alias complains about unknown methods)
#++
module History
def history(*args, &b); gibbler_history(*args, &b); end
def commit; gibbler_commit; end
def object(*args, &b); gibbler_object(*args, &b); end
def stamp(*args, &b); gibbler_stamp(*args, &b); end
def revert!(*args, &b); gibbler_revert!(*args, &b); end
def history?; gibbler_history?; end
def valid?(*args, &b); gibbler_valid?(*args, &b); end
def find_long(*args, &b); gibbler_find_long(*args, &b); end
end

end
60 changes: 60 additions & 0 deletions tryouts/90_alias_tryouts.rb
@@ -0,0 +1,60 @@

group "Aliases"

library :gibbler, 'lib'
library 'gibbler/aliases', 'lib'
library 'gibbler/history', 'lib'

tryouts "Gibbler::Object Aliases" do

drill "has digest", true do
:kimmy.gibbler == :kimmy.digest
end

drill "has changed?", true do
a = "kimmy"
a.digest
a << '+ dj'
a.gibbled?
end

end


tryouts "Gibbler::History Aliases" do

dream "d7049916ddb25e6cc438b1028fb957e5139f9910"
drill "can convert short digest into long" do
a = { :magic => :original }
g = a.commit.short
stash :short, g
a.find_long g
end

dream :class, Time
drill "can return most recent stamp" do
a = { :magic => :original }
a.commit
stash :hist, a.history
a.stamp
end

dream ["d7049916ddb25e6cc438b1028fb957e5139f9910", "0b11c377fccd44554a601e5d2b135c46dc1c4cb1"]
drill "can return history" do
a = { :magic => :original }
a.commit
a[:magic] = :changed
a.commit
a.history
end

dream ["d7049916", "0b11c377"]
drill "can return history (short)" do
a = { :magic => :original }
a.commit
a[:magic] = :changed
a.commit
a.history(:short)
end

end

0 comments on commit 92cd3ea

Please sign in to comment.