Module: Configy

Defined in:
lib/configy.rb,
lib/configy/base.rb,
lib/configy/config_file.rb,
lib/configy/config_store.rb,
lib/configy/string_inquirer.rb,
lib/generators/configy_generator.rb,
lib/generators/configy/install/install_generator.rb

Defined Under Namespace

Classes: Base, ConfigFile, ConfigParamNotFound, ConfigStore, ConfigyError, InstallGenerator, StringInquirer

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.cache_configObject



35
36
37
38
# File 'lib/configy.rb', line 35

def cache_config
  @cache_config = false if @cache_config.nil?
  @cache_config
end

.load_pathObject



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/configy.rb', line 13

def load_path
  if @load_path
    @load_path
  elsif defined? Rails
    Rails.root.join("config")
  elsif ENV['RAILS_ROOT']
    "#{ENV['RAILS_ROOT']}/config"
  elsif ENV['RACK_ROOT']
    "#{ENV['RACK_ROOT']}/config"
  else
    'config'
  end
end

Class Method Details

.camelize(phrase) ⇒ Object



47
48
49
50
51
52
53
# File 'lib/configy.rb', line 47

def self.camelize(phrase)
  camelized = phrase.gsub(/^[a-z]|\s+[a-z]|_+[a-z]|-+[a-z]/i) { |a| a.upcase }
  camelized.gsub!(/\s/, '')
  camelized.gsub!(/_/, '')
  camelized.gsub!(/-/, '')
  return camelized
end

.create(file, parent = Object) ⇒ Object

The main interface for creating Configy instances



56
57
58
# File 'lib/configy.rb', line 56

def self.create(file, parent=Object)
  parent.const_set( camelize(file.to_s), Configy::Base.new(file, section, load_path, cache_config) )
end

.sectionObject



27
28
29
# File 'lib/configy.rb', line 27

def section
  @section ||= Configy::StringInquirer.new(section_string)
end

.section=(value) ⇒ Object



31
32
33
# File 'lib/configy.rb', line 31

def section=( value )
  @section = value.is_a?(String) ? Configy::StringInquirer.new(value) : value
end