require "rake/gcc4test"
require "rake/extensiontask"
+begin
+ require "rubygems"
+ require "rake/gempackagetask"
+rescue LoadError
+end
+
PKG_NAME = "ruby-vorbistagger"
PKG_VERSION = File.read("lib/ogg/vorbis/tagger.rb").
match(/^\s*VERSION = \"(.*)\"$/).captures.first
+PKG_FILES = FileList[
+ "AUTHORS", "COPYING", "README", "Rakefile",
+ "gemspec.rb",
+ "rake/{{configure,extension}task,gcc4test}.rb",
+ "ext/comments.[ch]", "ext/ext.c", "ext/vcedit.[ch]",
+ "lib/ogg/vorbis/tagger.rb",
+ "test/test_main.rb"
+]
ext_objs = [:ext, :comments, :vcedit]
task :default => [:ext]
+task :extension => [:install, :clobber]
config = Rake::ConfigureTask.new do |t|
t.tests << Rake::ConfigureTask::
task :install => [:ext] do |t|
destdir = ENV["DESTDIR"] || ""
- ddir = destdir + Config::CONFIG["sitearchdir"]
- FileUtils::Verbose.mkdir_p(ddir) unless File.directory?(ddir)
- FileUtils::Verbose.install(ext.lib_name, ddir, :mode => 0755)
+ tmp = ENV["RUBYARCHDIR"] || Config::CONFIG["sitearchdir"]
+ ddir = File.join(destdir, tmp)
+
+ unless File.expand_path(ext.lib_name) ==
+ File.join(ddir, File.basename(ext.lib_name))
+ FileUtils::Verbose.mkdir_p(ddir) unless File.directory?(ddir)
+ FileUtils::Verbose.install(ext.lib_name, ddir, :mode => 0755)
+ end
+
+ tmp = ENV["RUBYLIBDIR"] || Config::CONFIG["sitelibdir"]
+ ddir = File.join(destdir, tmp)
+
+ PKG_FILES.each do |file|
+ next unless file.pathmap("%1d") == "lib"
+
+ dest_file = file.pathmap("%{^lib,#{ddir}}p")
+
+ next if File.expand_path(file) == dest_file
- ddir = destdir + Config::CONFIG["sitelibdir"] + "ogg/vorbis"
- FileUtils::Verbose.mkdir_p(ddir) unless File.directory?(ddir)
- FileUtils::Verbose.install("lib/**/*.rb", ddir, :mode => 0644)
+ FileUtils::Verbose.mkdir_p(File.dirname(dest_file))
+ FileUtils::Verbose.install(file, dest_file, :mode => 0644)
+ end
end
task :test => [:ext]
-Rake::TestTask.new do |t|
- t.libs = ["lib", "ext", "test"]
- t.test_files = FileList["test/test_*.rb"]
+test = Rake::TestTask.new do |t|
+ t.libs = ["lib", "ext"]
t.warning = true
end
-Rake::RDocTask.new do |t|
+rdoc = Rake::RDocTask.new do |t|
t.rdoc_dir = "doc"
t.title = PKG_NAME
t.options = ["--line-numbers", "--inline-source", "--main", "README"]
- t.rdoc_files.include("README", "COPYING", "AUTHORS",
- "ext/ext.c", "ext/comments.c", "lib/**/*.rb")
+ t.rdoc_files = FileList[
+ "README", "COPYING", "AUTHORS",
+ "ext/ext.c", "ext/comments.c", "lib/ogg/vorbis/tagger.rb"
+ ]
end
-Rake::PackageTask.new(PKG_NAME, PKG_VERSION) do |t|
- t.need_tar_gz = true
- t.package_files.include("[A-Z]*", "rake/*rb", "ext/*.[ch]",
- "lib/**/*.rb", "test/*.rb")
+if defined?(Gem)
+ s = Gem::Specification.new
+ eval(File.read("gemspec.rb"))
+
+ Rake::GemPackageTask.new(s) do |t|
+ t.need_tar_gz = true
+ end
+else
+ Rake::PackageTask.new(PKG_NAME, PKG_VERSION) do |t|
+ t.need_tar_gz = true
+ t.package_files = PKG_FILES
+ end
end
task :publish => [:rdoc, :package] do
p.add(Rake::SshFreshDirPublisher.new("code-monkey.de",
"public_docs/" +
PKG_NAME, "doc"))
- p.add(Rake::SshFilePublisher.new("code-monkey.de",
- ".", "pkg",
- "#{PKG_NAME}-#{PKG_VERSION}.tar.gz"))
+
+ files = ["tar.gz"]
+ files << "gem" if defined?(Gem)
+
+ files.map! { |f| "#{PKG_NAME}-#{PKG_VERSION}.#{f}" }
+
+ p.add(Rake::SshFilePublisher.new("code-monkey.de", ".", "pkg", *files))
p.upload
end
--- /dev/null
+s.platform = Gem::Platform::RUBY
+s.name = "ruby-vorbistagger"
+s.version = PKG_VERSION
+s.summary = "Read-write interface to Vorbis comments/tags."
+s.requirements << "libvorbis"
+s.require_path = "lib"
+s.files = PKG_FILES.to_a
+s.description =<<EOT
+ruby-vorbistagger provides a read-write interface to tags used in Ogg Vorbis files (known as vorbiscomments).
+EOT
+
+s.extensions << "Rakefile"
+
+s.has_rdoc = true
+s.rdoc_options = ["--title", rdoc.title, rdoc.options].flatten
+s.extra_rdoc_files = rdoc.rdoc_files
+
+s.test_files = Dir.glob(test.pattern)
+
+s.author = "Tilman Sauerbeck"
+s.email = "tilman@code-monkey.de"
+s.homepage = "http://code-monkey.de/pages/ruby-vorbistagger"
+
+if ENV["GEM_CERT_DIR"]
+ s.signing_key = File.join(ENV["GEM_CERT_DIR"],
+ "gem-private_key.pem")
+ s.cert_chain = [File.join(ENV["GEM_CERT_DIR"],
+ "gem-public_cert.pem")]
+end