Skip to content

Commit

Permalink
renamed everything to Rugged from Ribbit
Browse files Browse the repository at this point in the history
  • Loading branch information
schacon committed Nov 17, 2010
1 parent 5a977b9 commit b6eac62
Show file tree
Hide file tree
Showing 23 changed files with 274 additions and 248 deletions.
92 changes: 59 additions & 33 deletions README.md
Original file line number Original file line Diff line number Diff line change
@@ -1,7 +1,7 @@
Ribbit - libgit2 bindings in Ruby Rugged - libgit2 bindings in Ruby
=================================== ===================================


Ribbit is a Ruby bindings to the libgit2 linkable C Git library. This is Rugged is a Ruby bindings to the libgit2 linkable C Git library. This is
for testing and using the libgit2 library in a language that is awesome. for testing and using the libgit2 library in a language that is awesome.


INSTALLING AND RUNNING INSTALLING AND RUNNING
Expand All @@ -18,10 +18,10 @@ Next, you need to install rake-compiler:


$ sudo gem install rake-compiler $ sudo gem install rake-compiler


Now that those are installed, you can install Ribbit: Now that those are installed, you can install Rugged:


$ git clone git://github.com/libgit2/ribbit.git $ git clone git://github.com/libgit2/rubbit.git
$ cd ribbit $ cd rugged
$ rake compile $ rake compile
$ rake test $ rake test


Expand All @@ -32,10 +32,12 @@ API
There is a general library for some basic Gitty methods. So far, just converting There is a general library for some basic Gitty methods. So far, just converting
a raw sha (20 bytes) into a readable hex sha (40 char). a raw sha (20 bytes) into a readable hex sha (40 char).


raw = Ribbit::Lib.hex_to_raw(hex_sha) raw = Rugged::Lib.hex_to_raw(hex_sha)
hex = Ribbit::Lib.raw_to_hex(20_byte_raw_sha) hex = Rugged::Lib.raw_to_hex(20_byte_raw_sha)


=== Repository Access
Repository Access
-----------------


There is a Repository class that you can instantiate with a path. There is a Repository class that you can instantiate with a path.
This lets you check for objects, read raw object data, write raw object data and This lets you check for objects, read raw object data, write raw object data and
Expand All @@ -46,7 +48,7 @@ Repository is the main repository object that everything
else will emanate from. else will emanate from.


repo = repo =
Ribbit::Repository.new(path, git_dir=nil, index_path=nil) Rugged::Repository.new(path, git_dir=nil, index_path=nil)
ctnt, type = repo.read(sha) ctnt, type = repo.read(sha)
gobj = repo.lookup(sha, type[?]) # optional type argument for checking gobj = repo.lookup(sha, type[?]) # optional type argument for checking
sha = repo.write(content, type) sha = repo.write(content, type)
Expand All @@ -55,11 +57,13 @@ else will emanate from.


If Repository is initialized without `git_dir`, path + '.git' will be assumed If Repository is initialized without `git_dir`, path + '.git' will be assumed
and path will be assumed to be the working directory. If `path` is a git and path will be assumed to be the working directory. If `path` is a git
directory, then `git_dir` will be set to that and none of the Ribbit functions directory, then `git_dir` will be set to that and none of the Rugged functions
that need a working directory will work. If the `index_path` is not specified, that need a working directory will work. If the `index_path` is not specified,
the `git_dir` path plus '/index' will be assumed. the `git_dir` path plus '/index' will be assumed.


=== Object Access
Object Access
-----------------


Object is the main object class - it shouldn't be created directly, Object is the main object class - it shouldn't be created directly,
but all of these methods should be useful in it's derived classes but all of these methods should be useful in it's derived classes
Expand All @@ -72,7 +76,7 @@ but all of these methods should be useful in it's derived classes
# the repository and instantiated # the repository and instantiated
# If the 'sha' ID of the object is missing, the object will be # If the 'sha' ID of the object is missing, the object will be
# created in memory and can be written later on to the repository # created in memory and can be written later on to the repository
Ribbit::Object(repo, sha) Rugged::Object(repo, sha)
obj.sha obj.sha
obj.type obj.type


Expand All @@ -87,7 +91,7 @@ so the object can be re-written slightly differently or no parameter
to simply read the current value out to simply read the current value out


gobjc = gobjc =
Ribbit::Commit.new < Ribbit::Object Rugged::Commit.new < Rugged::Object
str = gobjc.message str = gobjc.message
str = gobjc.message_short str = gobjc.message_short
str = gobjc.message_body # TODO str = gobjc.message_body # TODO
Expand All @@ -98,51 +102,55 @@ to simply read the current value out
arr = gobjc.parents [*] # TODO arr = gobjc.parents [*] # TODO


gobtg = gobtg =
Ribbit::Tag.new < Ribbit::Object Rugged::Tag.new < Rugged::Object
gobj = gobtg.target gobj = gobtg.target
int = gobtg.target_type int = gobtg.target_type
str = gobtg.name str = gobtg.name
prsn = gobtg.tagger prsn = gobtg.tagger
str = gobtg.message str = gobtg.message


