Class: Bricolage::DataSourceFactory::Loader
- Inherits:
-
ConfigLoader
- Object
- ConfigLoader
- Bricolage::DataSourceFactory::Loader
- Defined in:
- lib/bricolage/datasource.rb
Constant Summary
Constants included from VacuumLock
VacuumLock::DEFAULT_VACUUM_LOCK_FILE, VacuumLock::DEFAULT_VACUUM_LOCK_TIMEOUT
Instance Method Summary collapse
-
#initialize(context, logger) ⇒ Loader
constructor
A new instance of Loader.
- #load(basename) ⇒ Object
- #load_passwords(basename) ⇒ Object
- #password(name) ⇒ Object
Methods inherited from ConfigLoader
#eruby, #load_eruby, #load_file, #load_yaml
Methods included from VacuumLock
cleanup_vacuum_lock, create_lockfile_cmd, create_vacuum_lock_file, enable_vacuum_lock?, locking?, psql_serialize_vacuum_begin, psql_serialize_vacuum_end, serialize_vacuum, using, #using_vacuum_lock, vacuum_lock_parameters
Constructor Details
#initialize(context, logger) ⇒ Loader
Returns a new instance of Loader.
25 26 27 28 29 30 |
# File 'lib/bricolage/datasource.rb', line 25 def initialize(context, logger) super context.home_path @context = context @logger = logger @passwords = nil end |
Instance Method Details
#load(basename) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/bricolage/datasource.rb', line 41 def load(basename) yml_path = @context.config_pathes(basename).detect(&:exist?) raise DataSourceFileNotExist, "database.yml does not exist" unless yml_path @config_dir = yml_path.parent DataSourceFactory.new(load_yaml(yml_path), @context, @logger) end |
#load_passwords(basename) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/bricolage/datasource.rb', line 32 def load_passwords(basename) @context.config_pathes(basename).each do |path| if path.exist? @passwords = load_yaml(path) break end end end |
#password(name) ⇒ Object
48 49 50 |
# File 'lib/bricolage/datasource.rb', line 48 def password(name) (@passwords || {})[name] or raise ParameterError, "no such password entry: #{name}" end |