Module: Pathsconfig

Defined in:
lib/pathsconfig/base.rb,
lib/pathsconfig/version.rb,
lib/pathsconfig/exceptions.rb,
lib/pathsconfig/extensions.rb,
lib/pathsconfig/configuration.rb

Defined Under Namespace

Modules: Base, Extensions, Version Classes: ConfigError, ModelError, PathsconfigError

Constant Summary collapse

@@config =
nil
@@root =
""

Class Method Summary collapse

Class Method Details

.clearObject



22
23
24
# File 'lib/pathsconfig/configuration.rb', line 22

def self.clear
  @@config = nil
end

.configObject



18
19
20
# File 'lib/pathsconfig/configuration.rb', line 18

def self.config
  @@config
end

.config=(path) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/pathsconfig/configuration.rb', line 6

def self.config=(path)
  begin
    @@config = YAML.load_file(File.expand_path(path))
    raise Pathsconfig::ConfigError, "Could not load paths configuration file: the config must be entered as a Hash" unless @@config.kind_of?(Hash)
    @@config.symbolize_keys!
  rescue Errno::ENOENT => err
    raise Pathsconfig::ConfigError, "Could not load paths configuration file: #{err.message}"
  rescue ArgumentError => err
    raise Pathsconfig::ConfigError, "Could not load paths configuration file: #{err.message}"
  end
end

.rootObject



30
31
32
# File 'lib/pathsconfig/configuration.rb', line 30

def self.root
  @@root
end

.root=(path) ⇒ Object



26
27
28
# File 'lib/pathsconfig/configuration.rb', line 26

def self.root=(path)
  @@root = Array(path)
end