Class: Chandler::Changelog
- Inherits:
-
Object
- Object
- Chandler::Changelog
- Defined in:
- lib/chandler/changelog.rb
Overview
Responsible for parsing a CHANGELOG into a hash of release notes keyed by version number. Release notes for a particular version or tag can be accessed using the ‘fetch` method.
Constant Summary collapse
- NoMatchingVersion =
Class.new(StandardError)
- HEADING_PATTERNS =
[ /^#[[:space:]]+.*\n/, # Markdown "atx" style /^##[[:space:]]+.*\n/, /^###[[:space:]]+.*\n/, /^=[[:space:]]+.*\n/, # Rdoc style /^==[[:space:]]+.*\n/, /^===[[:space:]]+.*\n/, /^\S.*\n=+\n/, # Markdown "Setext" style /^\S.*\n-+\n/, /^[vr]?[0-9]+\S+[[:space:]]*\n/ # Lines with version string ].freeze
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #basename ⇒ Object
-
#fetch(tag) ⇒ Object
Fetch release notes for the given tag or version number.
-
#initialize(path:) ⇒ Changelog
constructor
A new instance of Changelog.
Constructor Details
#initialize(path:) ⇒ Changelog
Returns a new instance of Changelog.
26 27 28 |
# File 'lib/chandler/changelog.rb', line 26 def initialize(path:) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
24 25 26 |
# File 'lib/chandler/changelog.rb', line 24 def path @path end |
Instance Method Details
#basename ⇒ Object
43 44 45 |
# File 'lib/chandler/changelog.rb', line 43 def basename File.basename(path.to_s) end |
#fetch(tag) ⇒ Object
Fetch release notes for the given tag or version number.
E.g. fetch(“v1.0.1”) # => “nRelease notes for 1.0.1.n” fetch(“1.0.1”) # => “nRelease notes for 1.0.1.n” fetch(“blergh”) # => Chandler::NoMatchingVersion
37 38 39 40 41 |
# File 'lib/chandler/changelog.rb', line 37 def fetch(tag) versions.fetch(tag.version_number) do raise NoMatchingVersion, "Couldn’t find #{tag} in #{path}" end end |