class Object
Constants
- DIR
Public Instance Methods
assert(msg) { |end| ... }
click to toggle source
# File lib/utils.rb, line 8 def assert(msg, &block) raise AssertionError, msg unless yield end class DhallError < StandardError def initialize(msg) super(msg) end end $dhallish_internal_global_counter = 0 def get_new_sym() $dhallish_internal_global_counter += 1 ("__newsym_#{$dhallish_internal_global_counter}").to_sym end def escape_str(str) str.gsub("\n", "\\n").gsub("\"", "\\\"") end def does_cmd_exist?(cmd) ENV['PATH'].split(File::PATH_SEPARATOR).each { |path| exe = File.join(path, cmd) if File.executable?(exe) && !File.directory?(exe) return true end } return false end def resolve_map(map, from_name, to_name) resmap = {} map.each { |key, val| reskey = key resval = val if reskey == from_name; reskey = to_name; end if resval == from_name; resval = to_name; end resmap[reskey] = resval } resmap
does_cmd_exist?(cmd)
click to toggle source
# File lib/utils.rb, line 26 def does_cmd_exist?(cmd) ENV['PATH'].split(File::PATH_SEPARATOR).each { |path| exe = File.join(path, cmd) if File.executable?(exe) && !File.directory?(exe) return true end } return false end
escape_str(str)
click to toggle source
# File lib/utils.rb, line 22 def escape_str(str) str.gsub("\n", "\\n").gsub("\"", "\\\"") end
get_new_sym()
click to toggle source
# File lib/utils.rb, line 17 def get_new_sym() $dhallish_internal_global_counter += 1 ("__newsym_#{$dhallish_internal_global_counter}").to_sym end
resolve_map(map, from_name, to_name)
click to toggle source
# File lib/utils.rb, line 36 def resolve_map(map, from_name, to_name) resmap = {} map.each { |key, val| reskey = key resval = val if reskey == from_name; reskey = to_name; end if resval == from_name; resval = to_name; end resmap[reskey] = resval } resmap end