Sha256: bf80ae3ebfa514c1d83c813911a9a76cd9fcb00ca0c9a3324158316c0980fcbd

Contents?: true

Size: 428 Bytes

Versions: 3

Compression:

Stored size: 428 Bytes

Contents

# coding: utf-8

require 'inifile'

module Confuse
  module Source
    class Ini
      def initialize(options = {})
        @ini = from_file(options[:path])
      end

      def from_file(file)
        IniFile.load(file).to_h
      rescue IniFile::Error
        nil
      end

      def [](namespace, key)
        namespace ||= :global
        @ini[namespace.to_s][key.to_s]
      end
    end

    register(:ini, Ini)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
confuse-1.1.1 lib/confuse/source/ini.rb
confuse-1.1.0 lib/confuse/source/ini.rb
confuse-1.0.0 lib/confuse/source/ini.rb