Browse files

Shift away from rakehelp

git-svn-id: http://rev.rubyforge.org/svn/trunk@164 ea6e6bc6-682b-4e20-bb59-304e6edd756d
  • Loading branch information...
1 parent 7aa136d commit 5ec5f2559a540b5b88eed2a393b46699c213bd53 tarcieri committed Feb 17, 2008
Showing with 87 additions and 117 deletions.
  1. +1 −1 README
  2. +58 −14 Rakefile
  3. +1 −2 ext/rev/rev_buffer.c
  4. +27 −0 rev.gemspec
  5. +0 −100 tools/rakehelp.rb
View
2 README
@@ -120,7 +120,7 @@ haven't overridden them in a subclass). This is especially useful for small
one off programs or just experimenting with the API.
Any callback (methods prefixed with on_*) can be set on the fly by passing it
-a block.
+a block. (NOTE: Ruby 1.9 only)
Below is an example of using this syntax. It implements an echo server
identical to the one above:
View
72 Rakefile
@@ -1,26 +1,70 @@
require 'rake'
-require 'rake/testtask'
require 'rake/clean'
-require 'rake/gempackagetask'
require 'rake/rdoctask'
-require 'tools/rakehelp'
+require 'rake/gempackagetask'
require 'fileutils'
include FileUtils
-setup_tests
-setup_clean ['ext/rev/Makefile', 'pkg']
-setup_rdoc ['README', 'LICENSE', 'lib/**/*.rb', 'doc/**/*.rdoc', 'ext/rev/*.c']
+# Load Rev Gemspec
+load 'rev.gemspec'
-desc "Does a full compile, test run"
-task :default => [:compile] #, :test]
+# Default Rake task is compile
+task :default => :compile
-desc "Compiles all extensions"
-task :compile => [:rev_ext, :http11_client]
-task :package => [:clean]
+# RDoc
+Rake::RDocTask.new(:rdoc) do |task|
+ task.rdoc_dir = 'doc'
+ task.title = 'Rev'
+ task.options = %w(--title Revactor --main README --line-numbers)
+ task.rdoc_files.include(['lib/**/*.rb', 'doc/**/*.rdoc', 'ext/rev/*.c'])
+ task.rdoc_files.include(['README', 'LICENSE'])
+end
+
+# Gem
+Rake::GemPackageTask.new(GEMSPEC) do |pkg|
+ pkg.need_tar = true
+end
+
+def make(makedir)
+ Dir.chdir(makedir) { sh 'make' }
+end
+
+def extconf(dir)
+ Dir.chdir(dir) { ruby "extconf.rb" }
+end
+
+def setup_extension(dir, extension)
+ ext = "ext/#{dir}"
+ ext_so = "#{ext}/#{extension}.#{Config::CONFIG['DLEXT']}"
+ ext_files = FileList[
+ "#{ext}/*.c",
+ "#{ext}/*.h",
+ "#{ext}/extconf.rb",
+ "#{ext}/Makefile",
+ "lib"
+ ]
+
+ task "lib" do
+ directory "lib"
+ end
+
+ desc "Builds just the #{extension} extension"
+ task extension.to_sym => ["#{ext}/Makefile", ext_so ]
+
+ file "#{ext}/Makefile" => ["#{ext}/extconf.rb"] do
+ extconf "#{ext}"
+ end
+
+ file ext_so => ext_files do
+ make "#{ext}"
+ cp ext_so, "lib"
+ end
+end
setup_extension("rev", "rev_ext")
setup_extension("http11_client", "http11_client")
-summary = "Ruby binding to the libev high performance event library"
-test_file = "spec/rev_spec.rb"
-setup_gem("rev", "0.2.0", "Tony Arcieri", summary, [], test_file)
+task :compile => [:rev_ext, :http11_client]
+
+CLEAN.include ['build/*', '**/*.o', '**/*.so', '**/*.a', 'lib/*-*', '**/*.log']
+CLEAN.include ['ext/rev/Makefile', 'lib/rev_ext.*', 'lib/http11_client.*']
View
3 ext/rev/rev_buffer.c
@@ -73,8 +73,7 @@ static int buffer_read_from(struct buffer *buf, int fd);
static int buffer_write_to(struct buffer *buf, int fd);
/*
- * High speed buffering geared towards non-blocking I/O. This was largely
- * written in response to String#slice! being incredibly slow in Ruby 1.9.
+ * High speed buffering geared towards non-blocking I/O.
*
* Data is stored in a byte queue implemented as a linked list of equal size
* chunks. Since every node in the list is the same size they are easily
View
27 rev.gemspec
@@ -0,0 +1,27 @@
+require 'rubygems'
+
+GEMSPEC = Gem::Specification.new do |s|
+ s.name = "rev"
+ s.version = "0.2.0"
+ s.authors = "Tony Arcieri"
+ s.email = "tony@medioh.com"
+ s.date = "2008-2-16"
+ s.summary = "Rev is a Ruby binding to the libev high performance event library"
+ s.platform = Gem::Platform::RUBY
+ s.required_ruby_version = '>= 1.8.6'
+
+ # Gem contents
+ s.files = Dir.glob("{lib,ext,examples}/**/*") + ['Rakefile', 'rev.gemspec']
+
+ # RubyForge info
+ s.homepage = "http://rev.rubyforge.org"
+ s.rubyforge_project = "rev"
+
+ # RDoc settings
+ s.has_rdoc = true
+ s.rdoc_options = %w(--title Rev --main README --line-numbers)
+ s.extra_rdoc_files = ["LICENSE", "README", "CHANGES"]
+
+ # Extensions
+ s.extensions = FileList["ext/**/extconf.rb"].to_a
+end
View
100 tools/rakehelp.rb
@@ -1,100 +0,0 @@
-
-def make(makedir)
- Dir.chdir(makedir) do
- sh 'make'
- end
-end
-
-
-def extconf(dir)
- Dir.chdir(dir) do ruby "extconf.rb" end
-end
-
-
-def setup_tests
- Rake::TestTask.new do |t|
- t.libs << "test"
- t.test_files = FileList['test/test*.rb']
- t.verbose = true
- end
-end
-
-
-def setup_clean otherfiles
- files = ['build/*', '**/*.o', '**/*.so', '**/*.a', 'lib/*-*', '**/*.log'] + otherfiles
- CLEAN.include(files)
-end
-
-
-def setup_rdoc files
- Rake::RDocTask.new do |rdoc|
- rdoc.rdoc_dir = 'doc/rdoc'
- rdoc.options = %w{--title Rev --main README --line-numbers}
- rdoc.rdoc_files.add(files)
- end
-end
-
-
-def setup_extension(dir, extension)
- ext = "ext/#{dir}"
- ext_so = "#{ext}/#{extension}.#{Config::CONFIG['DLEXT']}"
- ext_files = FileList[
- "#{ext}/*.c",
- "#{ext}/*.h",
- "#{ext}/extconf.rb",
- "#{ext}/Makefile",
- "lib"
- ]
-
- task "lib" do
- directory "lib"
- end
-
- desc "Builds just the #{extension} extension"
- task extension.to_sym => ["#{ext}/Makefile", ext_so ]
-
- file "#{ext}/Makefile" => ["#{ext}/extconf.rb"] do
- extconf "#{ext}"
- end
-
- file ext_so => ext_files do
- make "#{ext}"
- cp ext_so, "lib"
- end
-end
-
-
-def setup_gem(pkg_name, pkg_version, author, summary, executables, test_file)
- pkg_version = pkg_version
- pkg_name = pkg_name
- pkg_file_name = "#{pkg_name}-#{pkg_version}"
-
- spec = Gem::Specification.new do |s|
- s.name = pkg_name
- s.version = pkg_version
- s.platform = Gem::Platform::RUBY
- s.author = author
- s.summary = summary
- s.test_file = test_file
- s.has_rdoc = true
- s.extra_rdoc_files = ["README", "LICENSE"] + FileList["ext/**/*.c"]
- s.rdoc_options = %w(--title Rev --main README --line-numbers)
- s.required_ruby_version = '>= 1.8.6'
-
- s.files = %w(LICENSE README) +
- Dir.glob("{lib,doc,test}/**/*") +
- Dir.glob("ext/**/*.{h,c,rb}")
-
- s.require_path = "lib"
- s.extensions = FileList["ext/**/extconf.rb"].to_a
-
- s.executables = executables
- s.bindir = "bin"
- end
-
- Rake::GemPackageTask.new(spec) do |p|
- p.gem_spec = spec
- p.need_tar = true
- p.need_zip = true
- end
-end

0 comments on commit 5ec5f25

Please sign in to comment.