Commit 9e15cc51 authored by Cédric Boutillier's avatar Cédric Boutillier

Imported Upstream version 1.4.3.0001

parent 6047d6a3
language: ruby
rvm:
- 1.9.3
- 1.8.7
- rbx-18mode
gemfile:
- gemfiles/Gemfile.travis-ruby1.9
- gemfiles/Gemfile.travis-ruby1.8
before_install:
- mkdir /tmp/bioruby
- ruby gemfiles/modify-Gemfile.rb
- ruby gemfiles/prepare-gemspec.rb
matrix:
include:
- rvm: 1.9.2
gemfile: gemfiles/Gemfile.travis-ruby1.9
- rvm: rbx-19mode
gemfile: gemfiles/Gemfile.travis-jruby1.9
- rvm: jruby-19mode
gemfile: gemfiles/Gemfile.travis-jruby1.9
env: TMPDIR=/tmp/bioruby
- rvm: 1.9.3
gemfile: gemfiles/Gemfile.travis-ruby1.9
env: BIORUBY_RAKE_DEFAULT_TASK=tar-integration-test
- rvm: 1.9.3
gemfile: gemfiles/Gemfile.travis-ruby1.9
env: BIORUBY_RAKE_DEFAULT_TASK=gem-test
- rvm: jruby-18mode
gemfile: gemfiles/Gemfile.travis-jruby1.8
env: TMPDIR=/tmp/bioruby BIORUBY_RAKE_DEFAULT_TASK=tar-integration-test
- rvm: jruby-18mode
gemfile: gemfiles/Gemfile.travis-jruby1.8
env: TMPDIR=/tmp/bioruby BIORUBY_RAKE_DEFAULT_TASK=gem-test
exclude:
- rvm: 1.8.7
gemfile: gemfiles/Gemfile.travis-ruby1.9
- rvm: 1.9.3
gemfile: gemfiles/Gemfile.travis-ruby1.8
- rvm: rbx-18mode
gemfile: gemfiles/Gemfile.travis-ruby1.9
allow_failures:
- rvm: rbx-19mode
gemfile: gemfiles/Gemfile.travis-jruby1.9
- rvm: jruby-19mode
gemfile: gemfiles/Gemfile.travis-jruby1.9
env: TMPDIR=/tmp/bioruby
- rvm: jruby-18mode
gemfile: gemfiles/Gemfile.travis-jruby1.8
env: TMPDIR=/tmp/bioruby BIORUBY_RAKE_DEFAULT_TASK=tar-integration-test
- rvm: jruby-18mode
gemfile: gemfiles/Gemfile.travis-jruby1.8
env: TMPDIR=/tmp/bioruby BIORUBY_RAKE_DEFAULT_TASK=gem-test
# uncomment this line if your project needs to run something other than `rake`:
# script: bundle exec rspec spec
#before_install:
# - sudo apt-get update
# - sudo apt-get install libxml2-dev libexpat1-dev
# whitelist branches
branches:
only:
- master
This diff is collapsed.
= KNOWN_ISSUES.rdoc - Known issues and bugs in BioRuby
Copyright:: Copyright (C) 2009 Naohisa Goto <ng@bioruby.org>
Copyright:: Copyright (C) 2009-2012 Naohisa Goto <ng@bioruby.org>
License:: The Ruby License
= Known issues and bugs in BioRuby
......@@ -15,7 +15,7 @@ they are not BioRuby's issues and/or it is very difficult to fix them.
=== Ruby 1.9.1 or later
Some classes/modules/methods still may not work or may return incorrect
results in Ruby 1.9.1, especially those not covered by the unit tests.
results in Ruby 1.9.X, especially those not covered by the unit tests.
==== String encodings
......@@ -66,6 +66,48 @@ deprecated in RubyGems 0.9.0 and removed in RubyGems 1.0.1.
require 'rubygems'
require_gem 'bio'
=== JRuby
On JRuby, errors may be raised due to the following unfixed bugs in JRuby.
* {JRUBY-6195}[http://jira.codehaus.org/browse/JRUBY-6195] Process.spawn
(and related methods) ignore option hash
* {JRUBY-6818}[http://jira.codehaus.org/browse/JRUBY-6818] Kernel.exec,
Process.spawn (and IO.popen etc.) raise error when program is an array
containing two strings
(WONT_FIX) With older version of JRuby, you may be bothered by the following
bugs that have already been fixed in the head of JRuby.
* {JRUBY-6658}[http://jira.codehaus.org/browse/JRUBY-6658] Problem when
setting up an autoload entry, defining a class via require, then redefining
the autoload entry
* {JRUBY-6666}[http://jira.codehaus.org/browse/JRUBY-6666] Open3.popen3
failing due to missing handling for [path, argv[0]] array
* {JRUBY-6819}[http://jira.codehaus.org/browse/JRUBY-6819]
java.lang.ArrayIndexOutOfBoundsException in String#each_line
(WONT_FIX) Due to JRUBY-5678 (resolved issue) and the difference of behavior
between CRuby and JRuby written in the comments of the issue tracking page,
when running BioRuby on JRuby with sudo or root rights, TMPDIR environment
variable should be set to a directory that is not world-writable. Currently,
the workaround is needed for running BioRuby tests with JRuby on Travis-CI.
* {JRUBY-5678}[http://jira.codehaus.org/browse/JRUBY-5678] tmpdir cannot
be delete when jruby has sudo/root rights
=== Rubinius
According to Travis-CI, unit tests have failed on 1.9 mode of Rubinius.
(WONT_FIX) With older version of Rubinius, you may be bothered by the
following bugs that have already been fixed in the head of Rubinius.
* {Rubinius Issue #1693}[https://github.com/rubinius/rubinius/issues/1693]
String#split gives incorrect output when splitting by /^/
* {Rubinius Issue #1724}[https://github.com/rubinius/rubinius/issues/1724]
Creating Struct class with length attribute
== 2. OS and/or architecture-dependent issues
=== Microsoft Windows
......@@ -104,6 +146,14 @@ Windows 95/98/98SE/ME because of the limitation of COMMAND.COM.
== 3. Known issues and bugs in BioRuby
=== DDBJ Web API related classes (Bio::DDBJ::*, Bio::BLAST::Remote::DDBJ)
The DDBJ Web API is stopping after their system replacement in March 2012.
(See the announcement though it is written only in Japanese:
http://www.ddbj.nig.ac.jp/replace/rp120601-j.html)
Due to the stop of the DDBJ Web API, Bio::DDBJ::* and Bio::BLAST::Remote::DDBJ
which are using the web API can not be used.
=== Bio::Ensembl
Due to the renewal of Ensembl web site, Bio::Ensembl does not work for
......@@ -135,6 +185,15 @@ because of the growth of the data size.
Bio::SPTR should be updated to follow UniProtKB format changes described
in http://www.uniprot.org/docs/sp_news.htm .
=== http://bioruby.org/cgi-bin/biofetch.rb and Bio::Fetch.query
BioRuby's default BioFetch server http://bioruby.org/cgi-bin/biofetch.rb is
down for years. Please use other server, such as EBI Dbfetch
(http://www.ebi.ac.uk/Tools/dbfetch/dbfetch).
Due to the stop of the http://bioruby.org/cgi-bin/biofetch.rb service,
Bio::Fetch.query always raises error.
== 4. Compatibility issues with other libraries/extensions
=== ActiveRecord
......@@ -147,6 +206,12 @@ know which version is suitable.
BioRuby Shell on Web uses Ruby on Rails, but the author of the document does
not know which version is suitable.
==== SOAP4R with Ruby 1.9
soap4r-ruby1.9 may raise "ununitialized constant XML::SaxParser" error with
some combinations of XML parser libraries. It seems this is a bug of
soap4r-ruby1.9.
== 5. Historical descriptions
=== CVS
......
......@@ -2,6 +2,7 @@
= README.rdoc - README for BioRuby
Copyright:: Copyright (C) 2001-2007 Toshiaki Katayama <k@bioruby.org>,
Copyright (C) 2008 Jan Aerts <jandot@bioruby.org>
Copyright (C) 2011-2012 Naohisa Goto <ng@bioruby.org>
License:: The Ruby License
* The above statement is limited to this file. See below about BioRuby's
copyright and license.
......@@ -9,7 +10,7 @@ License:: The Ruby License
= BioRuby
Copyright (C) 2001-2011 Toshiaki Katayama <k@bioruby.org>
Copyright (C) 2001-2012 Toshiaki Katayama <k@bioruby.org>
BioRuby is an open source Ruby library for developing bioinformatics
software. Object oriented scripting language Ruby has many features
......@@ -35,13 +36,16 @@ services including KEGG API can be easily utilized by BioRuby.
== FOR MORE INFORMATION
See RELEASE_NOTES.rdoc for news and important changes in this version.
=== Documents in this distribution
==== General information
==== Release notes, important changes and issues
README.rdoc:: This file. General information and installation procedure.
RELEASE_NOTES.rdoc:: News and important changes in this release.
KNOWN_ISSUES.rdoc:: Known issues and bugs in BioRuby.
doc/RELEASE_NOTES-1.4.2.rdoc:: News and incompatible changes from 1.4.1 to 1.4.2.
doc/RELEASE_NOTES-1.4.1.rdoc:: News and incompatible changes from 1.4.0 to 1.4.1.
doc/RELEASE_NOTES-1.4.0.rdoc:: News and incompatible changes from 1.3.1 to 1.4.0.
doc/Changes-1.3.rdoc:: News and incompatible changes from 1.2.1 to 1.3.0.
......@@ -56,6 +60,7 @@ doc/KEGG_API.rd:: Documents about KEGG API, including usage of Bio::KEGG::API.
==== BioRuby development
ChangeLog:: History of changes.
doc/ChangeLog-before-1.4.2:: changes before 1.4.2.
doc/ChangeLog-before-1.3.1:: changes before 1.3.1.
README_DEV.rdoc:: Describes ways to contribute to the BioRuby project, including coding styles and documentation guidelines.
......@@ -65,6 +70,9 @@ doc/Tutorial.rd.ja:: BioRuby Tutorial written in Japanese.
doc/Tutorial.rd.ja.html:: HTML version of Tutorial.rd.ja.
doc/KEGG_API.rd.ja:: Japanese translation of KEGG_API.rd.
==== Sample codes
In sample/, There are many sample codes and demo scripts.
=== WWW
......@@ -107,38 +115,54 @@ and can be obtained by the following procedure:
== REQUIREMENTS
* Ruby 1.8.6 or later (except Ruby 1.9.0) -- http://www.ruby-lang.org/
* Ruby 1.8.7-p352 or later is recommended.
* Not yet fully ready with Ruby 1.9, although many components can now work
in Ruby 1.9.1 and Ruby 1.9.2.
* Ruby 1.9.3-p194 or later, or Ruby 1.8.7-p358 or later is recommended.
* See KNOWN_ISSUES.rdoc for Ruby version specific problems.
== OPTIONAL REQUIREMENTS
Some optional libraries can be utilized to extend BioRuby's functionality.
If your needs meets the following conditions, install them from the "Ruby
Application Archive" at http://raa.ruby-lang.org/, RubyForge at
http://rubyforge.org/, or the following web sites.
If your needs meets the following conditions, install them by using RubyGems,
or download and install from the "Ruby Application Archive" (RAA) at
http://raa.ruby-lang.org/, RubyForge at http://rubyforge.org/, GitHub at
http://github.com/, or the following web sites.
For faster parsing of the BLAST XML output format:
* {RAA:xmlparser}[http://raa.ruby-lang.org/project/xmlparser/]
* For Ruby 1.8: {gem install xmlparser}[http://rubygems.org/gems/xmlparser]
* For Ruby 1.9: http://www.yoshidam.net/Ruby.html#xmlparser
* In both cases, {The Expat XML Parser}[http://expat.sourceforge.net/]
and C compiler will be required.
Creating faster flatfile index using Berkley DB:
* {RAA:bdb}[http://raa.ruby-lang.org/project/bdb/]
* {GitHub:ruby-bdb}[https://github.com/knu/ruby-bdb]
(which took over {RAA:bdb}[http://raa.ruby-lang.org/project/bdb/])
(No RubyGems available)
* {Oracle Berkeley DB}[http://www.oracle.com/technetwork/database/berkeleydb/index.html] and C compiler will be required.
Accessing BioSQL database created by other Open Bio* libraries:
* {RubyForge:ActiveRecord}[http://rubyforge.org/projects/activerecord/]
and at least one driver (or adapter) from
{RubyForge:MySQL/Ruby}[http://rubyforge.org/projects/mysql-ruby/],
{RubyForge:postgres-pr}[http://rubyforge.org/projects/postgres-pr], or
{RubyForge:ActiveRecord Oracle enhanced adapter}[http://rubyforge.org/projects/oracle-enhanced/].
* {gem install activerecord}[http://rubygems.org/gems/activerecord]
and at least one driver (or adapter):
* {gem install mysql}[http://rubygems.org/gems/mysql] or
{gem install mysql2}[http://rubygems.org/gems/mysql2]
* {gem install pg}[http://rubygems.org/gems/pg]
* {gem install sqlite-ruby}[http://rubygems.org/gems/sqlite-ruby] or
{gem install sqlite3}[http://rubygems.org/gems/sqlite3]
* {gem install activerecord-oracle_enhanced-adapter}[http://rubygems.org/gems/activerecord-oracle_enhanced-adapter]
For parsing PhyloXML format files:
* {RubyForge:libxml-ruby}[http://libxml.rubyforge.org/] (Ruby language
bindings for the {GNOME Libxml2 XML toolkit}[http://xmlsoft.org/])
* {gem install libxml-ruby}[http://rubygems.org/gems/libxml-ruby]
* {GNOME Libxml2 XML toolkit}[http://xmlsoft.org/] and C compiler will be
required.
(Only for Ruby 1.9.x) For using SOAP web services e.g. KEGG API:
* {gem install soap4r-ruby1.9}[https://rubygems.org/gems/soap4r-ruby1.9]
* For Ruby 1.8.x, SOAP4R is bundled within the Ruby 1.8.x release.
== INSTALL
......@@ -147,7 +171,7 @@ For parsing PhyloXML format files:
If you are using RubyGems, just type
% gems install bio
% gem install bio
Alternatively, manually download bio-X.X.X.gem from
http://rubyforge.org/projects/bioruby/ and install it by using gems command.
......@@ -180,17 +204,46 @@ The options "config", "setup", and "install" are still available.
% su
# ruby setup.rb install
You can run tests by
% ruby setup.rb test
and run
You can run
% ruby setup.rb --help
for more details.
=== Running self-test
To check if bioruby works fine on a machine, self-test codes are bundled.
Note that some tests may need internet connection.
To run tests,
% ruby test/runner.rb
If you are using Ruby 1.8.x and you want to use components installed by using
RubyGems, explicit loading of RubyGems may be needed.
% ruby -rubygems test/runner.rb
Alternatively, testrb, the test runner command of ruby, can be used.
% testrb test/
With testrb, you can select tests to run, for example,
% testrb test/unit
For those familiar with Rake,
% rake test
also works.
Before reporting test failure, please check KNOWN_ISSUES.rdoc about known
platform-dependent issues. We are happy if you write patches to solve the
issues.
== SETUP
If you want to use the OBDA (Open Bio Database Access) to obtain database
......@@ -255,6 +308,19 @@ under different license. For example, setup.rb which comes from
(http://i.loveruby.net/en/projects/setup/) is licensed under LGPL 2.1.
== REFERENCE
If you use BioRuby in academic research, please consider citing the following
publication.
* BioRuby: Bioinformatics software for the Ruby programming language.
Naohisa Goto, Pjotr Prins, Mitsuteru Nakao, Raoul Bonnal, Jan Aerts and
Toshiaki Katayama.
Bioinformatics (2010) 26(20): 2617-2619.
* {doi: 10.1093/bioinformatics/btq475}[http://bioinformatics.oxfordjournals.org/content/26/20/2617]
* {PMID: 20739307}[http://www.ncbi.nlm.nih.gov/pubmed/20739307]
== CONTACT
Current staff of the BioRuby project can be reached by sending e-mail
......
......@@ -2,6 +2,7 @@
Copyright:: Copyright (C) 2005, 2006 Toshiaki Katayama <k@bioruby.org>
Copyright:: Copyright (C) 2006, 2008 Jan Aerts <jandot@bioruby.org>
Copyright:: Copyright (C) 2011 Naohisa Goto <ng@bioruby.org>
= HOW TO CONTRIBUTE TO THE BIORUBY PROJECT?
......@@ -13,8 +14,9 @@ such as:
* Add and correct documentation
* Develop code for new features, etc.
All of these are welcome! However, this document describes the last option,
how to contribute your code to the BioRuby distribution.
All of these are welcome! This document mainly focuses on the last option,
how to contribute your code to the BioRuby distribution. This may also be
helpful when you send large patches for existing codes.
We would like to include your contribution as long as the scope of
your module meets the field of bioinformatics.
......@@ -25,6 +27,46 @@ Bioruby is now under git source control at http://github.com/bioruby/bioruby.
There are two basic ways to contribute: with patches or pull requests. Both are
explained on the bioruby wiki at http://bioruby.open-bio.org/wiki.
=== Preparation before sending patches or pull requests
Before sending patches or pull requests, rewriting history and reordering or
selecting patches are recommended. See "Creating the perfect patch series"
in the Git User's Manual.
http://www.kernel.org/pub/software/scm/git/docs/user-manual.html#patch-series
=== Sending your contribution
==== With patches
You can send patches with git-format-patch. For a smaller change, unified
diff (diff -u) without using git can also be accepted.
==== With pull requests
We are happy if your commits can be pulled with fast-forward. For the purpose,
using git-rebase before sending pull request is recommended. See "Keeping a
patch series up to date using git rebase" in the Git User's Manual.
http://www.kernel.org/pub/software/scm/git/docs/user-manual.html#using-git-rebase
=== Notes for the treatment of contributions in the blessed repository
==== Merging policy
We do not always merge your commits as is. We may edit, rewrite, reorder,
select, and/or mix your commits before and/or after merging to the blessed
repository.
==== Git commit management policy
We want to keep the commit history linear as far as possible, because it is
easy to find problems and regressions in commits. See "Why bisecting merge
commits can be harder than bisecting linear history" in the Git User's Manual.
http://www.kernel.org/pub/software/scm/git/docs/user-manual.html#bisect-merges
Note that the above policy is only for the main 'blessed' repository, and it
does not aim to restrict each user's fork.
= LICENSE
If you would like your module to be included in the BioRuby distribution,
......@@ -50,6 +92,11 @@ You will need to follow the typical coding styles of the BioRuby modules:
* Use 2 spaces for indentation.
* Don't replace spaces to tabs.
== Parenthesis in the method definition line should be written
* Good: <tt>def example(str, ary)</tt>
* Discouraged: <tt>def example str, ary</tt>
== Comments
Don't use <tt>=begin</tt> and <tt>=end</tt> blocks for comments. If you need to
......@@ -202,6 +249,24 @@ format of this information is as follows:
Attribute accessors can be preceded by a short description.
# P-value (Float)
attr_reader :pvalue
For writing rdoc documentation, putting two or more attributes in a line
(such as <tt>attr_reader :evalue, :pvalue</tt>) is strongly discouraged.
Methods looks like attributes can also be preceded by a short description.
# Scientific name (String)
def scientific_name
#...
end
# Scientific name (String)
def scientific_name=(str)
#...
end
== Exception handling
Don't use
......@@ -211,6 +276,12 @@ Don't use
in your code. Instead, try to avoid printing error messages. For fatal errors,
use +raise+ with an appropriate message.
Kernel#warn can only be used to notice incompatible changes to programmers.
Typically it may be used for deprecated or obsolete usage of a method.
For example,
warn "The Foo#bar method is obsoleted. Use Foo#baz instead."
== Testing code should use 'test/unit'
Unit tests should come with your modules by which you can assure what
......@@ -283,3 +354,23 @@ a new module or making changes on existing modules.
Finally, please maintain the code you've contributed. Please let us know (on
the bioruby list) before you commit, so that users can discuss on the change.
= RUBY VERSION and IMPLEMENTATION
We are mainly using Ruby MRI (Matz' Ruby Implementation, or Matz' Ruby
Interpreter). Please confirm that your code is running on current stable
release versions of Ruby MRI.
We are very happy if your code can run on both Ruby 1.8.x and 1.9.x.
Note that Ruby 1.9.0 should be ignored because it was discontinued.
Ruby 1.8.5 or earlier versions can also be ignored. See README.rdoc and
RELEASE_NOTES.rdoc for recommended Ruby versions.
It is welcome to support JRuby, Rubinius, etc, in addition to Ruby MRI.
Of course, it is strongly encouraged to write code that is not affected by
differences between Ruby versions and/or implementations, as far as possible.
= OS and ARCHITECTURE
We hope BioRuby can be run on both UNIX (and UNIX-like OS) and Microsoft
Windows.
This diff is collapsed.
#
# = Rakefile - helper of developement and packaging
#
# Copyright:: Copyright (C) 2009 Naohisa Goto <ng@bioruby.org>
# Copyright:: Copyright (C) 2009, 2012 Naohisa Goto <ng@bioruby.org>
# License:: The Ruby License
#
require 'rubygems'
require 'erb'
require 'pathname'
require 'fileutils'
require 'tmpdir'
require 'rake/testtask'
require 'rake/packagetask'
require 'rake/gempackagetask'
require 'rake/rdoctask'
begin
require 'rubygems/package_task'
rescue LoadError
# old RubyGems/Rake version
require 'rake/gempackagetask'
end
begin
require 'rdoc/task'
rescue LoadError
# old RDoc/Rake version
require 'rake/rdoctask'
end
# workaround for new module name
unless defined? Rake::GemPackageTask then
Rake::GemPackageTask = Gem::PackageTask
end
load "./lib/bio/version.rb"
BIO_VERSION_RB_LOADED = true
......@@ -25,12 +45,22 @@ extraversion = nil if extraversion.to_s.empty?
BIORUBY_VERSION = version
BIORUBY_EXTRA_VERSION = extraversion
task :default => "test"
task :default => "see-env"
Rake::TestTask.new do |t|
t.test_files = FileList["test/{unit,functional}/**/test_*.rb"]
end
Rake::TestTask.new do |t|
t.name = :"test-all"
t.test_files = FileList["test/{unit,functional,network}/**/test_*.rb"]
end
Rake::TestTask.new do |t|
t.name = :"test-network"
t.test_files = FileList["test/network/**/test_*.rb"]
end
# files not included in gem but included in tar archive
tar_additional_files = []
......@@ -38,7 +68,9 @@ GEM_SPEC_FILE = "bioruby.gemspec"
GEM_SPEC_TEMPLATE_FILE = "bioruby.gemspec.erb"
# gets gem spec string
gem_spec_string = ERB.new(File.read(GEM_SPEC_TEMPLATE_FILE)).result
gem_spec_string = File.open(GEM_SPEC_TEMPLATE_FILE, "rb") do |f|
ERB.new(f.read).result
end
# gets gem spec object
spec = eval(gem_spec_string)
......@@ -68,7 +100,7 @@ desc "Update #{GEM_SPEC_FILE}"
file GEM_SPEC_FILE => [ GEM_SPEC_TEMPLATE_FILE, 'Rakefile',
'lib/bio/version.rb' ] do |t|
puts "creates #{GEM_SPEC_FILE}"
File.open(t.name, 'w') do |w|
File.open(t.name, 'wb') do |w|
w.print gem_spec_string
end
end
......@@ -77,12 +109,20 @@ task :package => [ GEM_SPEC_FILE ] do
Rake::Task[:regemspec].invoke if flag_update_gemspec
end
pkg_dir = "pkg"
tar_version = (BIORUBY_VERSION || spec.version) + BIORUBY_EXTRA_VERSION.to_s
tar_basename = "bioruby-#{tar_version}"
tar_filename = "#{tar_basename}.tar.gz"
tar_pkg_filepath = File.join(pkg_dir, tar_filename)
gem_filename = spec.full_name + ".gem"
gem_pkg_filepath = File.join(pkg_dir, gem_filename)
Rake::PackageTask.new("bioruby") do |pkg|
#pkg.package_dir = "./pkg"
pkg.need_tar_gz = true
pkg.package_files.import(spec.files)
pkg.package_files.include(*tar_additional_files)
pkg.version = (BIORUBY_VERSION || spec.version) + BIORUBY_EXTRA_VERSION.to_s
pkg.version = tar_version
end
Rake::GemPackageTask.new(spec) do |pkg|
......@@ -141,3 +181,155 @@ task :retutorial2html do
end
end
# ChangeLog
desc "Force update ChangeLog using git log"
task :rechangelog do
# The tag name in the command line should be changed
# after releasing new version, updating ChangeLog,
# and doing "git mv ChangeLog doc/ChangeLog-X.X.X".
sh "git log --stat --summary 1.4.2..HEAD > ChangeLog"
end
# define mktmpdir
if true then
# Note: arg is a subset of Dir.mktmpdir
def mktmpdir(prefix)
## prepare temporary directory for testing
top = Pathname.new(File.join(Dir.pwd, "tmp")).cleanpath.to_s
begin
Dir.mkdir(top)
rescue Errno::EEXIST
end
## prepare working directory
flag = false
dirname = nil
ret = nil
begin
10.times do |n|
# following 3 lines are copied from Ruby 1.9.3's tmpdir.rb and modified
t = Time.now.strftime("%Y%m%d")
path = "#{prefix}#{t}-#{$$}-#{rand(0x100000000).to_s(36)}"
path << "-#{n}" if n > 0
begin
dirname = File.join(top, path)
flag = Dir.mkdir(dirname)
break if flag
rescue SystemCallError
end
end
raise "Couldn't create a directory under #{tmp}." unless flag
ret = yield(dirname)
ensure
FileUtils.remove_entry_secure(dirname, true) if flag and dirname
end
ret
end #def mktmpdir
## Currently, Dir.mktmpdir isn't used Because of JRuby's behavior.
elsif Dir.respond_to?(:mktmpdir) then
def self.mktmpdir(*arg, &block)
Dir.mktmpdir(*arg, &block)
end
else
load "lib/bio/command.rb"
def mktmpdir(*arg, &block)
Bio::Command.mktmpdir(*arg, &block)
end
end
def chdir_with_message(dir)
$stderr.puts("chdir #{dir}")
Dir.chdir(dir)
end
# run in different directory
def work_in_another_directory
pwd = Dir.pwd
ret = false
mktmpdir("bioruby") do |dirname|
begin
chdir_with_message(dirname)
ret = yield(dirname)
ensure
chdir_with_message(pwd)
end
end
ret
end
desc "task specified with BIORUBY_RAKE_DEFAULT_TASK (default \"test\")"
task :"see-env" do
t = ENV["BIORUBY_RAKE_DEFAULT_TASK"]
if t then
Rake::Task[t].invoke
else
Rake::Task[:test].invoke
end
end
desc "DANGER: build tar and install (GNU tar needed)"
task :"tar-install" => [ :package ] do
pwd = Dir.pwd
work_in_another_directory do |dirname|
begin
# remove tar file in direname
FileUtils.remove_entry_secure(tar_filename, true)
# chdir to old pwd
chdir_with_message(pwd)
# copy (or link) tar file
safe_ln(tar_pkg_filepath, dirname)
# chdir to dirname again
chdir_with_message(dirname)
# remove a directory the tar file will contain
FileUtils.remove_entry_secure(tar_basename, true)
# extract tar
sh("tar zxvf #{tar_filename}")
# chdir to the directory