module Anyway::Utils
Public Class Methods
deep_merge!(source, other)
click to toggle source
# File lib/anyway/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)
click to toggle source
Cross-platform solution taken from stackoverflow.com/a/5471032
# File lib/anyway/utils/which.rb, line 7 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