Class: Milestoner::Views::Parts::Tag
- Inherits:
-
Hanami::View::Part
- Object
- Hanami::View::Part
- Milestoner::Views::Parts::Tag
- Defined in:
- lib/milestoner/views/parts/tag.rb
Overview
The tag presentation logic.
Instance Method Summary collapse
- #colored_total_deletions(*custom) ⇒ Object
- #colored_total_insertions(*custom) ⇒ Object
- #commit_count ⇒ Object
- #committed_at(fallback: Time.now) ⇒ Object
- #committed_date ⇒ Object
- #committed_datetime ⇒ Object
- #contributor_names ⇒ Object
- #deletion_count ⇒ Object
- #duration ⇒ Object
- #empty? ⇒ Boolean
- #file_count ⇒ Object
- #index? ⇒ Boolean
- #insertion_count ⇒ Object
- #security ⇒ Object
- #total_commits ⇒ Object
- #total_deletions ⇒ Object
- #total_duration ⇒ Object
- #total_files ⇒ Object
- #total_insertions ⇒ Object
- #uri ⇒ Object
Instance Method Details
#colored_total_deletions(*custom) ⇒ Object
21 22 23 24 |
# File 'lib/milestoner/views/parts/tag.rb', line 21 def colored_total_deletions(*custom) custom.push :green if custom.empty? color[total_deletions, *custom] end |
#colored_total_insertions(*custom) ⇒ Object
26 27 28 29 |
# File 'lib/milestoner/views/parts/tag.rb', line 26 def colored_total_insertions(*custom) custom.push :red if custom.empty? color[total_insertions, *custom] end |
#commit_count ⇒ Object
31 |
# File 'lib/milestoner/views/parts/tag.rb', line 31 def commit_count = commits.size |
#committed_at(fallback: Time.now) ⇒ Object
33 34 35 |
# File 'lib/milestoner/views/parts/tag.rb', line 33 def committed_at fallback: Time.now value.committed_at.then { |at| at ? Time.at(at) : fallback } end |
#committed_date ⇒ Object
37 |
# File 'lib/milestoner/views/parts/tag.rb', line 37 def committed_date = committed_at.strftime "%Y-%m-%d" |
#committed_datetime ⇒ Object
39 |
# File 'lib/milestoner/views/parts/tag.rb', line 39 def committed_datetime = committed_at.strftime "%Y-%m-%dT%H:%M:%S%z" |
#contributor_names ⇒ Object
41 |
# File 'lib/milestoner/views/parts/tag.rb', line 41 def contributor_names = contributors.map(&:name).to_sentence |
#deletion_count ⇒ Object
43 |
# File 'lib/milestoner/views/parts/tag.rb', line 43 def deletion_count = commits.sum(&:deletions) |
#duration ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/milestoner/views/parts/tag.rb', line 45 def duration return 0 if commits.empty? min = commits.min_by(&:created_at) max = commits.max_by(&:updated_at) (max.updated_at - min.created_at).to_i end |
#empty? ⇒ Boolean
53 |
# File 'lib/milestoner/views/parts/tag.rb', line 53 def empty? = commits.empty? |
#file_count ⇒ Object
55 |
# File 'lib/milestoner/views/parts/tag.rb', line 55 def file_count = commits.sum(&:files_changed) |
#index? ⇒ Boolean
57 |
# File 'lib/milestoner/views/parts/tag.rb', line 57 def index? = settings.build_index |
#insertion_count ⇒ Object
59 |
# File 'lib/milestoner/views/parts/tag.rb', line 59 def insertion_count = commits.sum(&:insertions) |
#security ⇒ Object
61 |
# File 'lib/milestoner/views/parts/tag.rb', line 61 def security = signature ? "🔒 Tag (secure)" : "🔓 Tag (insecure)" |
#total_commits ⇒ Object
63 |
# File 'lib/milestoner/views/parts/tag.rb', line 63 def total_commits = commit_count.then { |total| "#{total} commit".pluralize "s", total } |
#total_deletions ⇒ Object
67 68 69 |
# File 'lib/milestoner/views/parts/tag.rb', line 67 def total_deletions deletion_count.then { |total| "#{total} deletion".pluralize "s", total } end |
#total_duration ⇒ Object
71 |
# File 'lib/milestoner/views/parts/tag.rb', line 71 def total_duration = duration.zero? ? "0 seconds" : durationer.call(duration) |
#total_files ⇒ Object
65 |
# File 'lib/milestoner/views/parts/tag.rb', line 65 def total_files = file_count.then { |total| "#{total} file".pluralize "s", total } |
#total_insertions ⇒ Object
73 74 75 |
# File 'lib/milestoner/views/parts/tag.rb', line 73 def total_insertions insertion_count.then { |total| "#{total} insertion".pluralize "s", total } end |
#uri ⇒ Object
77 |
# File 'lib/milestoner/views/parts/tag.rb', line 77 def uri = format settings.project_uri_version, id: version |