class Guard::RSpec::Inspectors::KeepingInspector

Inspector that remembers all failed paths and returns that paths in future calls to paths method along with any new paths passed as parameter to paths

Attributes

failed_locations[RW]

Public Class Methods

new(options = {}) click to toggle source
# File lib/guard/rspec/inspectors/keeping_inspector.rb, line 12
def initialize(options = {})
  super
  @failed_locations = []
end

Public Instance Methods

failed(locations) click to toggle source
# File lib/guard/rspec/inspectors/keeping_inspector.rb, line 21
def failed(locations)
  @failed_locations = locations
end
paths(paths) click to toggle source
# File lib/guard/rspec/inspectors/keeping_inspector.rb, line 17
def paths(paths)
  _with_failed_locations(_clean(paths))
end
reload() click to toggle source
# File lib/guard/rspec/inspectors/keeping_inspector.rb, line 25
def reload
  @failed_locations = []
end

Private Instance Methods

_location_path(location) click to toggle source

Extract file path from location

# File lib/guard/rspec/inspectors/keeping_inspector.rb, line 39
def _location_path(location)
  location.match(%r{^(\./)?(.*?)(:\d+)?$})[2]
end
_with_failed_locations(paths) click to toggle source

Return paths + failed locations. Do not include location in result if its path is already included.

# File lib/guard/rspec/inspectors/keeping_inspector.rb, line 33
def _with_failed_locations(paths)
  failed_paths = failed_locations.map { |l| _location_path(l) }
  (paths | failed_paths).uniq
end