Sha256: 921f98344ab7e9cccca57041a1f4f17e281043ed9a3534799b30e843f446147d

Contents?: true

Size: 644 Bytes

Versions: 2

Compression:

Stored size: 644 Bytes

Contents

require "yaml"

module Notifaction
  class Cfg
    #
    # @since 0.4.0
    def initialize
      local_conf = Dir.home + "/.notifaction.yml"

      conf = {}
      conf = YAML.load(File.open(local_conf)) if File.exists? local_conf

      @hooks = conf["hooks"] ||= []
      @config = conf["config"] ||= {}

      nil
    end

    #
    # @since 0.4.3
    def hook(item)
      return if @hooks.empty? || item.nil?
      @hooks[item.to_sym]
    end

    #
    # @since 0.4.3
    def hooks
      @hooks
    end

    #
    # @since 0.4.3
    def config(item)
      return if @config.empty? || item.nil?
      @config[item.to_sym]
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
notifaction-0.4.4 lib/notifaction/config.rb
notifaction-0.4.3 lib/notifaction/config.rb