Class: HeedKit::Changelog
- Inherits:
-
Object
- Object
- HeedKit::Changelog
- Includes:
- Enumerable
- Defined in:
- lib/heedkit/changelog.rb
Overview
A project's public changelog: published entries, newest first.
Constant Summary collapse
- CATEGORY_LABELS =
{ "new" => "New", "improved" => "Improved", "fixed" => "Fixed", "announcement" => "Announcement" }.freeze
Instance Attribute Summary collapse
-
#entries ⇒ Object
readonly
Returns the value of attribute entries.
-
#project_name ⇒ Object
readonly
Returns the value of attribute project_name.
-
#theme ⇒ Object
readonly
Returns the value of attribute theme.
Class Method Summary collapse
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize(project_name:, theme:, entries:) ⇒ Changelog
constructor
A new instance of Changelog.
- #primary_color ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize(project_name:, theme:, entries:) ⇒ Changelog
Returns a new instance of Changelog.
40 41 42 43 44 |
# File 'lib/heedkit/changelog.rb', line 40 def initialize(project_name:, theme:, entries:) @project_name = project_name @theme = theme @entries = entries end |
Instance Attribute Details
#entries ⇒ Object (readonly)
Returns the value of attribute entries.
20 21 22 |
# File 'lib/heedkit/changelog.rb', line 20 def entries @entries end |
#project_name ⇒ Object (readonly)
Returns the value of attribute project_name.
20 21 22 |
# File 'lib/heedkit/changelog.rb', line 20 def project_name @project_name end |
#theme ⇒ Object (readonly)
Returns the value of attribute theme.
20 21 22 |
# File 'lib/heedkit/changelog.rb', line 20 def theme @theme end |
Class Method Details
.from_payload(payload) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/heedkit/changelog.rb', line 22 def self.from_payload(payload) entries = (payload["entries"] || []).map do |e| ChangelogEntry.new( id: e["id"], title: e["title"], body: e["body"], category: e["category"], category_label: e["category_label"] || CATEGORY_LABELS[e["category"]] || e["category"], published_at: parse_time(e["published_at"]) ) end new(project_name: payload["project_name"], theme: payload["theme"] || {}, entries: entries) end |
.parse_time(value) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/heedkit/changelog.rb', line 33 def self.parse_time(value) return nil if value.to_s.empty? Time.iso8601(value.to_s) rescue ArgumentError nil end |
Instance Method Details
#each(&block) ⇒ Object
47 |
# File 'lib/heedkit/changelog.rb', line 47 def each(&block) = entries.each(&block) |
#primary_color ⇒ Object
49 50 51 |
# File 'lib/heedkit/changelog.rb', line 49 def primary_color theme["primary"] || "#0d9488" end |
#size ⇒ Object
53 |
# File 'lib/heedkit/changelog.rb', line 53 def size = entries.size |