September 2008

It's a Gash, Gash, Gash

sudo gem install gash

Let me show you what I mean…

require 'gash'
wiki = Gash.new("~/programming/sources/gash/.git", "wiki")

# See, it doesn't exists yet!
wiki.branch_exists? # => false

# Lets add some files...
wiki["Start"] = "Welcome to this great [[Wiki]]!"
wiki["Wiki"] = "Something everyone can edit."

# And commit them.
wiki.commit("First verision")

# Now it exists!
wiki.branch_exists? # => true

# We can use all the regular Hash-methods too:
wiki.merge!("Start" => "Se our new section: [[Git]]",
            "Git/About" => "An awesome SCM.")

wiki["GitSCM"] = wiki.delete("Git")

wiki.commit("Adding a Git-section")

# And some special methods:
wiki["Git"].tree?                         # => true
wiki["Git/About"] == wiki["Git"]["About"] # => true
wiki["Git/About"].blob?                   # => true
wiki["Git/About"].sha1                    # => "123456789"
wiki["Git/About"].mode                    # => "100644"