Method: Thor::Util.load_thorfile

Defined in:
lib/vendor/thor/lib/thor/util.rb

.load_thorfile(path, content = nil, debug = false) ⇒ Object

Receives a path and load the thor file in the path. The file is evaluated inside the sandbox to avoid namespacing conflicts.



150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/vendor/thor/lib/thor/util.rb', line 150

def self.load_thorfile(path, content=nil, debug=false)
  content ||= File.binread(path)

  begin
    Thor::Sandbox.class_eval(content, path)
  rescue Exception => e
    $stderr.puts("WARNING: unable to load thorfile #{path.inspect}: #{e.message}")
    if debug
      $stderr.puts(*e.backtrace)
    else
      $stderr.puts(e.backtrace.first)
    end
  end
end