Module: Coat::Palette
- Defined in:
- lib/coat/palette.rb
Overview
Assigns each source a color from the quilt palette, derived from its name. The same agent gets the same patch color in every build, on every machine, so color carries provenance without a legend lookup.
Constant Summary collapse
- COLORS =
%w[brick gold forest denim plum rust teal clay].freeze
Class Method Summary collapse
- .for(name) ⇒ Object
-
.legend(names) ⇒ Object
The distinct colors in play, in the order their sources first appear, so the header strip reads as the document's own palette.
Class Method Details
.for(name) ⇒ Object
12 13 14 |
# File 'lib/coat/palette.rb', line 12 def self.for(name) COLORS[Digest::SHA256.hexdigest(name.to_s).to_i(16) % COLORS.size] end |
.legend(names) ⇒ Object
The distinct colors in play, in the order their sources first appear, so the header strip reads as the document's own palette.
18 19 20 |
# File 'lib/coat/palette.rb', line 18 def self.legend(names) names.uniq.map { |name| [name, self.for(name)] } end |