Sha256: cd98501063da76d34c796aeda8e47f9b7901e4a21f16e82ed6e386bc35247119

Contents?: true

Size: 1.02 KB

Versions: 4

Compression:

Stored size: 1.02 KB

Contents

require "jstdutil/formatter"
require "jstdutil/redgreen"
require "jstdutil/colorful_html"
#require "jstdutil/autotest"

module Jstdutil
  def self.install_dir
    File.expand_path(File.dirname(__FILE__))
  end

  #
  # Locate Jar file from a given path. Default classpath is $JSTDUTIL_HOME
  # Finds and returns the first file matching jstest*.jar (case insensitive).
  # Also checks current working directory
  #
  def self.jar(classpath = ENV["JSTESTDRIVER_HOME"] || Dir.pwd)
    files = Dir.glob(File.join(classpath, 'jstest*.jar'), File::FNM_CASEFOLD)
    files.sort! { |f1, f2| f1.downcase <=> f2.downcase }

    if !files || !files.first
      msg = "Unable to load jar file from #{classpath}\n" <<
            "Check that $JSTESTDRIVER_HOME is set correctly"
      raise FileNotFoundError.new(msg)
    end

    files[-1]
  end

  #
  # Run the jar through the java command
  #
  def self.run(args, jar)
    begin
      `java -jar #{jar} #{args}`
    rescue Exception => err
    end
  end
end

class FileNotFoundError < StandardError
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jstdutil-0.3.3 lib/jstdutil.rb
jstdutil-0.3.2 lib/jstdutil.rb
jstdutil-0.3.1 lib/jstdutil.rb
jstdutil-0.3.0 lib/jstdutil.rb