Class: DeprecationToolkit::Collector

Inherits:
Object
  • Object
show all
Extended by:
ReadWriteHelper
Includes:
Comparable
Defined in:
lib/deprecation_toolkit/collector.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ReadWriteHelper

read, write

Constructor Details

#initialize(deprecations) ⇒ Collector

Returns a new instance of Collector.



28
29
30
# File 'lib/deprecation_toolkit/collector.rb', line 28

def initialize(deprecations)
  self.deprecations = deprecations
end

Class Method Details

.collect(message) ⇒ Object



15
16
17
# File 'lib/deprecation_toolkit/collector.rb', line 15

def collect(message)
  deprecations << message
end

.load(test) ⇒ Object



19
20
21
# File 'lib/deprecation_toolkit/collector.rb', line 19

def load(test)
  new(read(test))
end

.reset!Object



23
24
25
# File 'lib/deprecation_toolkit/collector.rb', line 23

def reset!
  deprecations.clear
end

Instance Method Details

#-(other) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/deprecation_toolkit/collector.rb', line 44

def -(other)
  difference = deprecations.dup
  current = deprecations_without_stacktrace
  other = other.deprecations_without_stacktrace

  other.each do |deprecation|
    index = current.index(deprecation)

    if index
      current.delete_at(index)
      difference.delete_at(index)
    end
  end

  difference
end

#<=>(other) ⇒ Object



32
33
34
# File 'lib/deprecation_toolkit/collector.rb', line 32

def <=>(other)
  deprecations_without_stacktrace <=> other.deprecations_without_stacktrace
end

#deprecations_without_stacktraceObject



36
37
38
39
40
41
42
# File 'lib/deprecation_toolkit/collector.rb', line 36

def deprecations_without_stacktrace
  deprecations.map do |deprecation|
    deprecation
      .sub(*active_support_deprecation_sub_params)
      .sub(*gem_deprecate_sub_params)
  end
end

#flaky?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/deprecation_toolkit/collector.rb', line 61

def flaky?
  size == 1 && deprecations.first["flaky"] == true
end