Sha256: f750472fc51accbef881c49650b616fe0ec917dccc05188ae7a8b764f4dd0d89

Contents?: true

Size: 508 Bytes

Versions: 3

Compression:

Stored size: 508 Bytes

Contents

module LoadConf
  def report(method, e)
    if method.instance_of?(String)
      warn(method)
    elsif method.instance_of?(Proc)
      method.call(e)
    end
  end

  def load(fname, *opt)
    er = opt[0] || {}
    begin
      open(fname) do |src|
        begin
          return instance_eval(src.read.untaint, fname, 1)
        rescue => e
          report(er[:script], e)
        end
      end
    rescue SystemCallError => e
      report(er[:open], e)
    end
  end

  module_function :load, :report
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gnn-rblibs-0.0.4 lib/loadconf.rb
gnn-rblibs-0.0.3 lib/loadconf.rb
gnn-rblibs-0.0.1 lib/loadconf.rb