Sha256: 4d74aed0074eb212e72b602efda9a1a157efdc1afc23302ac6bd04bdbe7d1744

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 KB

Contents

#!/usr/bin/env ruby
# Ruby Wrapper for CasperJs
# by hannyu

def resolve(file_path)
    while File.symlink?(file_path) do
        file_path = File.readlink(file_path)
    end
    file_path
end

CASPER_PATH = File.dirname(File.dirname(File.expand_path(resolve(__FILE__))))

PHANTOMJS_NATIVE_ARGS = [
    '--cookies-file',
    '--config',
    '--debug',
    '--disk-cache',
    '--ignore-ssl-errors',
    '--load-images',
    '--load-plugins',
    '--local-storage-path',
    '--local-storage-quota',
    '--local-to-remote-url-access',
    '--max-disk-cache-size',
    '--output-encoding',
    '--proxy',
    '--proxy-auth',
    '--proxy-type',
    '--remote-debugger-port',
    '--remote-debugger-autorun',
    '--script-encoding',
    '--web-security',
]

CASPER_ARGS = []
PHANTOMJS_ARGS = []
ARGV.each do |arg|
    is_found = false
    PHANTOMJS_NATIVE_ARGS.each do |pna|
        if arg.start_with? pna
            PHANTOMJS_ARGS << arg
            is_found = true
            break
        end
    end
    CASPER_ARGS << arg if not is_found
end

CASPER_COMMAND = []
CASPER_COMMAND << (ENV["PHANTOMJS_EXECUTABLE"] || "phantomjs")
CASPER_COMMAND.concat PHANTOMJS_ARGS
CASPER_COMMAND << File.join(CASPER_PATH, "bin", "bootstrap.js")
CASPER_COMMAND << "--casper-path=#{CASPER_PATH}"
CASPER_COMMAND << "--cli"
CASPER_COMMAND.concat CASPER_ARGS

exec CASPER_COMMAND.join(" ")

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
phantomjs-binaries-1.8.0 bin/casperjs