phantomjs.rb 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,11 +19,11 @@ class Phantomjs
19
19
 
20
20
  begin
21
21
  if block_given?
22
- IO.popen("#{EXEC} #{script} #{string_args}").each_line do |line|
22
+ IO.popen([EXEC, script, args].flatten).each_line do |line|
23
23
  yield line
24
24
  end
25
25
  else
26
- `#{EXEC} #{script} #{string_args}`
26
+ IO.popen([EXEC, script, args].flatten).read
27
27
  end
28
28
  rescue Errno::ENOENT
29
29
  raise CommandNotFoundError.new('Phantomjs is not installed')
@@ -1,3 +1,3 @@
1
1
  class Phantomjs
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
@@ -24,7 +24,7 @@ describe Phantomjs do
24
24
  it "runs phantomjs binary with the correct arguments" do
25
25
  script = File.expand_path('./spec/runner.js')
26
26
  result = Phantomjs.run(script, 'foo1', 'foo2')
27
- result.should eq("bar foo1 foo2\n")
27
+ result.should eq("bar\nfoo1\nfoo2\n")
28
28
  end
29
29
 
30
30
  it "accepts a block that will get called for each line of output" do
@@ -33,7 +33,37 @@ describe Phantomjs do
33
33
  Phantomjs.run(script, 'foo1', 'foo2') do |l|
34
34
  line << l
35
35
  end
36
- line.should eq("bar foo1 foo2\n")
36
+ line.should eq("bar\nfoo1\nfoo2\n")
37
+ end
38
+
39
+ it "accepts empty parameters" do
40
+ line = ''
41
+ script = File.expand_path('./spec/runner.js')
42
+ Phantomjs.run(script, 'foo1', 'foo2', '') do |l|
43
+ line << l
44
+ end
45
+ line.should eq("bar\nfoo1\nfoo2\n\n")
46
+ end
47
+
48
+ it "accepts parameters with spaces" do
49
+ line = ''
50
+ script = File.expand_path('./spec/runner.js')
51
+ Phantomjs.run(script, 'foo bar', 'foo2') do |l|
52
+ line << l
53
+ end
54
+ line.should eq("bar\nfoo bar\nfoo2\n")
55
+ end
56
+
57
+ it "accepts empty parameters without block" do
58
+ script = File.expand_path('./spec/runner.js')
59
+ output = Phantomjs.run(script, 'foo1', 'foo2', '')
60
+ output.should eq("bar\nfoo1\nfoo2\n\n")
61
+ end
62
+
63
+ it "accepts parameters with spaces without block" do
64
+ script = File.expand_path('./spec/runner.js')
65
+ output = Phantomjs.run(script, 'foo bar', 'foo2')
66
+ output.should eq("bar\nfoo bar\nfoo2\n")
37
67
  end
38
68
  end
39
69
  end
@@ -1,2 +1,5 @@
1
- console.log('bar ' + phantom.args[0] + ' ' + phantom.args[1]);
1
+ console.log('bar');
2
+ for (var i = 0; i < phantom.args.length; i++) {
3
+ console.log(phantom.args[i]);
4
+ }
2
5
  phantom.exit();
metadata CHANGED
@@ -1,18 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phantomjs.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - William Estoque
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-05-17 00:00:00.000000000 Z
12
+ date: 2013-09-08 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: rspec
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ! '>='
18
20
  - !ruby/object:Gem::Version
@@ -20,6 +22,7 @@ dependencies:
20
22
  type: :development
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - ! '>='
25
28
  - !ruby/object:Gem::Version
@@ -27,6 +30,7 @@ dependencies:
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: rake
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
35
  - - ! '>='
32
36
  - !ruby/object:Gem::Version
@@ -34,6 +38,7 @@ dependencies:
34
38
  type: :development
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
43
  - - ! '>='
39
44
  - !ruby/object:Gem::Version
@@ -61,28 +66,34 @@ files:
61
66
  - spec/runner.js
62
67
  homepage: http://westoque.com
63
68
  licenses: []
64
- metadata: {}
65
69
  post_install_message:
66
70
  rdoc_options: []
67
71
  require_paths:
68
72
  - lib
69
73
  required_ruby_version: !ruby/object:Gem::Requirement
74
+ none: false
70
75
  requirements:
71
76
  - - ! '>='
72
77
  - !ruby/object:Gem::Version
73
78
  version: '0'
79
+ segments:
80
+ - 0
81
+ hash: -794486166950785980
74
82
  required_rubygems_version: !ruby/object:Gem::Requirement
83
+ none: false
75
84
  requirements:
76
85
  - - ! '>='
77
86
  - !ruby/object:Gem::Version
78
87
  version: '0'
88
+ segments:
89
+ - 0
90
+ hash: -794486166950785980
79
91
  requirements: []
80
92
  rubyforge_project: phantomjs.rb
81
- rubygems_version: 2.0.3
93
+ rubygems_version: 1.8.24
82
94
  signing_key:
83
- specification_version: 4
95
+ specification_version: 3
84
96
  summary: Ruby wrapper for phantomjs
85
97
  test_files:
86
98
  - spec/phantomjs_spec.rb
87
99
  - spec/runner.js
88
- has_rdoc:
checksums.yaml DELETED
@@ -1,15 +0,0 @@
1
- ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- YzdiZTc3OWFlMWE3MDc2N2NkMWZiMzczMjEwY2FiOGUzN2Q2OTYyOA==
5
- data.tar.gz: !binary |-
6
- MjI4ODIyNTY3ZGFjYmIzOTMxMWJkZGQzNmNiNGZlNGE4ZDczOWUwMw==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- M2UwYjQzOThmNGI2MTM1YTlhNzk4NDVmZTU1OTkyMDRjYjdmOGE4MTlmNTU5
10
- OTg3ZDU0MGE3MmRlMzE3NDdkZTVkYzEwYWZjZDI3MTE0Njc3YTQ5Zjk0ZjE0
11
- N2I4NjU3OTk1YjYyZGE4YjI4OTdhMmM1MzUwNWRhNDczZTdkZmY=
12
- data.tar.gz: !binary |-
13
- Mjk5YmVmZTg5YWE1MzVkMzE4ZjA1NzJkMzAwNWU4OTI3YjMxOWFjYmI0MjQw
14
- OGM0YThkZWI4NmM3NTliNDg5NGNjOGZkMWJlYThmMjI3MzdhNmZkY2E1ZDI5
15
- ZTUzZmZhZThiMDUwY2Y5ZGY3NzAzNjE5ZTBiOWViYTA3NmZkYTg=