lib/slack_messaging/config.rb in slack_messaging-1.3.1 vs lib/slack_messaging/config.rb in slack_messaging-1.4.0

- old
+ new

@@ -1,43 +1,27 @@ -require 'yaml' -require 'hashie' - module SlackMessaging - class DefaultPaths - class << self - def config - File.join(self.home,'.slack_messaging.yml') - end + class Config + def self.config + config_data.to_hash + end - def home - ENV['HOME'] ? ENV['HOME'] : "." - end + def self.load(path) + load_config(path) + config end - end - class Config - class << self + private - def config - config_data.to_hash - end + def self.config_data + @config_data ||= Hashie::Mash.new + end - def load(path) - load_config(path) - config - end + def self.method_missing(method, args = false) + config_data.send(method, args) + 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 + def self.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