Module: Runger::Utils
- Defined in:
- lib/runger_config.rb,
lib/runger/utils/which.rb,
lib/runger/utils/deep_merge.rb
Class Method Summary collapse
- .deep_merge!(source, other) ⇒ Object
-
.which(cmd) ⇒ Object
Cross-platform solution taken from stackoverflow.com/a/5471032.
Class Method Details
.deep_merge!(source, other) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/runger/utils/deep_merge.rb', line 7 def self.deep_merge!(source, other) other.each do |key, other_value| this_value = source[key] if this_value.is_a?(::Hash) && other_value.is_a?(::Hash) deep_merge!(this_value, other_value) else source[key] = other_value.deep_dup end end source end |
.which(cmd) ⇒ Object
Cross-platform solution taken from stackoverflow.com/a/5471032
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/runger/utils/which.rb', line 6 def self.which(cmd) exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : [''] ENV['PATH'].split(File::PATH_SEPARATOR).each do |path| exts.each do |ext| exe = File.join(path, "#{cmd}#{ext}") return exe if File.executable?(exe) && !File.directory?(exe) end end nil end |