Module: Rails::Generators::Hyperdrive::InstallSummary
- Defined in:
- lib/generators/hyperdrive/install_summary.rb
Constant Summary collapse
- KIND_WIDTH =
"guideline".length
- KIND_ORDER =
%w[skill guideline].freeze
Class Method Summary collapse
-
.lines(entries) ⇒ Object
The lock is the authoritative set: it includes untouched, locally-modified, and orphaned files.
Class Method Details
.lines(entries) ⇒ Object
The lock is the authoritative set: it includes untouched, locally-modified, and orphaned files.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/generators/hyperdrive/install_summary.rb', line 14 def lines(entries) entries = entries.to_a return [] if entries.empty? support, listed = entries.partition { |e| e.kind.to_s == "skill_support" } # A carried SKILL.md entry can record an older source than its # supporting files, so counts key on the installed directory name, # which is unique across sources. support_counts = support .group_by { |e| ::Rails::Hyperdrive::InstallLayout.installed_name(:skill_support, e.path.to_s) } .transform_values(&:size) out = [" #{installed_counts(listed)}", ""] group_by_source(listed).each do |source, group| out << " #{source}" group.each do |entry| name = display_name(entry) count = entry.kind.to_s == "skill" ? support_counts[name].to_i : 0 suffix = count.positive? ? " (+#{quantify(count, "file")})" : "" out << " #{entry.kind.to_s.ljust(KIND_WIDTH)} #{name}#{suffix}" end end out end |