Class: Rscons::Script::GlobalDsl
- Inherits:
-
Object
- Object
- Rscons::Script::GlobalDsl
- Defined in:
- lib/rscons/script.rb
Overview
Global DSL methods.
Direct Known Subclasses
Instance Method Summary collapse
-
#path_append(path) ⇒ void
Append a path component to the PATH variable.
-
#path_components ⇒ Array<String>
Return path components from the PATH variable.
-
#path_prepend(path) ⇒ void
Prepend a path component to the PATH variable.
-
#path_set(new_path) ⇒ void
Set the PATH variable.
-
#rscons(path, *args) ⇒ Object
Invoke rscons in a subprocess for a subsidiary Rsconscript file.
Instance Method Details
#path_append(path) ⇒ void
This method returns an undefined value.
Append a path component to the PATH variable.
33 34 35 |
# File 'lib/rscons/script.rb', line 33 def path_append(path) path_set(path_components + [File.(path)]) end |
#path_components ⇒ Array<String>
Return path components from the PATH variable.
13 14 15 |
# File 'lib/rscons/script.rb', line 13 def path_components ENV["PATH"].split(File::PATH_SEPARATOR) end |
#path_prepend(path) ⇒ void
This method returns an undefined value.
Prepend a path component to the PATH variable.
23 24 25 |
# File 'lib/rscons/script.rb', line 23 def path_prepend(path) path_set([File.(path)] + path_components) end |
#path_set(new_path) ⇒ void
This method returns an undefined value.
Set the PATH variable.
43 44 45 46 47 48 |
# File 'lib/rscons/script.rb', line 43 def path_set(new_path) if new_path.is_a?(Array) new_path = new_path.join(File::PATH_SEPARATOR) end ENV["PATH"] = new_path end |
#rscons(path, *args) ⇒ Object
Invoke rscons in a subprocess for a subsidiary Rsconscript file.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/rscons/script.rb', line 57 def rscons(path, *args) rscons_path = File.($0) path = File.(path) if File.directory?(path) command = [*args] dir = path else command = ["-f", path, *args] dir = File.dirname(path) end if File.exist?("#{dir}/rscons") rscons_path = "#{dir}/rscons" end command = [rscons_path] + command print_dir = dir != "." && dir != File.(Dir.pwd) if ENV["specs"] and not ENV["dist_specs"] # specs command = ["ruby", $LOAD_PATH.map {|p| ["-I", p]}, command].flatten # specs end # specs puts "rscons: Entering directory '#{dir}'" if print_dir result = system(*command, chdir: dir) puts "rscons: Leaving directory '#{dir}'" if print_dir unless result raise RsconsError.new("Failed command: " + command.join(" ")) end end |