Class: PersistenceDetector::Client
- Inherits:
-
Object
- Object
- PersistenceDetector::Client
- Defined in:
- lib/persistence_detector.rb
Overview
Client contains methods for invoking persistence detector functionality.
Instance Attribute Summary collapse
-
#current_platform ⇒ Object
Returns the value of attribute current_platform.
Instance Method Summary collapse
- #detect_persistence_ttp(ttp_id) ⇒ Object
- #enable_verbose ⇒ Object
-
#initialize ⇒ Client
constructor
A new instance of Client.
- #list_detectors ⇒ Object
Constructor Details
#initialize ⇒ Client
Returns a new instance of Client.
21 22 23 24 |
# File 'lib/persistence_detector.rb', line 21 def initialize super @current_platform = Gem::Platform::local.os end |
Instance Attribute Details
#current_platform ⇒ Object
Returns the value of attribute current_platform.
19 20 21 |
# File 'lib/persistence_detector.rb', line 19 def current_platform @current_platform end |
Instance Method Details
#detect_persistence_ttp(ttp_id) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/persistence_detector.rb', line 30 def detect_persistence_ttp(ttp_id) if ttp_id == 'all' || ttp_id == '' $logger.debug('executing all applicable persistence detectors') $detector_registry.each do |d| d.detect_persistence if d.platforms.include? @current_platform end else $detector_registry.each do |d| if ttp_id == d.ttp_id $logger.debug("executing detector: #{d.ttp_id}") if d.platforms.include? @current_platform d.detect_persistence else $logger.fatal("attempted to run #{d.ttp_id} on #{@current_platform}, but detector only works on #{d.platforms}") end else $logger.fatal("unable to find detector: #{d.ttp_id}") end end end end |
#enable_verbose ⇒ Object
26 27 28 |
# File 'lib/persistence_detector.rb', line 26 def enable_verbose Log.enable_verbose end |
#list_detectors ⇒ Object
55 56 57 |
# File 'lib/persistence_detector.rb', line 55 def list_detectors $detector_registry.each(&:display_metadata) end |