Method: O.require
- Defined in:
- lib/o.rb
.require(name) ⇒ O
load a configuration file, use $: and support ‘~/.gutenrc’
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/o.rb', line 96 def require(name) path = nil # ~/.gutenrc if name =~ /^~/ file = File.(name) path = file if File.exists?(file) # /absolute/path/to/rc elsif File.absolute_path(name) == name path = name if File.exists?(name) # relative/rc else catch :break do $:.each { |p| ['.rb', ''].each { |ext| file = File.join(p, name+ext) if File.exists? file path = file throw :break end } } end end raise LoadError, "can't find file -- #{name}" unless path O.eval File.read(path) end |