Class: Node
- Inherits:
-
Object
- Object
- Node
- Defined in:
- lib/node.rb
Instance Attribute Summary collapse
-
#exec_name ⇒ Object
the name of the stock node.js executable, which is normally just “node”.
-
#module_contexts ⇒ Object
If set true, loads modules in their own global contexts.
-
#node_debug ⇒ Object
If true, prints additional debug output.
-
#opts ⇒ Object
Array of command-line arguments for node.js.
-
#path ⇒ Object
the value of NODE_PATH.
Class Method Summary collapse
-
.path_to_gem ⇒ Object
Returns the path to the node.rb gem.
Instance Method Summary collapse
-
#command ⇒ Object
Constructs the execution command.
-
#initialize(file) ⇒ Node
constructor
A new instance of Node.
-
#path_to_gem ⇒ Object
Returns the path to the node.rb gem.
- #run ⇒ Object
Constructor Details
#initialize(file) ⇒ Node
Returns a new instance of Node.
21 22 23 24 25 26 27 28 |
# File 'lib/node.rb', line 21 def initialize(file) @file = file @path = default_node_path @exec_name = "node" @node_debug = false @module_contexts = false @opts = [] end |
Instance Attribute Details
#exec_name ⇒ Object
the name of the stock node.js executable, which is normally just “node”
10 11 12 |
# File 'lib/node.rb', line 10 def exec_name @exec_name end |
#module_contexts ⇒ Object
If set true, loads modules in their own global contexts.
16 17 18 |
# File 'lib/node.rb', line 16 def module_contexts @module_contexts end |
#node_debug ⇒ Object
If true, prints additional debug output. Defaults to false.
13 14 15 |
# File 'lib/node.rb', line 13 def node_debug @node_debug end |
#opts ⇒ Object
Array of command-line arguments for node.js.
19 20 21 |
# File 'lib/node.rb', line 19 def opts @opts end |
#path ⇒ Object
the value of NODE_PATH. This is an array.
7 8 9 |
# File 'lib/node.rb', line 7 def path @path end |
Class Method Details
.path_to_gem ⇒ Object
Returns the path to the node.rb gem.
42 43 44 |
# File 'lib/node.rb', line 42 def path_to_gem File.(File.join(File.dirname(__FILE__), "..")) end |
Instance Method Details
#command ⇒ Object
Constructs the execution command.
35 36 37 38 |
# File 'lib/node.rb', line 35 def command parts = [construct_path, construct_debug, construct_contexts, construct_name, construct_opts, @file] parts.reject { |a| a.nil? || a.length == 0 }.join " " end |
#path_to_gem ⇒ Object
Returns the path to the node.rb gem.
48 49 50 |
# File 'lib/node.rb', line 48 def path_to_gem self.class.path_to_gem end |
#run ⇒ Object
30 31 32 |
# File 'lib/node.rb', line 30 def run %x[#{command}].strip end |