Class: Danger::Changelog::ChangelogFile
- Inherits:
-
Object
- Object
- Danger::Changelog::ChangelogFile
- Defined in:
- lib/changelog/changelog_file.rb
Overview
A CHANGELOG.md file reader.
Instance Attribute Summary collapse
-
#bad_lines ⇒ Object
readonly
Returns the value of attribute bad_lines.
-
#exists ⇒ Object
readonly
Returns the value of attribute exists.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#global_failures ⇒ Object
readonly
Returns the value of attribute global_failures.
Instance Method Summary collapse
- #add_bad_line(line) ⇒ Object
- #add_global_failure(message) ⇒ Object
- #bad? ⇒ Boolean
-
#bad_lines? ⇒ Boolean
Any bad_lines?.
- #exists? ⇒ Boolean
- #global_failures? ⇒ Boolean
- #good? ⇒ Boolean
-
#initialize(filename = 'CHANGELOG.md', parser: Parsers.lookup(Parsers.default_format)) ⇒ ChangelogFile
constructor
A new instance of ChangelogFile.
- #parse ⇒ Object
Constructor Details
#initialize(filename = 'CHANGELOG.md', parser: Parsers.lookup(Parsers.default_format)) ⇒ ChangelogFile
Returns a new instance of ChangelogFile.
7 8 9 10 11 12 13 14 15 |
# File 'lib/changelog/changelog_file.rb', line 7 def initialize(filename = 'CHANGELOG.md', parser: Parsers.lookup(Parsers.default_format)) @filename = filename @exists = File.exist?(filename) @bad_lines = [] @global_failures = [] @parser = parser parser.add_listener(self) end |
Instance Attribute Details
#bad_lines ⇒ Object (readonly)
Returns the value of attribute bad_lines.
5 6 7 |
# File 'lib/changelog/changelog_file.rb', line 5 def bad_lines @bad_lines end |
#exists ⇒ Object (readonly)
Returns the value of attribute exists.
5 6 7 |
# File 'lib/changelog/changelog_file.rb', line 5 def exists @exists end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
5 6 7 |
# File 'lib/changelog/changelog_file.rb', line 5 def filename @filename end |
#global_failures ⇒ Object (readonly)
Returns the value of attribute global_failures.
5 6 7 |
# File 'lib/changelog/changelog_file.rb', line 5 def global_failures @global_failures end |
Instance Method Details
#add_bad_line(line) ⇒ Object
17 18 19 |
# File 'lib/changelog/changelog_file.rb', line 17 def add_bad_line(line) @bad_lines << line end |
#add_global_failure(message) ⇒ Object
21 22 23 |
# File 'lib/changelog/changelog_file.rb', line 21 def add_global_failure() @global_failures << end |
#bad? ⇒ Boolean
44 45 46 |
# File 'lib/changelog/changelog_file.rb', line 44 def bad? bad_lines? || global_failures? end |
#bad_lines? ⇒ Boolean
Any bad_lines?
32 33 34 |
# File 'lib/changelog/changelog_file.rb', line 32 def bad_lines? bad_lines.any? end |
#exists? ⇒ Boolean
40 41 42 |
# File 'lib/changelog/changelog_file.rb', line 40 def exists? !!@exists end |
#global_failures? ⇒ Boolean
36 37 38 |
# File 'lib/changelog/changelog_file.rb', line 36 def global_failures? global_failures.any? end |
#good? ⇒ Boolean
48 49 50 |
# File 'lib/changelog/changelog_file.rb', line 48 def good? !bad? end |
#parse ⇒ Object
25 26 27 28 29 |
# File 'lib/changelog/changelog_file.rb', line 25 def parse return unless exists? @parser.parse(filename) end |