Created
August 16, 2010 21:54
-
-
Save rubiii/527822 to your computer and use it in GitHub Desktop.
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
# a cute key/value (web-)store using git and sinatra | |
# inspiration: "gittin down to the plumbing" by scott chacon | |
# http://video2010.scottishrubyconference.com/show_video/11/0 | |
get "/:key" do | |
value = retrieve params[:key] | |
halt 404 unless $?.success? | |
value | |
end | |
post "/" do | |
return unless params[:store] | |
store params[:store] | |
end | |
def store(value) | |
`echo '#{value}' | git hash-object -w --stdin` | |
end | |
def retrieve(key) | |
`git cat-file blob #{key}` | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nice!