gobtr = gobtr =
Ribbit::Tree.new < Ribbit::Object Rugged::Tree.new < Rugged::Object
gobtr.add(ent) # TODO gobtr.add(ent) # TODO
gobtr.remove(name) # TODO gobtr.remove(name) # TODO
int = gobtr.entry_count int = gobtr.entry_count
ent = gobtr.get_entry ent = gobtr.get_entry


ent = ent =
Ribbit::TreeEntry.new(attributes, name, sha) Rugged::TreeEntry.new(attributes, name, sha)
int = ent.attributes int = ent.attributes
str = ent.name str = ent.name
sha = ent.sha sha = ent.sha
gobj = ent.to_object gobj = ent.to_object


// * Person information is returned as a hash table // * Person information is returned as a hash table


=== Commit Walker
Commit Walker
-----------------


There is also a Walker class that currently takes a repo object. You can push There is also a Walker class that currently takes a repo object. You can push
head SHAs onto the walker, then call next to get a list of the reachable commit head SHAs onto the walker, then call next to get a list of the reachable commit
objects, one at a time. You can also hide() commits if you are not interested in objects, one at a time. You can also hide() commits if you are not interested in
anything beneath them (useful for a `git log master ^origin/master` type deal). anything beneath them (useful for a `git log master ^origin/master` type deal).


walker = walker =
Ribbit::Walker.new(repo) Rugged::Walker.new(repo)
walker.push(hex_sha_interesting) walker.push(hex_sha_interesting)
walker.hide(hex_sha_uninteresting) walker.hide(hex_sha_uninteresting)
cmt = walker.next # false if none left cmt = walker.next # false if none left
walker.reset walker.reset




=== Index/Staging Area
Index/Staging Area
-------------------


We can inspect and manipulate the Git Index as well. We can inspect and manipulate the Git Index as well.


# the remove and add functions immediately flush to the index file on disk # the remove and add functions immediately flush to the index file on disk
index = index =
Ribbit::Index.new(repo, path=nil) # TODO: take a repo or a path Rugged::Index.new(repo, path=nil) # TODO: take a repo or a path
index.refresh # re-read the index file from disk index.refresh # re-read the index file from disk
int = index.entry_count # count of index entries int = index.entry_count # count of index entries
ent = index.get_entry(i/path) ent = index.get_entry(i/path)
Expand All @@ -153,7 +161,7 @@ We can inspect and manipulate the Git Index as well.
#TODO index.write_tree #TODO index.write_tree


ientry = ientry =
Ribbit::IndexEntry.new(index, offset) Rugged::IndexEntry.new(index, offset)
str = ientry.path str = ientry.path
time = ientry.ctime time = ientry.ctime
time = ientry.mtime time = ientry.mtime
Expand All @@ -167,7 +175,8 @@ We can inspect and manipulate the Git Index as well.
int = ientry.flags # (what flags are available?) int = ientry.flags # (what flags are available?)
int = ientry.flags_extended # (what flags are available?) int = ientry.flags_extended # (what flags are available?)


=== Index Status # TODO Index Status # TODO
-------------------


#TODO index.status # how does the index differ from the work tree and the last commit #TODO index.status # how does the index differ from the work tree and the last commit


Expand All @@ -179,20 +188,22 @@ We can inspect and manipulate the Git Index as well.
# ['file4', :unmerged], # ['file4', :unmerged],
# ] # ]


=== Ref Management # TODO
Ref Management # TODO
-------------------


The RefList class allows you to list, create and delete packed and loose refs. The RefList class allows you to list, create and delete packed and loose refs.


list = list =
Ribbit::RefList.new(repo) Rugged::RefList.new(repo)
ref = list.head # can retrieve and set HEAD with this - returns ref obj or commit obj if detatched ref = list.head # can retrieve and set HEAD with this - returns ref obj or commit obj if detatched
array = list.list([type]) # type is 'heads', 'tags', 'remotes', 'notes', et array = list.list([type]) # type is 'heads', 'tags', 'remotes', 'notes', et
list.add(oref) list.add(oref)
list.pack list.pack
list.unpack list.unpack


oref = oref =
Ribbit::Ref.new(ref, sha) Rugged::Ref.new(ref, sha)
br.name # master br.name # master
br.ref # refs/heads/master br.ref # refs/heads/master
br.type # heads br.type # heads
Expand All @@ -201,39 +212,54 @@ The RefList class allows you to list, create and delete packed and loose refs.
br.delete br.delete
br.save br.save


=== Config Management # TODO
Config Management # TODO
------------------------


conf = conf =
Ribbit::Config.new(repo) Rugged::Config.new(repo)
hash = conf.list([section]) hash = conf.list([section])
val = conf.get(key, [scope]) val = conf.get(key, [scope])
bool = conf.set(key, value, [scope]) # scope is 'local'(default), 'global', 'system' bool = conf.set(key, value, [scope]) # scope is 'local'(default), 'global', 'system'




=== Client Transport # TODO Client Transport # TODO
-----------------------


