Module: Attractor

Defined in:
lib/attractor.rb,
lib/attractor/cli.rb,
lib/attractor/cache.rb,
lib/attractor/value.rb,
lib/attractor/version.rb,
lib/attractor/watcher.rb,
lib/attractor/gem_names.rb,
lib/attractor/suggester.rb,
lib/attractor/registry_entry.rb,
lib/attractor/duration_parser.rb,
lib/attractor/detectors/base_detector.rb,
lib/attractor/reporters/base_reporter.rb,
lib/attractor/reporters/html_reporter.rb,
lib/attractor/reporters/console_reporter.rb,
lib/attractor/reporters/sinatra_reporter.rb,
lib/attractor/calculators/base_calculator.rb

Defined Under Namespace

Modules: CacheAdapter Classes: AttractorApp, BaseCalculator, BaseDetector, BaseReporter, CLI, Cache, ConsoleReporter, DurationParser, Error, GemNames, HtmlReporter, RegistryEntry, SinatraReporter, Suggester, Value, Watcher

Constant Summary collapse

VERSION =
"2.6.0"

Class Method Summary collapse

Class Method Details

.all_registered_calculators(options = {}) ⇒ Object



45
46
47
48
49
# File 'lib/attractor.rb', line 45

def all_registered_calculators(options = {})
  @registry_entries.map do |type, entry|
    [type, entry.calculator_class.new(**options)] if entry.detector_class.new.detect
  end.compact.to_h
end

.calculators_for_type(type, **options) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/attractor.rb', line 37

def calculators_for_type(type, **options)
  registry_entry_for_type = @registry_entries[type]

  return {type => registry_entry_for_type.calculator_class.new(**options)} if type

  all_registered_calculators(**options)
end

.clearObject



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

def clear
  Cache.clear
end

.init(calculators) ⇒ Object



24
25
26
27
# File 'lib/attractor.rb', line 24

def init(calculators)
  calculators ||= all_registered_calculators
  calculators.to_a.map(&:last).each(&:calculate)
end

.register(registry_entry) ⇒ Object



33
34
35
# File 'lib/attractor.rb', line 33

def register(registry_entry)
  @registry_entries[registry_entry.type] = registry_entry
end