Class: Skunk::Configuration

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeConfiguration



29
30
31
# File 'lib/skunk/config.rb', line 29

def initialize
  @formats = [DEFAULT_FORMAT]
end

Instance Attribute Details

#formatsArray<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

#resetObject

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(options = {})
  self.formats = options[:formats] if options.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_formatsArray<Symbol>

Get all supported formats



73
74
75
# File 'lib/skunk/config.rb', line 73

def supported_formats
  FormatValidator.supported_formats
end