Sha256: 4fce2bcaa217dd9e286a1fb57c4c09a79063c76cae8624197680696fc8c65238

Contents?: true

Size: 848 Bytes

Versions: 1

Compression:

Stored size: 848 Bytes

Contents

require 'yaml'
require 'hashie'

module SlackMessaging
  class DefaultPaths
    class << self
      def config
        File.join(self.home,'.slack_messaging.yml')
      end

      def home
        ENV['HOME'] ? ENV['HOME'] : "."
      end
    end
  end

  class Config
    class << self

      def config
        config_data.to_hash
      end

      def load(path)
        load_config(path)
        config
      end

      private def config_data
        @config_data ||= Hashie::Mash.new
      end

      private def method_missing(method, args=false)
        config_data.send(method, args)
      end

      private def load_config(file)
        raise MissingConfig, "Missing configuration file: #{file}" unless File.exist?(file)
        YAML.load_file(file).each{ |key,value| config_data.assign_property(key, value) }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
slack_messaging-1.3.1 lib/slack_messaging/config.rb