Class: Evilution::Reporter::Suggestion::Registry Private

Inherits:
Object
  • Object
show all
Defined in:
lib/evilution/reporter/suggestion/registry.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRegistry

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Registry.



32
33
34
35
# File 'lib/evilution/reporter/suggestion/registry.rb', line 32

def initialize
  @generic = {}
  @concrete = Hash.new { |h, k| h[k] = {} }
end

Class Method Details

.defaultObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/evilution/reporter/suggestion/registry.rb', line 7

def self.default
  return @default if @default

  require_relative "templates/generic"
  require_relative "templates/rspec"
  require_relative "templates/minitest"

  registry = new
  Evilution::Reporter::Suggestion::Templates::Generic::GENERIC_ENTRIES.each do |op, text|
    registry.register_generic(op, text)
  end
  Evilution::Reporter::Suggestion::Templates::Rspec::RSPEC_ENTRIES.each do |op, blk|
    registry.register_concrete(op, integration: :rspec, block: blk)
  end
  Evilution::Reporter::Suggestion::Templates::Minitest::MINITEST_ENTRIES.each do |op, blk|
    registry.register_concrete(op, integration: :minitest, block: blk)
  end

  @default = registry
end

.reset!Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



28
29
30
# File 'lib/evilution/reporter/suggestion/registry.rb', line 28

def self.reset!
  @default = nil
end

Instance Method Details

#concrete(operator_name, integration:) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



51
52
53
# File 'lib/evilution/reporter/suggestion/registry.rb', line 51

def concrete(operator_name, integration:)
  @concrete.fetch(integration, {})[operator_name]
end

#each_generic_operatorObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



55
56
57
58
59
# File 'lib/evilution/reporter/suggestion/registry.rb', line 55

def each_generic_operator(&)
  return @generic.each_key unless block_given?

  @generic.each_key(&)
end

#generic(operator_name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



47
48
49
# File 'lib/evilution/reporter/suggestion/registry.rb', line 47

def generic(operator_name)
  @generic[operator_name]
end

#register_concrete(operator_name, integration:, block:) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



42
43
44
45
# File 'lib/evilution/reporter/suggestion/registry.rb', line 42

def register_concrete(operator_name, integration:, block:)
  @concrete[integration][operator_name] = block
  self
end

#register_generic(operator_name, text) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



37
38
39
40
# File 'lib/evilution/reporter/suggestion/registry.rb', line 37

def register_generic(operator_name, text)
  @generic[operator_name] = text
  self
end