Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 67 lines (58 sloc) 1.992 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
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

Something went wrong with that request. Please try again.