Browse files

Playing around with Tryout formatting

  • Loading branch information...
1 parent 1a3f6ee commit fa50d253af7f2c65c203c3b35f6dd0b011e53139 @delano committed Jul 18, 2010
View
4 try/01_mixins_try.rb
@@ -1,6 +1,6 @@
require 'gibbler'
-# TEST 1: has String#clear
-"".respond_to? :clear
+## has String#clear
+ "".respond_to? :clear
#=> true
View
10 try/02_compat_try.rb
@@ -1,16 +1,14 @@
require 'gibbler'
## Gibbler Objects have gibbler_cache method
-"kimmy".respond_to? :gibbler_cache
+ "kimmy".respond_to? :gibbler_cache
#=> true
-
## Gibbler Objects have __gibbler_cache method
-"kimmy".respond_to? :__gibbler_cache
+ "kimmy".respond_to? :__gibbler_cache
#=> true
-
## __gibbler_cache returns the same value as gibbler_cache
-@a = "kimmy" and @a.gibbler
-@a.gibbler_cache
+ @a = "kimmy" and @a.gibbler
+ @a.gibbler_cache
#=> @a.__gibbler_cache
View
22 try/05_gibbler_digest_try.rb
@@ -1,41 +1,41 @@
require 'gibbler'
## has short method
-"kimmy".gibbler.short
+ "kimmy".gibbler.short
#=> Gibbler::Digest.new("c8027100")
# can Gibbler::Digest#short
-Gibbler::Digest.new("1234567890").short
+ Gibbler::Digest.new("1234567890").short
#=> Gibbler::Digest.new("12345678")
# == is strict (only exact matches)
-Gibbler::Digest.new("1234567890") == "12345678"
-#=> false
+ Gibbler::Digest.new("1234567890") != "12345678"
+#=> true
# === is relaxed (allows partial matches)
-Gibbler::Digest.new("1234567890") === "12345678"
+ Gibbler::Digest.new("1234567890") === "12345678"
#=> true
# supports base36 output
-Gibbler::Digest.new("1234567890").base36
+ Gibbler::Digest.new("1234567890").base36
#=> 'zx2tc40'
# base36 works on digests too
-"kimmy".gibbler.base36
+ "kimmy".gibbler.base36
#=> 'nd2w8270caslmly0ix3s8ruh0y8yjdt'
# base36 digests can be short too
-"kimmy".gibbler.base36.short
+ "kimmy".gibbler.base36.short
#=> 'nd2w8270'
# to_s returns a string and can accept a base
-"kimmy".gibbler.to_s(16)
+ "kimmy".gibbler.to_s(16)
#=> "kimmy".gibbler.base(16).to_s
# base takes a base
-"kimmy".gibbler.base(17)
+ "kimmy".gibbler.base(17)
#=> '12gaabd69eg5b32gf69a7a021c22g977d4gf46d6'
# to_s can take a base
-"kimmy".gibbler.to_s(36)
+ "kimmy".gibbler.to_s(36)
#=> "kimmy".gibbler.base36
View
95 try/10_basic_try.rb
@@ -3,96 +3,96 @@
#Gibbler.enable_debug
# include Gibbler raises exception
-begin
- a = Class.new
- a.send :include, Gibbler
-rescue RuntimeError
- :success
-end
+ begin
+ a = Class.new
+ a.send :include, Gibbler
+ rescue RuntimeError
+ :success
+ end
#=> :success
# Symbol digests are consistent
-:kimmy.gibbler
+ :kimmy.gibbler
#=> '52be7494a602d85ff5d8a8ab4ffe7f1b171587df'
# String digests are consistent
-'kimmy'.gibbler
+ 'kimmy'.gibbler
#=> 'c8027100ecc54945ab15ddac529230e38b1ba6a1'
# String and Symbol return different digests
-:kimmy.gibbler != "kimmy".gibbler
+ :kimmy.gibbler != "kimmy".gibbler
#=> true
# Class digests are consistent
-Class.gibbler
+ Class.gibbler
#=> '25ac269ae3ef18cdb4143ad02ca315afb5026de9'
# Fixnum instance digests are consistent
-1.gibbler
+ 1.gibbler
#=> 'a9cad665549bd22a4346fcf602d9d3c3b0482bbe'
# Bignum instance
-100000000000.gibbler
+ 100000000000.gibbler
#=> '608256db120251843843bba57e9b2c7adb7342aa'
# Empty Hash instance digests are consistent
-Hash.new.gibbler
+ Hash.new.gibbler
#=> '4fdcadc66a38feb9c57faf3c5a18d5e76a6d29bf'
# Populated Hash instance
-{ :a => [1,2,3, [4,5,6]], :b => { :c => Class } }.gibbler
+ { :a => [1,2,3, [4,5,6]], :b => { :c => Class } }.gibbler
#=> "1d4b62e1e9f2c097b0cefb6877bf47c2015cdd21"
# Empty Array instance
-Array.new.gibbler
+ Array.new.gibbler
#=> '48fda57c05684c9e5c3259557851943572183a21'
# Populated Array instance
-[1, 2, :runtime, [3, "four", [Object, true]]].gibbler
+ [1, 2, :runtime, [3, "four", [Object, true]]].gibbler
#=> "3e1d79d113a409a96a13ca3879fc4c42027aa74b"
# Knows when a Hash has not changed
-a = { :magic => true }
-a.gibbler
-a[:magic] = true
-a.gibbled?
+ a = { :magic => true }
+ a.gibbler
+ a[:magic] = true
+ a.gibbled?
# => false
# Knows when a Hash has changed
-a = { :magic => true }
-a.gibbler
-a[:magic] = false
-a.gibbled?
+ a = { :magic => true }
+ a.gibbler
+ a[:magic] = false
+ a.gibbled?
#=> true
# Two Symbol digests don't cross streams
-a, b = :something, :anything
-a.gibbler
-b.gibbler
-[a.gibbler_cache.short, b.gibbler_cache.short]
+ a, b = :something, :anything
+ a.gibbler
+ b.gibbler
+ [a.gibbler_cache.short, b.gibbler_cache.short]
#=> ["667ce086", "92d5f7cd"]
-# Two String digests don't cross streams" do
-a, b = 'something', 'anything'
-a.gibbler
-b.gibbler
-[a.gibbler_cache.short, b.gibbler_cache.short]
+# Two String digests don't cross streams"
+ a, b = 'something', 'anything'
+ a.gibbler
+ b.gibbler
+ [a.gibbler_cache.short, b.gibbler_cache.short]
#=> ["ce0c7694", "c13b2f02"]
## DISABLED: If gibbler/history is required, there will be an
## additional attic_var (:gibbler_history), but only if the
## gibbler_history method has been called already (the history
## remains nil by default). The fix is not straightfroward and
## tests are not important anyway so disabling them is fine.
-## Symbol has list of attic vars", [:gibbler_cache] do
+## Symbol has list of attic vars", [:gibbler_cache]
# Symbol.attic_vars
#end
#
-## String has list of attic vars", [:gibbler_cache] do
+## String has list of attic vars", [:gibbler_cache]
# String.attic_vars
#end
#
-## Hash has list of attic vars", [:gibbler_cache] do
+## Hash has list of attic vars", [:gibbler_cache]
# Hash.attic_vars
#end
@@ -104,18 +104,18 @@
pre != post && post == a.gibbler_cache
#=> true
-# works on arbitrary objects" do
-class ::FullHouse
- include Gibbler::Complex
- attr_accessor :roles
-end
-a = FullHouse.new
-a.roles = [:jesse, :joey, :danny, :kimmy, :michelle, :dj, :stephanie]
-a.gibbler
+# works on arbitrary objects"
+ class ::FullHouse
+ include Gibbler::Complex
+ attr_accessor :roles
+ end
+ a = FullHouse.new
+ a.roles = [:jesse, :joey, :danny, :kimmy, :michelle, :dj, :stephanie]
+ a.gibbler
#=> "fa5f741275b6b27932537e1946042b0286286e1d"
# TODO: Update for Attic 0.4
-# doesn't reveal @__gibbler_digest__ instance variable", false do
+# doesn't reveal @__gibbler_digest__ instance variable", false
a = {}
a.gibbler # We need to gibbler first so it sets a value to the instance var
val = RUBY_VERSION >= '1.9' ? :'@__gibbler_digest__' : '@__gibbler_digest__'
@@ -128,8 +128,3 @@ class ::FullHouse
a.gibbler_cache
#=> 'c8027100ecc54945ab15ddac529230e38b1ba6a1'
-
-
-
-
-
View
9 try/11_basic_sha256_try.rb
@@ -9,21 +9,20 @@
end
## A Symbol can gibbler
-:anything.gibbler
+ :anything.gibbler
#=> '754f87ca720ec256633a286d9270d68478850b2abd7b0ae65021cb769ae70c08'
## Class can gibbler
-Class.gibbler
+ Class.gibbler
#=> 'd345c0afb4e8da0133a3946d3bd9b2622b0acdd8d6cc1237470cc637a9e4777f'
## TrueClass can gibbler
-TrueClass.gibbler
+ TrueClass.gibbler
#=> 'b7b874a9bff7825caa57750a900652354ac601b77497b694d313f658c69d25b4'
# Empty Hash instance
-{}.gibbler
+ {}.gibbler
#=> '88d2bcbd68ce593fd2e0e06f276f7301357516291b95c0c53038e61a9bf091e5'
-
Gibbler.digest_type = Digest::SHA1
View
6 try/15_file_try.rb
@@ -3,7 +3,7 @@
@tempfile = "tryouts-9000-awesome.txt"
-# File can gibbler
+## File can gibbler
file = File.new(File.join('.', 'CHANGES.txt'))
file.gibbler
#=> 'c052e87bd0acb7e08c98dad7f8b09b4382a08ef6'
@@ -22,8 +22,8 @@
# TempFile digests change
-Tempfile.new('gibbler').gibbler == Tempfile.new('gibbler').gibbler
-#=> false
+Tempfile.new('gibbler').gibbler != Tempfile.new('gibbler').gibbler
+#=> true
# File doesn't care about file contents
View
10 try/16_uri_try.rb
@@ -1,31 +1,31 @@
require 'uri'
require 'gibbler'
-# "URI::HTTP can gibbler" do
+# "URI::HTTP can gibbler"
uri = URI.parse "http://localhost:3114/spaceship"
uri.gibbler
#=> "9efe60a5db66aecf9b5fb8655b0bab0fcc7bd0c5"
-# "URI::HTTPS can gibbler" do
+# "URI::HTTPS can gibbler"
uri = URI.parse "https://localhost:3114/spaceship"
uri.gibbler
#=> "b75d3c34e60d6feafa796ddbb51e45710f6b106d"
-# "URI::HTTP is trailing slash sensitive" do
+# "URI::HTTP is trailing slash sensitive"
uri = URI.parse "http://localhost:3114/spaceship/"
uri.gibbler
#=> "191b0072b95ca0c79ed75e6deb5b28562dd9e5b9"
-# "URI::Generic can gibbler" do
+# "URI::Generic can gibbler"
uri = URI.parse "localhost:3114/spaceship"
uri.gibbler
#=> "d378372934326947113489d1f36f4853bef90a65"
-# "URI::FTP can gibbler" do
+# "URI::FTP can gibbler"
uri = URI.parse "ftp://localhost:3114/spaceship"
uri.gibbler
#=> "9d0543b31afebac9e8d38c56a0cf12070779f790"
View
14 try/51_hash_history_try.rb
@@ -17,34 +17,34 @@ class ::Hash
a.gibbler_commit
#=> 'd7049916ddb25e6cc438b1028fb957e5139f9910'
-# "return a Hash history" do
+# "return a Hash history"
a = { :magic => :original }
a.gibbler_commit
a[:magic] = :updated
a.gibbler_commit
a.gibbler_history
#=> ['d7049916ddb25e6cc438b1028fb957e5139f9910', 'b668098e16d08898532bf3aa33ce2253a3a4150e']
-# "can revert Hash" do
+# "can revert Hash"
a = { :magic => :original }
a.gibbler_commit
a[:magic] = :updated
a.gibbler_revert!
#=> 'd7049916ddb25e6cc438b1028fb957e5139f9910'
-# "knows a valid gibble", true do
+# "knows a valid gibble"
a = { :magic => :original }
a.gibbler_commit
a.gibbler_valid? 'd7049916ddb25e6cc438b1028fb957e5139f9910'
#=> true
-# "knows an invalid gibble", false do
+# "knows an invalid gibble"
a = { :magic => :original }
a.gibbler_commit
a.gibbler_valid? '2222222222222222222222222222222222222222'
#=> false
-# "can revert to any valid gibble" do
+# "can revert to any valid gibble"
a = { :magic => :original }
a.gibbler_commit
a[:magic] = :updated
@@ -56,14 +56,14 @@ class ::Hash
#=> Hash[:magic => :original]
-# "revert does nothing if digest is the same as current one" do
+# "revert does nothing if digest is the same as current one"
a = { :magic => :original }
a.gibbler_commit
a.gibbler_revert!
a
#=> Hash[:magic => :original]
-# "can revert using short gibbler_commit
+# "can revert using short gibbler_commit"
a = { :magic => :original }
a.gibbler_commit
a[:magic] = :updated
View
4 try/52_array_history_try.rb
@@ -11,15 +11,15 @@ class Array
a.gibbler_commit
#=> 'd95fcabb498ae282f356eba63da541e4f72c6efa'
-# "return an Array history" do
+# "return an Array history"
a = [:jesse]
a.gibbler_commit
a << :joey
a.gibbler_commit
a.gibbler_history
#=> ['d95fcabb498ae282f356eba63da541e4f72c6efa', 'eebcb2e84e828b1a7207af4d588cf41fd4c6393a']
-# "can revert Array" do
+# "can revert Array"
a = [:jesse]
a.gibbler_commit
a << :joey
View
6 try/53_string_history_try.rb
@@ -5,20 +5,20 @@ class String
include Gibbler::History
end
-# "can take a String snapshot" do
+# "can take a String snapshot"
a = "kimmy"
a.gibbler_commit
#=> 'c8027100ecc54945ab15ddac529230e38b1ba6a1'
-# "return a String history" do
+# "return a String history"
a = "kimmy"
a.gibbler_commit
a << " gibbler"
a.gibbler_commit
a.gibbler_history
#=> ['c8027100ecc54945ab15ddac529230e38b1ba6a1', '692c05d3186baf2da36e87b7bc5fe53ef13b902e']
-# "can revert String" do
+# "can revert String"
a = "kimmy"
a.gibbler_commit
a << " gibbler"
View
4 try/57_arbitrary_history_try.rb
@@ -12,15 +12,15 @@ class ::FullHouse
a.gibbler_commit
#=> '4192d4cb59975813f117a51dcd4454ac16df6703'
-# "return a FullHouse history" do
+# "return a FullHouse history"
a = FullHouse.new
a.gibbler_commit
a.roles = [:jesse]
a.gibbler_commit
a.gibbler_history
#=> ['4192d4cb59975813f117a51dcd4454ac16df6703', '05219bdee8ec6300b579f2ba8ce55d851d10928b']
-# "can revert FullHouse" do
+# "can revert FullHouse"
a = FullHouse.new
a.gibbler_commit
a.roles = [:jesse]
View
42 try/59_history_exceptions_try.rb
@@ -2,30 +2,30 @@
require 'gibbler/history'
-# "raises exception when reverting to unknown gibble" do
-begin
- a = {}
- a.gibbler_commit
- a.gibbler_revert! '2222222222222222222222222222222222222222'
-rescue Gibbler::BadDigest
- :success
-end
+# "raises exception when reverting to unknown gibble"
+ begin
+ a = {}
+ a.gibbler_commit
+ a.gibbler_revert! '2222222222222222222222222222222222222222'
+ rescue Gibbler::BadDigest
+ :success
+ end
#=> :success
-# "raises exception when reverting and there's no history" do
-begin
- a = []
- a.gibbler_revert!
-rescue Gibbler::NoHistory
- :success
-end
+# "raises exception when reverting and there's no history"
+ begin
+ a = []
+ a.gibbler_revert!
+ rescue Gibbler::NoHistory
+ :success
+ end
#=> :success
-# "raises exception when reverting an unsupported object" do
-begin
- :kimmy.gibbler_revert!
-rescue NoMethodError
- :success
-end
+# "raises exception when reverting an unsupported object"
+ begin
+ :kimmy.gibbler_revert!
+ rescue NoMethodError
+ :success
+ end
#=> :success
View
57 try/90_alias_try.rb
@@ -1,48 +1,47 @@
-
require 'gibbler/aliases'
require 'gibbler/history'
# "has digest"
-:kimmy.gibbler == :kimmy.digest
+ :kimmy.gibbler == :kimmy.digest
#=> true
-# "has digest_cache", true do
-a = :kimmy.gibbler
-a.gibbler_cache == a.digest_cache
+# "has digest_cache", true
+ a = :kimmy.gibbler
+ a.gibbler_cache == a.digest_cache
#=> true
# "has changed?"
-a = "kimmy"
-a.digest
-a << '+ dj'
-a.gibbled?
+ a = "kimmy"
+ a.digest
+ a << '+ dj'
+ a.gibbled?
#=> true
-# "can convert short digest into long" do
-a = { :magic => :original }
-g = a.commit.short
-a.find_long g
+# "can convert short digest into long"
+ a = { :magic => :original }
+ g = a.commit.short
+ a.find_long g
#=> "d7049916ddb25e6cc438b1028fb957e5139f9910"
-# "can return most recent stamp" do
-a = { :magic => :original }
-a.commit
-a.stamp.class
+# "can return most recent stamp"
+ a = { :magic => :original }
+ a.commit
+ a.stamp.class
#=> Time
-# "can return history" do
-a = { :magic => :original }
-a.commit
-a[:magic] = :changed
-a.commit
-a.history
+# "can return history"
+ a = { :magic => :original }
+ a.commit
+ a[:magic] = :changed
+ a.commit
+ a.history
#=> ["d7049916ddb25e6cc438b1028fb957e5139f9910", "0b11c377fccd44554a601e5d2b135c46dc1c4cb1"]
-# "can return history (short)" do
-a = { :magic => :original }
-a.commit
-a[:magic] = :changed
-a.commit
-a.history(:short)
+# "can return history (short)"
+ a = { :magic => :original }
+ a.commit
+ a[:magic] = :changed
+ a.commit
+ a.history(:short)
#=> ["d7049916", "0b11c377"]

0 comments on commit fa50d25

Please sign in to comment.