Class: Polyrun::Config
- Inherits:
-
Object
- Object
- Polyrun::Config
- Defined in:
- lib/polyrun/config.rb
Overview
Loads polyrun.yml (or path from POLYRUN_CONFIG / –config).
Constant Summary collapse
- DEFAULT_FILENAMES =
%w[polyrun.yml config/polyrun.yml].freeze
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Class Method Summary collapse
Instance Method Summary collapse
- #coverage ⇒ Object
- #databases ⇒ Object
-
#initialize(path:, raw:) ⇒ Config
constructor
A new instance of Config.
- #partition ⇒ Object
- #prepare ⇒ Object
-
#start_config ⇒ Object
Optional
start:block:prepare/databasesbooleans override auto-detection for polyrun start. - #version ⇒ Object
Constructor Details
#initialize(path:, raw:) ⇒ Config
Returns a new instance of Config.
31 32 33 34 |
# File 'lib/polyrun/config.rb', line 31 def initialize(path:, raw:) @path = path @raw = raw.freeze end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
8 9 10 |
# File 'lib/polyrun/config.rb', line 8 def path @path end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
8 9 10 |
# File 'lib/polyrun/config.rb', line 8 def raw @raw end |
Class Method Details
.load(path: nil) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/polyrun/config.rb', line 10 def self.load(path: nil) path = resolve_path(path) raw = if path && File.file?(path) YAML.safe_load_file(path, permitted_classes: [Symbol], aliases: true) || {} else {} end new(path: path, raw: raw) end |
.resolve_path(explicit) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/polyrun/config.rb', line 21 def self.resolve_path(explicit) return File.(explicit) if explicit && !explicit.empty? DEFAULT_FILENAMES.each do |name| full = File.(name, Dir.pwd) return full if File.file?(full) end nil end |
Instance Method Details
#coverage ⇒ Object
44 45 46 |
# File 'lib/polyrun/config.rb', line 44 def coverage raw["coverage"] || raw[:coverage] || {} end |
#databases ⇒ Object
48 49 50 |
# File 'lib/polyrun/config.rb', line 48 def databases raw["databases"] || raw[:databases] || {} end |
#partition ⇒ Object
36 37 38 |
# File 'lib/polyrun/config.rb', line 36 def partition raw["partition"] || raw[:partition] || {} end |
#prepare ⇒ Object
40 41 42 |
# File 'lib/polyrun/config.rb', line 40 def prepare raw["prepare"] || raw[:prepare] || {} end |
#start_config ⇒ Object
Optional start: block: prepare / databases booleans override auto-detection for polyrun start.
53 54 55 |
# File 'lib/polyrun/config.rb', line 53 def start_config raw["start"] || raw[:start] || {} end |
#version ⇒ Object
57 58 59 |
# File 'lib/polyrun/config.rb', line 57 def version raw["version"] || raw[:version] end |