Sha256: dac1e60613015fa51a932e33b05e3f0c4d953dea4703970893a74b645fd8c03a

Contents?: true

Size: 766 Bytes

Versions: 5

Compression:

Stored size: 766 Bytes

Contents

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

module GemConfigurator

  attr_reader :settings
  
  private
  
  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 parse_yaml(path)
    path ? YAML.load_file(path) : nil
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gem_configurator-1.0.1 lib/gem_configurator.rb
gem_configurator-1.0.0 lib/gem_configurator.rb
gem_configurator-0.0.6 lib/gem_configurator.rb
gem_configurator-0.0.5 lib/gem_configurator.rb
gem_configurator-0.0.4 lib/gem_configurator.rb