class ConfigFile

Constants

VERSION

Attributes

config[R]

Public Class Methods

register(type) click to toggle source
# File lib/config_file/config_file.rb, line 4
def self.register(type)
  @types << type unless @types.include? type
end
type(extension) click to toggle source
# File lib/config_file/config_file.rb, line 8
def self.type(extension)
  @types.detect { |type| type.extensions.include? extension }
end

Public Instance Methods

read(file_name, ext=nil) click to toggle source
# File lib/config_file/config_file.rb, line 14
def read file_name, ext=nil
  ext = File.extname(file_name) unless ext

  config_file_type = ConfigFile.type(ext)

  if config_file_type
    config_file = config_file_type.new

    @config = config_file.read file_name
  else
    raise ArgumentError, "Configuration from #{ext} is not supported"
  end
end