Class: Coat::Seam
- Inherits:
-
Struct
- Object
- Struct
- Coat::Seam
- 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
-
#mend ⇒ Object
Returns the value of attribute mend.
-
#patches ⇒ Object
Returns the value of attribute patches.
-
#path ⇒ Object
Returns the value of attribute path.
Class Method Summary collapse
-
.crossed(seams) ⇒ Object
The patches sitting on any seam, so each one can be marked without re-walking every seam.
- .find(patches, mends = {}) ⇒ Object
-
.mended(seams) ⇒ Object
The patches on a seam somebody has settled.
Instance Method Summary collapse
Instance Attribute Details
#mend ⇒ Object
Returns the value of attribute mend
36 37 38 |
# File 'lib/coat/seam.rb', line 36 def mend @mend end |
#patches ⇒ Object
Returns the value of attribute patches
36 37 38 |
# File 'lib/coat/seam.rb', line 36 def patches @patches end |
#path ⇒ Object
Returns the value of attribute 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
#agents ⇒ Object
63 64 65 |
# File 'lib/coat/seam.rb', line 63 def agents patches.map(&:agent).uniq end |
#mended? ⇒ Boolean
67 68 69 |
# File 'lib/coat/seam.rb', line 67 def mended? !mend.nil? end |
#state ⇒ Object
71 72 73 |
# File 'lib/coat/seam.rb', line 71 def state mended? ? "mended" : "open" end |