phantomjs.rb 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ 2012.12.12, Version 0.0.5
2
+
3
+ * Added the ability to pass a block to run that will be called for each line
4
+ of output. (#5) (jejacks0n)
5
+
1
6
  2012.06.06, Version 0.0.4
2
7
 
3
8
  * Added specs to travis-ci.
@@ -13,9 +13,13 @@ module Phantomjs
13
13
  def run(script, *args)
14
14
  string_args = args.join(" ")
15
15
  @executable ||= get_executable
16
- body = ""
17
- IO.popen "#{@executable} #{script} #{string_args}" do |stream|
18
- body << stream.read
16
+
17
+ if block_given?
18
+ IO.popen("#{@executable} #{script} #{string_args}").each_line do |line|
19
+ yield line
20
+ end
21
+ else
22
+ `#{@executable} #{script} #{string_args}`
19
23
  end
20
24
  end
21
25
 
@@ -1,3 +1,3 @@
1
1
  module Phantomjs
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -7,5 +7,14 @@ describe Phantomjs do
7
7
  result = Phantomjs.run(script, 'foo1', 'foo2')
8
8
  result.should eq("bar foo1 foo2\n")
9
9
  end
10
+
11
+ it "accepts a block that will get called for each line of output" do
12
+ line = ''
13
+ script = File.expand_path('./spec/runner.js')
14
+ Phantomjs.run(script, 'foo1', 'foo2') do |l|
15
+ line << l
16
+ end
17
+ line.should eq("bar foo1 foo2\n")
18
+ end
10
19
  end
11
20
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phantomjs.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-06 00:00:00.000000000 Z
12
+ date: 2012-12-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ZenTest
@@ -107,12 +107,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
107
107
  - - ! '>='
108
108
  - !ruby/object:Gem::Version
109
109
  version: '0'
110
+ segments:
111
+ - 0
112
+ hash: 344941083117915964
110
113
  required_rubygems_version: !ruby/object:Gem::Requirement
111
114
  none: false
112
115
  requirements:
113
116
  - - ! '>='
114
117
  - !ruby/object:Gem::Version
115
118
  version: '0'
119
+ segments:
120
+ - 0
121
+ hash: 344941083117915964
116
122
  requirements: []
117
123
  rubyforge_project: phantomjs.rb
118
124
  rubygems_version: 1.8.24