class Releaselog::Change
Constants
- FEAT
- FIX
- GUI
- REFACTOR
- TOKEN_FEAT
- TOKEN_FIX
- TOKEN_GUI
- TOKEN_REFACTOR
Public Class Methods
new(type, note)
click to toggle source
# File lib/git-releaselog/change.rb, line 15 def initialize(type, note) @type = type @note = note.strip end
parse(line, scope = nil)
click to toggle source
Parse a single line as a ‘Change` entry If the line is formatte correctly as a change entry, a corresponding `Change` object will be created and returned, otherwise, nil will be returned.
The additional scope can be used to skip changes of another scope. Changes without scope will always be included.
# File lib/git-releaselog/change.rb, line 33 def self.parse(line, scope = nil) if line.start_with? Change::TOKEN_FEAT self.new(Change::FEAT, line.split(Change::TOKEN_FEAT).last).check_scope(scope) elsif line.start_with? Change::TOKEN_FIX self.new(Change::FIX, line.split(Change::TOKEN_FIX).last).check_scope(scope) elsif line.start_with? Change::TOKEN_GUI self.new(Change::GUI, line.split(Change::TOKEN_GUI).last).check_scope(scope) elsif line.start_with? Change::TOKEN_REFACTOR self.new(Change::REFACTOR, line.split(Change::TOKEN_REFACTOR).last).check_scope(scope) else nil end end
Public Instance Methods
check_scope(scope = nil)
click to toggle source
Checks the scope of the ‘Change` and the change out if the scope does not match.
# File lib/git-releaselog/change.rb, line 48 def check_scope(scope = nil) # If no scope is requested or the change has no scope include this change unchanged return self unless scope change_scope = /^\s*\[\w+\]/.match(@note) return self unless change_scope # change_scope is a string of format `[scope]`, need to strip the `[]` to compare the scope if change_scope[0][1..-2] == scope # Change has the scope that is requested, strip the whole scope scope from the change note @note = change_scope.post_match.strip return self else # Change has a different scope than requested return nil end end
note()
click to toggle source
# File lib/git-releaselog/change.rb, line 24 def note @note end
type()
click to toggle source
# File lib/git-releaselog/change.rb, line 20 def type @type end