Sha256: 8ba0e823c4ce58ed9c92376e93be1c9efe56861f986e9da1948ff44b12e73cb0

Contents?: true

Size: 803 Bytes

Versions: 2

Compression:

Stored size: 803 Bytes

Contents

require "gem_configurator/version"
require 'active_support/inflector'

module GemConfigurator
  
  attr_reader :settings
  
  def config_path
    config_file_name = "#{self.class.to_s.underscore}.yml"
    if defined?(Rails) && File.exists?(Rails.root.join("config",config_file_name))
      Rails.root.join("config",config_file_name)
    else
      nil
    end
  end
  
  def configure
    raw_settings = parse_yaml(config_path())

    if raw_settings
      @settings = raw_settings[Rails.env]
    else
      @settings = {}          
    end

    if self.respond_to?(:default_settings,true)
      @settings = default_settings.merge(@settings)
    else
      @settings
    end
  end
  
  def test
    self.private_methods.sort
  end

  def parse_yaml(path)
    path ? YAML.load_file(path) : nil
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gem_configurator-0.0.3 lib/gem_configurator.rb
gem_configurator-0.0.2 lib/gem_configurator.rb