Class: DeadCodeDetector::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/dead_code_detector/configuration.rb

Constant Summary collapse

STORAGE_BACKENDS =
{
  memory: Storage::MemoryBackend,
  redis: Storage::RedisBackend,
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



11
12
13
14
15
16
# File 'lib/dead_code_detector/configuration.rb', line 11

def initialize
  @allowed = true
  @classes_to_monitor = []
  @cache_expiry = 60 * 60 * 24 * 14
  @max_seconds_to_enable = 1
end

Instance Attribute Details

#allowedObject

Returns the value of attribute allowed.



4
5
6
# File 'lib/dead_code_detector/configuration.rb', line 4

def allowed
  @allowed
end

#cache_expiryObject

Returns the value of attribute cache_expiry.



4
5
6
# File 'lib/dead_code_detector/configuration.rb', line 4

def cache_expiry
  @cache_expiry
end

#classes_to_monitorObject

Returns the value of attribute classes_to_monitor.



4
5
6
# File 'lib/dead_code_detector/configuration.rb', line 4

def classes_to_monitor
  @classes_to_monitor
end

#error_handlerObject

Returns the value of attribute error_handler.



4
5
6
# File 'lib/dead_code_detector/configuration.rb', line 4

def error_handler
  @error_handler
end

#ignore_pathsObject

Returns the value of attribute ignore_paths.



4
5
6
# File 'lib/dead_code_detector/configuration.rb', line 4

def ignore_paths
  @ignore_paths
end

#max_seconds_to_enableObject

Returns the value of attribute max_seconds_to_enable.



4
5
6
# File 'lib/dead_code_detector/configuration.rb', line 4

def max_seconds_to_enable
  @max_seconds_to_enable
end

#redisObject

Returns the value of attribute redis.



4
5
6
# File 'lib/dead_code_detector/configuration.rb', line 4

def redis
  @redis
end

Instance Method Details

#storageObject



22
23
24
25
26
27
28
# File 'lib/dead_code_detector/configuration.rb', line 22

def storage
  if @storage
    @storage
  else
    raise "#{self.class.name}#storage is not configured"
  end
end

#storage=(backend_type) ⇒ Object



18
19
20
# File 'lib/dead_code_detector/configuration.rb', line 18

def storage=(backend_type)
  @storage ||= STORAGE_BACKENDS.fetch(backend_type).new
end