Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

66 lines (58 sloc) 1.991 kb
dir = File.dirname(__FILE__)
require 'rubygems'
require 'rake'
#$LOAD_PATH.unshift(File.join(dir, 'vendor', 'rspec', 'lib'))
require 'rspec/core'
require 'rspec/core/rake_task'
#Gem::manage_gems
#require 'rake/gempackagetask'
task :default => :spec
RSpec::Core::RakeTask.new do |t|
t.pattern = 'spec/**/*spec.rb'
end
ruby_version = RUBY_VERSION.split('.')[0..1].join('').to_i
begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
gem.name = ruby_version < 19 ? "biodiversity" : "biodiversity19"
gem.summary = 'Parser of scientific names'
gem.description = 'Tools for biodiversity informatics'
gem.email = "dmozzherin@gmail.com"
gem.homepage = "http://github.com/GlobalNamesArchitecture/biodiversity"
gem.authors = ["Dmitry Mozzherin"]
gem.has_rdoc = false
gem.bindir = 'bin'
gem.executables = ['nnparse', 'parserver']
gem.add_dependency('treetop')
gem.add_dependency('parallel')
gem.add_dependency('json') if ruby_version < 19
gem.add_development_dependency "rspec"
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
end
rescue LoadError
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
end
task :tt do
['scientific_name_clean', 'scientific_name_dirty', 'scientific_name_canonical'].each do |f|
file = "#{dir}/lib/biodiversity/parser/#{f}"
FileUtils.rm("#{file}.rb") if FileTest.exist?("#{file}.rb")
system("tt #{file}.treetop")
rf = "#{file}.rb"
rfn = open(rf + ".tmp", 'w')
skip_head = false
f = open(rf)
#getting around a bug in treetop which prevents setting UTF-8 encoding in ruby19
f.each_with_index do |l, i|
skip_head = l.match(/^# Autogenerated/) if i == 0
if skip_head && (l.strip == '' || l.match(/^# Autogenerated/))
next
else
skip_head = false
rfn.write(l)
end
end
rfn.close
f.close
`mv #{rf}.tmp #{rf}`
end
end
Jump to Line
Something went wrong with that request. Please try again.