Commit 55dff511 55dff511439bbda296dfc6a4a5961af04ab228ec by Nicolas Perriault

added ruby based casperjs executable (thanks @hannyu)

1 parent 43b16154
1 #!/usr/bin/env ruby
2
3 # Ruby Wrapper for CasperJs
4 # Version: 1.0.0
5 # by hannyu
6
7
8 CASPER_PATH = File.dirname(File.dirname(File.expand_path(__FILE__)))
9
10 PHANTOMJS_NATIVE_ARGS = [
11 '--cookies-file',
12 '--config',
13 '--disk-cache',
14 '--ignore-ssl-errors',
15 '--load-images',
16 '--load-plugins',
17 '--local-to-remote-url-access',
18 '--max-disk-cache-size',
19 '--output-encoding',
20 '--remote-debugger-port',
21 '--remote-debugger-autorun',
22 '--proxy',
23 '--proxy-auth',
24 '--proxy-type',
25 '--script-encoding',
26 '--web-security',
27 ]
28
29 CASPER_ARGS = []
30 PHANTOMJS_ARGS = []
31 ARGV.each do |arg|
32 is_found = false
33 PHANTOMJS_NATIVE_ARGS.each do |pna|
34 if arg.start_with? pna
35 PHANTOMJS_ARGS << arg
36 is_found = true
37 break
38 end
39 end
40 CASPER_ARGS << arg if not is_found
41 end
42
43 CASPER_COMMAND = []
44 CASPER_COMMAND << (ENV["PHANTOMJS_EXECUTABLE"] || "phantomjs")
45 CASPER_COMMAND.concat PHANTOMJS_ARGS
46 CASPER_COMMAND << File.join(CASPER_PATH, "bin", "bootstrap.js")
47 CASPER_COMMAND << "--casper-path=#{CASPER_PATH}"
48 CASPER_COMMAND << "--cli"
49 CASPER_COMMAND.concat CASPER_ARGS
50
51 if system(CASPER_COMMAND.join(" ")).nil?
52 puts "Fatal: Did you install phantomjs?"
53 end
54
55 exit $?.exitstatus
56