Skip to content

Commit

Permalink
more of a proper ext setup
Browse files Browse the repository at this point in the history
  • Loading branch information
schacon committed May 7, 2010
1 parent 3d7b309 commit 6fe2ba2
Show file tree
Hide file tree
Showing 13 changed files with 205 additions and 191 deletions.
3 changes: 3 additions & 0 deletions .gitignore
@@ -0,0 +1,3 @@
*.bundle
*.swp
tmp/
1 change: 1 addition & 0 deletions API
@@ -0,0 +1 @@
Coming soon
13 changes: 8 additions & 5 deletions README
Expand Up @@ -14,13 +14,16 @@ First you need to install libgit2:
$ make
$ make install

Now that is installed, you can install Ribbit:
Next, you need to install rake-compiler:

$ sudo gem install rake-compiler

Now that those are installed, you can install Ribbit:

$ git clone git://github.com/schacon/ribbit.git
$ cd ribbit/ext
$ ruby extconf.rb
$ make
$ ./test.rb
$ cd ribbit
$ rake compile
$ rake test

That's as far as I've gotten for now. However, it does load libgit2
and at least run something from the library.
Expand Down
113 changes: 113 additions & 0 deletions Rakefile
@@ -0,0 +1,113 @@
# stolen largely from defunkt/mustache
require 'rake/testtask'
require 'rake/rdoctask'
require 'rake/extensiontask'

Rake::ExtensionTask.new('ribbit')

#
# Helpers
#

def command?(command)
system("type #{command} > /dev/null")
end


#
# Tests
#

task :default => :test

if command? :turn
desc "Run tests"
task :test do
suffix = "-n #{ENV['TEST']}" if ENV['TEST']
sh "turn test/*.rb #{suffix}"
end
else
Rake::TestTask.new do |t|
t.libs << 'lib'
t.pattern = 'test/**/*_test.rb'
t.verbose = false
end
end

if command? :kicker
desc "Launch Kicker (like autotest)"
task :kicker do
puts "Kicking... (ctrl+c to cancel)"
exec "kicker -e rake test lib examples"
end
end


#
# Ron
#

if command? :ronn
desc "Show the manual"
task :man => "man:build" do
exec "man man/mustache.1"
end

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


#
# Gems
#

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

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

system "git tag v#{Ribbit::Version}"
sh "git push origin master --tags"
sh "git clean -fd"
exec "rake pages"
end
rescue LoadError
warn "mg not available."
warn "Install it with: gem i mg"
end

#
# Documentation
#

begin
require 'sdoc_helpers'
rescue LoadError
warn "sdoc support not enabled. Please gem install sdoc-helpers."
end

desc "Publish to GitHub Pages"
task :pages => [ "man:build" ] do
Dir['man/*.html'].each do |f|
cp f, File.basename(f).sub('.html', '.newhtml')
end

`git commit -am 'generated manual'`
`git checkout site`

Dir['*.newhtml'].each do |f|
mv f, f.sub('.newhtml', '.html')
end

`git add .`
`git commit -m updated`
`git push site site:master`
`git checkout master`
puts :done
end
157 changes: 0 additions & 157 deletions ext/Makefile

This file was deleted.

21 changes: 0 additions & 21 deletions ext/ribbit.c

This file was deleted.

File renamed without changes.
18 changes: 18 additions & 0 deletions ext/ribbit/ribbit.c
@@ -0,0 +1,18 @@
#include "ruby.h"

static VALUE rb_cRibbit;

static VALUE
compare_prefix(VALUE self, VALUE string1, VALUE string2)
{
return git__prefixcmp(string1, string2);
}

void
Init_ribbit()
{
rb_cRibbit = rb_define_class("Ribbit", rb_cObject);

rb_define_method(rb_cRibbit, "compare_prefix", compare_prefix, 2);
}

8 changes: 0 additions & 8 deletions ext/test.rb

This file was deleted.

3 changes: 3 additions & 0 deletions lib/ribbit/version.rb
@@ -0,0 +1,3 @@
class Ribbit
Version = VERSION = '0.0.1'
end
20 changes: 20 additions & 0 deletions ribbit.gemspec
@@ -0,0 +1,20 @@
require 'lib/ribbit/version'

Gem::Specification.new do |s|
s.name = "ribbit"
s.version = Ribbit::Version
s.date = Time.now.strftime('%Y-%m-%d')
s.summary = "Ribbit is a Ruby binding to the libgit2 linkable library"
s.homepage = "http://github.com/schacon/ribbit"
s.email = "schacon@gmail.com"
s.authors = [ "Scott Chacon" ]
s.files = %w( README API Rakefile LICENSE )
s.files += Dir.glob("lib/**/*")
s.files += Dir.glob("man/**/*")
s.files += Dir.glob("test/**/*")
s.extensions = ['ext/ribbit/extconf.rb']
s.description = <<desc
Ribbit 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.
desc
end
13 changes: 13 additions & 0 deletions test/strutil_test.rb
@@ -0,0 +1,13 @@
require File.dirname(__FILE__) + '/test_helper'

context "Ribbit strutils" do
setup do
@ribbit = Ribbit.new
end

test "can compare prefixes" do
puts @ribbit.compare_prefix("aa", "ab")
assert_equal 1, 1
end

end

0 comments on commit 6fe2ba2

Please sign in to comment.