Sha256: 1ee822dc857f273ab53ac884c3ef65b0ca6070dbe9da393e56e02cf6ddf13afe

Contents?: true

Size: 1019 Bytes

Versions: 4

Compression:

Stored size: 1019 Bytes

Contents

#!/usr/bin/env ruby
require 'boojs'
require 'optparse'
require 'phantomjs'
require 'timeout'

#Parse
##########################################
parser = OptionParser.new do |opts|
  opts.banner = "Usage: boojs [-v file] [-e command] [file]"

  #Verify this file
  opts.on "-v FILE" do |f|
    @vfile = f
  end

  #One-shot command
  opts.on "-e COMMAND" do |c|
    @c = c
  end

  #Timeout
  opts.on "-t TIMEOUT" do |t|
    @t = t.to_i
  end
end
parser.parse!
file = ARGV.pop
##########################################


#Pipe with with a optional file and optional execute command
pipe_proc = Proc.new do
  if file
    BooJS.pipe File.read(file), @c, !@t.nil?
  else
    BooJS.pipe nil, @c, !@t.nil?
  end
end

#This takes a long time
$phantomjs_path = Phantomjs.path

#Run verify or run stdin/stdout mode?
if @vfile
  BooJS.verify File.read(@file)
else
  if @t
    begin
      Timeout::timeout(@t) do
        pipe_proc.call
      end
    rescue Timeout::Error
      exit 0
    end
  else
    pipe_proc.call
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
boojs-0.0.20 bin/boojs
boojs-0.0.19 bin/boojs
boojs-0.0.18 bin/boojs
boojs-0.0.17 bin/boojs