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.
-
#test_blocks ⇒ Object
Returns the value of attribute test_blocks.
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
- #validate! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
9 10 11 12 13 14 15 |
# File 'lib/flaky/configuration.rb', line 9 def initialize @provider_name = nil @project = nil @branch = "main" @db_path = nil # resolved lazily @test_blocks = ["Unit Tests", "System Tests"] 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 |
#test_blocks ⇒ Object
Returns the value of attribute test_blocks.
7 8 9 |
# File 'lib/flaky/configuration.rb', line 7 def test_blocks @test_blocks end |
Class Method Details
.register_provider(name, klass) ⇒ Object
40 41 42 |
# File 'lib/flaky/configuration.rb', line 40 def self.register_provider(name, klass) PROVIDERS[name.to_sym] = klass end |
Instance Method Details
#provider=(name) ⇒ Object
17 18 19 |
# File 'lib/flaky/configuration.rb', line 17 def provider=(name) @provider_name = name.to_sym end |
#provider_instance ⇒ Object
21 22 23 24 25 |
# File 'lib/flaky/configuration.rb', line 21 def provider_instance validate! klass = PROVIDERS[@provider_name] || raise(Error, "Unknown provider: #{@provider_name}. Registered: #{PROVIDERS.keys.join(', ')}") klass.new(self) end |
#resolved_db_path ⇒ Object
27 28 29 |
# File 'lib/flaky/configuration.rb', line 27 def resolved_db_path @db_path || (defined?(Rails) ? Rails.root.join("tmp", "flaky.db").to_s : "tmp/flaky.db") end |
#validate! ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/flaky/configuration.rb', line 31 def validate! unless @provider_name raise Error, "Flaky: provider not configured. Add `Flaky.configure { |c| c.provider = :semaphore }` to your initializer." end unless @project raise Error, "Flaky: project not configured. Add `Flaky.configure { |c| c.project = 'your-project' }` to your initializer." end end |