bin/parserver in biodiversity-1.0.0 vs bin/parserver in biodiversity-1.0.1

- old
+ new

@@ -9,10 +9,11 @@ OPTIONS = { :output => "json", :port => DEFAULT_PORT } +options = {} ARGV.options do |opts| script_name = File.basename($0) opts.banner = "Usage: ruby #{script_name} [options]" opts.separator "" @@ -20,27 +21,27 @@ opts.on("-o", "--output=output", String, "Specifies the type of the output: json - parsed results in json canonical - canonical version canonical_with_rank - canonical with rank", - "Default: json") { |OPTIONS[:output]| } + "Default: json") { |output| options[:output] = output } opts.separator "" opts.on("-p", "--port=port", String, "Specifies the port number", - "Default: #{DEFAULT_PORT}") { |OPTIONS[:port]| } + "Default: #{DEFAULT_PORT}") { |port| options[:port] = port } opts.separator "" opts.on("-h", "--help", "Show this help message.") { puts opts; exit } opts.parse! end -OPTIONS[:output] = "json" unless ['canonical', 'canonical_with_rank'].include?(OPTIONS[:output]) -OPTIONS[:port] = (OPTIONS[:port].to_i > 0 ? OPTIONS[:port].to_i : DEFAULT_PORT) +OPTIONS[:output] = options[:output] if ['canonical', 'canonical_with_rank'].include?(options[:output]) +OPTIONS[:port] = options[:port].to_i if options[:port].to_i > 0 def parser_error(name_string) {:scientificName => {:parsed => false, :verbatim => name_string, :error => 'Parser error'}} end