Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gibbler aliases to allow shorter methods by request.
- Loading branch information
Showing
3 changed files
with
91 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |