Class: Skunk::Configuration
- Inherits:
-
Object
- Object
- Skunk::Configuration
- Defined in:
- lib/skunk/config.rb
Overview
Configuration class for Skunk that supports formats Similar to RubyCritic::Configuration but focused only on Skunk’s needs
Constant Summary collapse
- DEFAULT_FORMAT =
Default format
:console
Instance Attribute Summary collapse
-
#formats ⇒ Array<Symbol>
Get the configured formats.
Instance Method Summary collapse
-
#add_format(format) ⇒ Object
Add a format to the existing list.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#remove_format(format) ⇒ Object
Remove a format from the list.
-
#reset ⇒ Object
Reset to default configuration.
- #set(options = {}) ⇒ Object
-
#supported_format?(format) ⇒ Boolean
Check if a format is supported.
-
#supported_formats ⇒ Array<Symbol>
Get all supported formats.
Constructor Details
#initialize ⇒ Configuration
29 30 31 |
# File 'lib/skunk/config.rb', line 29 def initialize @formats = [DEFAULT_FORMAT] end |
Instance Attribute Details
#formats ⇒ Array<Symbol>
Get the configured formats
39 40 41 |
# File 'lib/skunk/config.rb', line 39 def formats @formats end |
Instance Method Details
#add_format(format) ⇒ Object
Add a format to the existing list
51 52 53 54 55 |
# File 'lib/skunk/config.rb', line 51 def add_format(format) return unless FormatValidator.supported_format?(format) @formats << format unless @formats.include?(format) end |
#remove_format(format) ⇒ Object
Remove a format from the list
59 60 61 62 |
# File 'lib/skunk/config.rb', line 59 def remove_format(format) @formats.delete(format) @formats = [DEFAULT_FORMAT] if @formats.empty? end |
#reset ⇒ Object
Reset to default configuration
78 79 80 |
# File 'lib/skunk/config.rb', line 78 def reset @formats = [DEFAULT_FORMAT] end |
#set(options = {}) ⇒ Object
33 34 35 |
# File 'lib/skunk/config.rb', line 33 def set( = {}) self.formats = [:formats] if .key?(:formats) end |
#supported_format?(format) ⇒ Boolean
Check if a format is supported
67 68 69 |
# File 'lib/skunk/config.rb', line 67 def supported_format?(format) FormatValidator.supported_format?(format) end |
#supported_formats ⇒ Array<Symbol>
Get all supported formats
73 74 75 |
# File 'lib/skunk/config.rb', line 73 def supported_formats FormatValidator.supported_formats end |