class Fpmache::File

Process single INI file and return section contents

Attributes

contents[RW]
inifile[RW]

Public Class Methods

new(inifile) click to toggle source
# File lib/fpmache/file.rb, line 7
def initialize(inifile)
  @inifile = inifile
  @contents = {}
end

Public Instance Methods

read() click to toggle source

Public - Read the INI file and return the processed Hash. Usually, there would be one section per file for PHP-FPM configuraiton file

Returns Hash

# File lib/fpmache/file.rb, line 16
def read
  ini = IniFile.load(@inifile)

  section = process_sections(ini)
  ini[section]
end

Private Instance Methods

process_sections(ini) click to toggle source

Private - Process the returned Object and list out sections, we are expecting one section

ini - Object procesed Ini file

Returns String

# File lib/fpmache/file.rb, line 31
def process_sections(ini)
  if ini.sections.length == 1
    ini.sections[0]
  else
    throw Exception('More than one section found in INI file')
  end
end