Class: Coat::Seam

Inherits:
Struct
  • Object
show all
Defined in:
lib/coat/seam.rb

Overview

Where more than one source laid a patch over the same ground. Surfacing the disagreement is the whole value; deciding who was right is a judgment call the tool has no business making, so nothing here resolves anything - it only reports whether somebody already did.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#mendObject

Returns the value of attribute mend

Returns:

  • (Object)

    the current value of mend



36
37
38
# File 'lib/coat/seam.rb', line 36

def mend
  @mend
end

#patchesObject

Returns the value of attribute patches

Returns:

  • (Object)

    the current value of patches



36
37
38
# File 'lib/coat/seam.rb', line 36

def patches
  @patches
end

#pathObject

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



36
37
38
# File 'lib/coat/seam.rb', line 36

def path
  @path
end

Class Method Details

.crossed(seams) ⇒ Object

The patches sitting on any seam, so each one can be marked without re-walking every seam.



46
47
48
# File 'lib/coat/seam.rb', line 46

def self.crossed(seams)
  seams.flat_map { |seam| seam.patches.map(&:seq) }.uniq
end

.find(patches, mends = {}) ⇒ Object



37
38
39
40
41
42
# File 'lib/coat/seam.rb', line 37

def self.find(patches, mends = {})
  claimants(patches)
    .select { |_path, claiming| claiming.map(&:agent).uniq.size > 1 }
    .map { |path, claiming| new(path: path, patches: claiming, mend: mends[path]) }
    .sort_by(&:path)
end

.mended(seams) ⇒ Object

The patches on a seam somebody has settled. Still marked, because the disagreement happened - but marked as closed rather than open.



52
53
54
# File 'lib/coat/seam.rb', line 52

def self.mended(seams)
  crossed(seams.select(&:mended?))
end

Instance Method Details

#agentsObject



63
64
65
# File 'lib/coat/seam.rb', line 63

def agents
  patches.map(&:agent).uniq
end

#mended?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/coat/seam.rb', line 67

def mended?
  !mend.nil?
end

#stateObject



71
72
73
# File 'lib/coat/seam.rb', line 71

def state
  mended? ? "mended" : "open"
end