Class: Pleeease::NodeRunner

Inherits:
Struct
  • Object
show all
Defined in:
lib/pleeease/runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#environmentObject

Returns the value of attribute environment

Returns:

  • (Object)

    the current value of environment



3
4
5
# File 'lib/pleeease/runner.rb', line 3

def environment
  @environment
end

#scriptObject

Returns the value of attribute script

Returns:

  • (Object)

    the current value of script



3
4
5
# File 'lib/pleeease/runner.rb', line 3

def script
  @script
end

Instance Method Details

#cmdObject



20
21
22
# File 'lib/pleeease/runner.rb', line 20

def cmd
  [ 'node', '-e', script ]
end

#envObject



16
17
18
# File 'lib/pleeease/runner.rb', line 16

def env
  environment || ENV
end

#runObject



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/pleeease/runner.rb', line 4

def run
  IO.popen(env, cmd, "r+") do |f|
    # pump stdout
    lines = []
    f.each do |line|
      lines << line
    end

    lines.join
  end
end