Class: FriendlyGhost::Runner
- Inherits:
-
Object
- Object
- FriendlyGhost::Runner
- Includes:
- POSIX::Spawn
- Defined in:
- lib/friendly_ghost/runner.rb
Instance Attribute Summary collapse
-
#casper_path ⇒ Object
Returns the value of attribute casper_path.
-
#process ⇒ Object
readonly
Returns the value of attribute process.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
- #command(args) ⇒ Object
-
#initialize ⇒ Runner
constructor
A new instance of Runner.
- #parse_result ⇒ Object
- #raw_output ⇒ Object
Constructor Details
#initialize ⇒ Runner
Returns a new instance of Runner.
11 12 13 |
# File 'lib/friendly_ghost/runner.rb', line 11 def initialize @casper_path = `which casperjs`.strip end |
Instance Attribute Details
#casper_path ⇒ Object
Returns the value of attribute casper_path.
8 9 10 |
# File 'lib/friendly_ghost/runner.rb', line 8 def casper_path @casper_path end |
#process ⇒ Object (readonly)
Returns the value of attribute process.
9 10 11 |
# File 'lib/friendly_ghost/runner.rb', line 9 def process @process end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
9 10 11 |
# File 'lib/friendly_ghost/runner.rb', line 9 def result @result end |
Instance Method Details
#command(args) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/friendly_ghost/runner.rb', line 15 def command(args) @process = Child.new("#{@casper_path} #{args}") @result = parse_result @result['status'] = @process.success? @result end |
#parse_result ⇒ Object
28 29 30 31 32 |
# File 'lib/friendly_ghost/runner.rb', line 28 def parse_result json_line = @process.out.split(/\n/).select { |line| line =~ /\{/ } output = json_line.first.strip MultiJson.load(output) end |
#raw_output ⇒ Object
24 25 26 |
# File 'lib/friendly_ghost/runner.rb', line 24 def raw_output @process.out end |