Module: IniFile

Extended by:
IniFile
Included in:
IniFile
Defined in:
lib/ini_file.rb,
lib/ini_file/parser.rb,
lib/ini_file/content.rb,
lib/ini_file/version.rb

Overview

Defined Under Namespace

Modules: Parser Classes: Content

Constant Summary collapse

IniFormatError =
Class.new(StandardError)
VERSION =
'0.0.2'

Instance Method Summary collapse

Instance Method Details

#load(path, safe = false) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/ini_file.rb', line 12

def load(path, safe = false)
  contents = File.open(File.expand_path(path), 'r') {|f| f.read }
  return Content.parse(contents)
rescue
  if safe
    return nil
  else
    raise $!
  end
end

#parse(contents, safe = false) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/ini_file.rb', line 23

def parse(contents, safe = false)
  return Parser.parse(contents)
rescue
  if safe
    return nil
  else
    raise $!
  end
end