Class: Flaky::Configuration
- Inherits:
-
Object
- Object
- Flaky::Configuration
- Defined in:
- lib/flaky/configuration.rb
Constant Summary collapse
- PROVIDERS =
{}
Instance Attribute Summary collapse
-
#branch ⇒ Object
Returns the value of attribute branch.
-
#db_path ⇒ Object
Returns the value of attribute db_path.
-
#project ⇒ Object
Returns the value of attribute project.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #provider=(name) ⇒ Object
- #provider_instance ⇒ Object
- #resolved_db_path ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
9 10 11 12 13 14 |
# File 'lib/flaky/configuration.rb', line 9 def initialize @provider_name = nil @project = nil @branch = "main" @db_path = nil # resolved lazily end |
Instance Attribute Details
#branch ⇒ Object
Returns the value of attribute branch.
7 8 9 |
# File 'lib/flaky/configuration.rb', line 7 def branch @branch end |
#db_path ⇒ Object
Returns the value of attribute db_path.
7 8 9 |
# File 'lib/flaky/configuration.rb', line 7 def db_path @db_path end |
#project ⇒ Object
Returns the value of attribute project.
7 8 9 |
# File 'lib/flaky/configuration.rb', line 7 def project @project end |
Class Method Details
.register_provider(name, klass) ⇒ Object
29 30 31 |
# File 'lib/flaky/configuration.rb', line 29 def self.register_provider(name, klass) PROVIDERS[name.to_sym] = klass end |
Instance Method Details
#provider=(name) ⇒ Object
16 17 18 |
# File 'lib/flaky/configuration.rb', line 16 def provider=(name) @provider_name = name.to_sym end |
#provider_instance ⇒ Object
20 21 22 23 |
# File 'lib/flaky/configuration.rb', line 20 def provider_instance klass = PROVIDERS[@provider_name] || raise(Error, "Unknown provider: #{@provider_name}. Registered: #{PROVIDERS.keys.join(', ')}") klass.new(self) end |
#resolved_db_path ⇒ Object
25 26 27 |
# File 'lib/flaky/configuration.rb', line 25 def resolved_db_path @db_path || (defined?(Rails) ? Rails.root.join("tmp", "flaky.db").to_s : "tmp/flaky.db") end |