Sha256: fff6ea53617c1a1648d1e79a1c74b42a017c00c4f3935fc33ac61f64c63938b7
Contents?: true
Size: 1.23 KB
Versions: 2
Compression:
Stored size: 1.23 KB
Contents
require_relative "bives/version" require 'open4' module Bives class ConversionException < Exception end class InitialisationException < Exception end JAR_FILENAME = "BiVeS-1.1.2-SNAPSHOT-fat.jar" JAR_FILEPATH = File.join File.dirname(__FILE__),"jars","#{JAR_FILENAME}" def self.included(mod) unless File.exist?(JAR_FILEPATH) raise InitialisationException.new("Jar file #{JAR_FILEPATH} not found") end end def check_jar unless File.exist?(JAR_FILEPATH) raise InitialisationException.new("Jar file #{JAR_FILEPATH} not found") end end def compare file1,file2,opts=["reportHtml"] check_jar cmd_opts = opts.collect{|o| "--#{o}"}.join(" ") command = "java -jar #{JAR_FILEPATH} #{cmd_opts} #{file1} #{file2}" err_message = "" output = "" status = Open4::popen4(command) do |pid, stdin, stdout, stderr| while ((line = stdout.gets) != nil) do output << line end stdout.close while ((line=stderr.gets)!= nil) do err_message << line end stderr.close end output=output.strip if status.to_i != 0 err_message = output if err_message.empty? raise ConversionException.new(err_message) end output end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
bives-0.4 | lib/bives.rb |
bives-0.3 | lib/bives.rb |