Sha256: f11bef52b29078f3caff52ea597b20186fbdc6e2d068fbb5a8eab5da43ded6e8

Contents?: true

Size: 1.61 KB

Versions: 19

Compression:

Stored size: 1.61 KB

Contents

require "yaml"
require "treetop"
require "json"
require "biodiversity"
require "webmock/rspec"


RSpec.configure do |c|
  c.mock_with :rr
end

dir = File.dirname(__FILE__)
Treetop.load(File.expand_path(File.join(dir,
             "../lib/biodiversity/parser/scientific_name_clean")))
Treetop.load(File.expand_path(File.join(dir,
             "../lib/biodiversity/parser/scientific_name_dirty")))
Treetop.load(File.expand_path(File.join(dir,
             "../lib/biodiversity/parser/scientific_name_canonical")))

PARSER_TEST_VERSION = "test_version"

def set_parser(parser)
  @parser = parser
end

def parse(input)
  @parser.parse(input)
end

def value(input)
  parse(input).value
end

def canonical(input)
  parse(input).canonical
end

def details(input)
  parse(input).details
end

def pos(input)
  parse(input).pos
end

def json(input)
  parse(input).
    to_json.gsub(/"parser_version":"[^"]*"/,
                 %Q["parser_version":"#{PARSER_TEST_VERSION}"])
end

def debug(input)
  res = parse(input)
  puts "<pre>"
    if res
      puts "success!"
      puts res.inspect
    else
      puts input
      val = @parser.failure_reason.to_s.match(/column [0-9]*/).
        to_s.gsub(/column /, "").to_i
      print ("-" * (val - 1))
      print "^   Computer says 'ni'!\n"
      puts @parser.failure_reason
      puts @parser.to_yaml
    end
  puts "</pre>"
end

def read_test_file
  f = open(File.expand_path("../files/test_data.txt", __FILE__))
  f.each do |line|
    name, jsn = line.split("|")
    if line.match(/^\s*#/) == nil && name && jsn
      yield({ name: name, jsn: jsn })
    else
      yield({ comment: line })
    end
  end
end


Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
biodiversity-3.5.1 spec/spec_helper.rb
biodiversity-3.5.0 spec/spec_helper.rb
biodiversity-3.4.6 spec/spec_helper.rb
biodiversity-3.4.5 spec/spec_helper.rb
biodiversity-3.4.4 spec/spec_helper.rb
biodiversity-3.4.3 spec/spec_helper.rb
biodiversity-3.4.2 spec/spec_helper.rb
biodiversity-3.4.1 spec/spec_helper.rb
biodiversity-3.4.0 spec/spec_helper.rb
biodiversity-3.3.0 spec/spec_helper.rb
biodiversity-3.2.1 spec/spec_helper.rb
biodiversity-3.2.0 spec/spec_helper.rb
biodiversity-3.1.10 spec/spec_helper.rb
biodiversity-3.1.9 spec/spec_helper.rb
biodiversity-3.1.8 spec/spec_helper.rb
biodiversity19-3.1.7 spec/spec_helper.rb
biodiversity-3.1.7 spec/spec_helper.rb
biodiversity19-3.1.6 spec/spec_helper.rb
biodiversity-3.1.6 spec/spec_helper.rb