Class: Ucode::Audit::Release::FaceCard
- Inherits:
-
Object
- Object
- Ucode::Audit::Release::FaceCard
- Defined in:
- lib/ucode/audit/release/face_card.rb
Overview
Value object deriving the per-face card fields shared by
LibraryIndexBuilder (Hash for library.json) and
ManifestBuilder (Models::Audit::ReleaseFaceEntry for
manifest.json).
Single source of truth for the rollup math (covered total,
assigned total, complete/partial block counts) and the path
conventions (face label sanitization, relative index/html
paths under <release_root>/audit/<slug>/<label>/).
Pure: no I/O, no mutation. Callers compose the final shape (Hash or model) from the derived fields.
Instance Attribute Summary collapse
-
#release_root ⇒ Object
readonly
Returns the value of attribute release_root.
-
#report ⇒ Object
readonly
Returns the value of attribute report.
-
#slug ⇒ Object
readonly
Returns the value of attribute slug.
Instance Method Summary collapse
- #assigned_total ⇒ Integer
- #blocks_complete ⇒ Integer
- #blocks_partial ⇒ Integer
- #covered_total ⇒ Integer
-
#face_dir ⇒ Pathname
<release_root>/audit/<slug>/<label>. -
#html_path ⇒ String
Relative path from release root to index.html.
-
#index_path ⇒ String
Relative path from release root to index.json.
-
#initialize(report, slug, release_root) ⇒ FaceCard
constructor
A new instance of FaceCard.
-
#label ⇒ String
Sanitized face label (postscript name with non-filename chars replaced by underscore).
Constructor Details
#initialize(report, slug, release_root) ⇒ FaceCard
Returns a new instance of FaceCard.
29 30 31 32 33 |
# File 'lib/ucode/audit/release/face_card.rb', line 29 def initialize(report, slug, release_root) @report = report @slug = slug @release_root = release_root end |
Instance Attribute Details
#release_root ⇒ Object (readonly)
Returns the value of attribute release_root.
24 25 26 |
# File 'lib/ucode/audit/release/face_card.rb', line 24 def release_root @release_root end |
#report ⇒ Object (readonly)
Returns the value of attribute report.
24 25 26 |
# File 'lib/ucode/audit/release/face_card.rb', line 24 def report @report end |
#slug ⇒ Object (readonly)
Returns the value of attribute slug.
24 25 26 |
# File 'lib/ucode/audit/release/face_card.rb', line 24 def slug @slug end |
Instance Method Details
#assigned_total ⇒ Integer
53 54 55 |
# File 'lib/ucode/audit/release/face_card.rb', line 53 def assigned_total report.blocks.sum(&:total_assigned) end |
#blocks_complete ⇒ Integer
58 59 60 61 62 |
# File 'lib/ucode/audit/release/face_card.rb', line 58 def blocks_complete report.blocks.count do |b| b.status == Models::Audit::BlockSummary::STATUS_COMPLETE end end |
#blocks_partial ⇒ Integer
65 66 67 68 69 |
# File 'lib/ucode/audit/release/face_card.rb', line 65 def blocks_partial report.blocks.count do |b| b.status == Models::Audit::BlockSummary::STATUS_PARTIAL end end |
#covered_total ⇒ Integer
48 49 50 |
# File 'lib/ucode/audit/release/face_card.rb', line 48 def covered_total report.blocks.sum(&:covered_count) end |
#face_dir ⇒ Pathname
Returns <release_root>/audit/<slug>/<label>.
43 44 45 |
# File 'lib/ucode/audit/release/face_card.rb', line 43 def face_dir Ucode::Audit::Emitter::Paths.release_face_dir(release_root, slug, label) end |
#html_path ⇒ String
Returns relative path from release root to index.html.
77 78 79 |
# File 'lib/ucode/audit/release/face_card.rb', line 77 def html_path relative_path(face_dir.join("index.html")) end |
#index_path ⇒ String
Returns relative path from release root to index.json.
72 73 74 |
# File 'lib/ucode/audit/release/face_card.rb', line 72 def index_path relative_path(face_dir.join("index.json")) end |
#label ⇒ String
Returns sanitized face label (postscript name with non-filename chars replaced by underscore).
37 38 39 40 |
# File 'lib/ucode/audit/release/face_card.rb', line 37 def label name = report.postscript_name || File.basename(report.source_file.to_s, ".*") (name || "face").to_s.gsub(/[^A-Za-z0-9._-]/, "_") end |