client = client =
Ribbit::Client.new(repo) Rugged::Client.new(repo)
summry = client.fetch(url, [refs]) summry = client.fetch(url, [refs])
summry = client.push(url, refs) summry = client.push(url, refs)
refs = client.refs(url) # ls-remote refs = client.refs(url) # ls-remote


=== Remote Management # TODO
Remote Management # TODO
------------------------


remlist = remlist =
Ribbit::RemoteList.new(repo) Rugged::RemoteList.new(repo)
array = remlist.list array = remlist.list
rem = remlist.add(alias, url) rem = remlist.add(alias, url)


rem = rem =
Ribbit::Remote.new(repo) Rugged::Remote.new(repo)
summry = rem.fetch([refs]) summry = rem.fetch([refs])
summry = rem.push(refs) summry = rem.push(refs)
summry = rem.remove(refs) summry = rem.remove(refs)
bool = rem.delete bool = rem.delete
heads = rem.heads heads = rem.heads




Server Transport # TODO
------------------------

server =
Rugged::Server.new
server.listen(port = 8080, ip = 0.0.0.0)
server.export_repo(path/repo)
server.export_path(path)


TODO TODO
============== ==============


Expand All @@ -246,7 +272,7 @@ be listed in the LIBGIT2_VERSION file.
CONTRIBUTING CONTRIBUTING
============== ==============


Fork libgit2/ribbit on GitHub, make it awesomer (preferably in a branch named Fork libgit2/rugged on GitHub, make it awesomer (preferably in a branch named
for the topic), send a pull request. for the topic), send a pull request.




Expand Down
10 changes: 5 additions & 5 deletions Rakefile
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ require 'rake/testtask'
require 'rake/rdoctask' require 'rake/rdoctask'
require 'rake/extensiontask' require 'rake/extensiontask'


Rake::ExtensionTask.new('ribbit') do |r| Rake::ExtensionTask.new('rugged') do |r|
r.lib_dir = 'lib/ribbit' r.lib_dir = 'lib/rugged'
end end


# #
Expand Down Expand Up @@ -66,7 +66,7 @@ if command? :ronn


desc "Build the manual" desc "Build the manual"
task "man:build" do task "man:build" do
sh "ronn -br5 --organization=SCHACON --manual='Ribbit Manual' man/*.ron" sh "ronn -br5 --organization=SCHACON --manual='Rugged Manual' man/*.ron"
end end
end end


Expand All @@ -77,13 +77,13 @@ end


begin begin
require 'mg' require 'mg'
MG.new("ribbit.gemspec") MG.new("rugged.gemspec")


desc "Push a new version to Gemcutter and publish docs." desc "Push a new version to Gemcutter and publish docs."
task :publish => "gem:publish" do task :publish => "gem:publish" do
require File.dirname(__FILE__) + '/lib/mustache/version' require File.dirname(__FILE__) + '/lib/mustache/version'


system "git tag v#{Ribbit::Version}" system "git tag v#{Rugged::Version}"
sh "git push origin master --tags" sh "git push origin master --tags"
sh "git clean -fd" sh "git clean -fd"
exec "rake pages" exec "rake pages"
Expand Down
2 changes: 1 addition & 1 deletion TODO.txt
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,4 @@
## Ribbit TODO ## ## Rugged TODO ##


* get basic object stuff working again * get basic object stuff working again
* commit parsing * commit parsing
Expand Down
8 changes: 4 additions & 4 deletions USAGE.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,13 +1,13 @@
# #
# Some example proposed usages of Ribbit # Some example proposed usages of Rugged
# so we can make sure the API design is OK # so we can make sure the API design is OK
# #


# #
# low level reading and writing # low level reading and writing
# #


repo = Ribbit::Repository.new(path_to_repo) repo = Rugged::Repository.new(path_to_repo)
if repo.exists(blob_sha) if repo.exists(blob_sha)
# reading # reading
blob_data, type = repo.read(blob_sha) blob_data, type = repo.read(blob_sha)
Expand Down Expand Up @@ -92,8 +92,8 @@ def ls_tree(tree_sha)
tree.add(entry.sha(bsha)) tree.add(entry.sha(bsha))
tsha = tree.write tsha = tree.write


new_commit = Ribbit::Commit.new new_commit = Rugged::Commit.new
person = Ribbit::Person.new("Scott", "scott@github.com", Time.now) person = Rugged::Person.new("Scott", "scott@github.com", Time.now)
commit.author(person) commit.author(person)
commit.message("updated file.txt") commit.message("updated file.txt")
commit.parents([head_sha]) commit.parents([head_sha])
Expand Down
4 changes: 2 additions & 2 deletions ext/ribbit/extconf.rb → ext/rugged/extconf.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,9 +1,9 @@
require 'mkmf' require 'mkmf'


dir_config("ribbit") dir_config("rugged")


have_library("git2") have_library("git2")
have_library('z') have_library('z')


create_makefile("ribbit") create_makefile("rugged")


Loading

0 comments on commit b6eac62

Please sign in to comment.