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 = DEFAULT_CONFIG_FILE_NAME) ⇒ Object
- #load_passwords(basename = DEFAULT_PASSWORD_FILE_NAME) ⇒ Object
- #password(name) ⇒ Object
Methods inherited from ConfigLoader
#eruby, #load_text, #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.
18 19 20 21 22 23 |
# File 'lib/bricolage/datasource.rb', line 18 def initialize(context, logger) super context.home_path @context = context @logger = logger @passwords = nil end |
Instance Method Details
#load(basename = DEFAULT_CONFIG_FILE_NAME) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/bricolage/datasource.rb', line 34 def load(basename = DEFAULT_CONFIG_FILE_NAME) database_yml = @context.config_pathes(basename).detect {|path| path.exist? } raise ParameterError, "database.yml does not exist" unless database_yml @config_dir = database_yml.parent DataSourceFactory.new(load_yaml(database_yml), @context, @logger) end |
#load_passwords(basename = DEFAULT_PASSWORD_FILE_NAME) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/bricolage/datasource.rb', line 25 def load_passwords(basename = DEFAULT_PASSWORD_FILE_NAME) @context.config_pathes(basename).each do |path| if path.exist? @passwords = load_yaml(path) break end end end |
#password(name) ⇒ Object
41 42 43 |
# File 'lib/bricolage/datasource.rb', line 41 def password(name) (@passwords || {})[name] or raise ParameterError, "no such password entry: #{name}" end |