Browse files

add Rakefile for gem creation

  • Loading branch information...
1 parent 00a8bd9 commit 78587a2f7f409696a0e34cc3cfb62469b4aa0eae @sunaku committed Jan 26, 2008
Showing with 96 additions and 3 deletions.
  1. +58 −0 Rakefile
  2. +14 −3 bin/rumai
  3. +24 −0 lib/rumai/nfo.rb
View
58 Rakefile
@@ -0,0 +1,58 @@
+# Copyright 2007 Suraj N. Kurapati
+# See the file named LICENSE for details.
+
+require 'rake/clean'
+require 'rake/rdoctask'
+require 'rake/gempackagetask'
+
+# documentation
+ desc "Build the documentation."
+ task :doc
+
+ # the user guide
+ file 'doc/guide.html' => 'doc/guide.erb' do |t|
+ sh "gerbil html #{t.prerequisites} > #{t.name}"
+ end
+ task :doc => 'doc/guide.html'
+ CLOBBER.include 'doc/guide.html'
+
+# API reference
+ desc "Build API reference."
+ task :ref => 'doc/api'
+
+ Rake::RDocTask.new 'doc/api' do |t|
+ t.rdoc_dir = t.name
+ t.rdoc_files.exclude('_darcs', 'pkg').include('**/*.rb')
+ end
+
+# packaging
+ require 'lib/rumai/nfo' # project info
+
+ spec = Gem::Specification.new do |s|
+ s.name = Rumai::NFO[:name].downcase
+ s.version = Rumai::NFO[:version]
+ s.summary = 'Ruby interface to wmii.'
+ s.description = s.summary
+ s.homepage = Rumai::NFO[:website]
+ s.files = FileList['**/*'].exclude('_darcs')
+ s.executables = s.name
+ s.rubyforge_project = s.name
+ s.has_rdoc = true
+ end
+
+ Rake::GemPackageTask.new(spec) do |pkg|
+ pkg.need_tar = true
+ end
+
+# releasing
+ desc 'Build release packages.'
+ task :dist => [:clobber, :doc, :ref] do
+ system 'rake package'
+ end
+
+# utility
+ desc 'Upload to project website.'
+ task :upload => [:doc, :ref] do
+ sh "rsync -av doc/ ~/www/lib/#{spec.name}"
+ sh "rsync -av doc/api/ ~/www/lib/#{spec.name}/api/ --delete"
+ end
View
17 bin/rumai
@@ -20,8 +20,19 @@ module IRB
end
end
-if __FILE__ == $0
+# the basename() is for being launched by a RubyGems executable
+if __FILE__ == $0 or File.basename(__FILE__) == File.basename($0)
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
- require 'rumai'
- IRB.start_session Rumai
+
+ if ARGV.first =~ /-v|--version/i
+ require 'rumai/nfo'
+
+ puts "%s %s (%s) %s %s" % [
+ :name, :version, :release, :website, :home
+ ].map {|m| Rumai::NFO[m] }
+
+ else
+ require 'rumai'
+ IRB.start_session Rumai
+ end
end
View
24 lib/rumai/nfo.rb
@@ -0,0 +1,24 @@
+# Project information.
+#--
+# Copyright 2007 Suraj N. Kurapati
+# See the file named LICENSE for details.
+
+module Rumai
+ NFO = {
+ :name => 'Rumai',
+ :version => '1.0.0',
+ :release => '2008-01-26',
+ :website => 'http://rumai.rubyforge.org',
+ :home => File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
+ }
+
+ class << NFO
+ # Returns the name and version.
+ def to_s
+ self[:name] + ' ' + self[:version]
+ end
+
+ # throw an exception instead of returning nil
+ alias [] fetch
+ end
+end

0 comments on commit 78587a2

Please sign in to comment.