Top Level Namespace
Defined Under Namespace
Modules: Dhallish, DhallishGrammar
Classes: AssertionError, DhallError, DhallishGrammarParser
Constant Summary
collapse
- DIR =
File.dirname(__FILE__)
Instance Method Summary
collapse
Instance Method Details
#assert(msg, &block) ⇒ Object
8
|
# File 'lib/utils.rb', line 8
def assert(msg, &block) raise AssertionError, msg unless yield end
|
#does_cmd_exist?(cmd) ⇒ Boolean
26
27
28
29
30
31
32
33
34
|
# 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) ⇒ Object
22
23
24
|
# File 'lib/utils.rb', line 22
def escape_str(str)
str.gsub("\n", "\\n").gsub("\"", "\\\"")
end
|
#get_new_sym ⇒ Object
17
18
19
20
|
# 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) ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
|
# 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
|