Class: NextcloudReleaseAgent::ChangelogFile
- Inherits:
-
Object
- Object
- NextcloudReleaseAgent::ChangelogFile
- Defined in:
- lib/nextcloud_release_agent/cli.rb
Constant Summary collapse
- SECTION_ORDER =
["Added", "Changed", "Fixed"].freeze
Instance Method Summary collapse
- #add_entry(entry) ⇒ Object
- #data ⇒ Object
- #entries ⇒ Object
- #ignore_rules ⇒ Object
- #ignored?(commit) ⇒ Boolean
-
#initialize(path) ⇒ ChangelogFile
constructor
A new instance of ChangelogFile.
- #latest_entry ⇒ Object
- #normalize! ⇒ Object
- #path ⇒ Object
- #repository_link ⇒ Object
Constructor Details
#initialize(path) ⇒ ChangelogFile
Returns a new instance of ChangelogFile.
81 82 83 |
# File 'lib/nextcloud_release_agent/cli.rb', line 81 def initialize(path) @path = Pathname(path) end |
Instance Method Details
#add_entry(entry) ⇒ Object
125 126 127 128 |
# File 'lib/nextcloud_release_agent/cli.rb', line 125 def add_entry(entry) data["entries"] = [entry] + entries write! end |
#data ⇒ Object
89 90 91 |
# File 'lib/nextcloud_release_agent/cli.rb', line 89 def data @data ||= Psych.safe_load(@path.read, aliases: false, permitted_classes: [], symbolize_names: false) || {} end |
#entries ⇒ Object
97 98 99 |
# File 'lib/nextcloud_release_agent/cli.rb', line 97 def entries data.fetch("entries", []) end |
#ignore_rules ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/nextcloud_release_agent/cli.rb', line 105 def ignore_rules config = data.fetch("release_agent", {}) rules = config.fetch("ignore_commits", []) rules.map do |rule| { "author" => compile_regex(rule["author"]), "email" => compile_regex(rule["email"]), "message" => compile_regex(rule["message"]) } end end |
#ignored?(commit) ⇒ Boolean
117 118 119 120 121 122 123 |
# File 'lib/nextcloud_release_agent/cli.rb', line 117 def ignored?(commit) ignore_rules.any? do |rule| matches?(rule["author"], commit.) && matches?(rule["email"], commit.) && matches?(rule["message"], commit.) end end |
#latest_entry ⇒ Object
101 102 103 |
# File 'lib/nextcloud_release_agent/cli.rb', line 101 def latest_entry entries.first end |
#normalize! ⇒ Object
130 131 132 |
# File 'lib/nextcloud_release_agent/cli.rb', line 130 def normalize! write! end |
#path ⇒ Object
85 86 87 |
# File 'lib/nextcloud_release_agent/cli.rb', line 85 def path @path end |
#repository_link ⇒ Object
93 94 95 |
# File 'lib/nextcloud_release_agent/cli.rb', line 93 def repository_link data["repository_link"] end |