Class: Keepachangelog::Parser
- Inherits:
-
Object
- Object
- Keepachangelog::Parser
- Defined in:
- lib/keepachangelog/parser.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#parsed_content ⇒ Object
Returns the value of attribute parsed_content.
Instance Method Summary collapse
-
#initialize ⇒ Parser
constructor
A new instance of Parser.
-
#to_json ⇒ Object
Changelog in JSON format.
-
#to_md ⇒ Object
Changelog as Markdown.
-
#to_s ⇒ Object
Changelog as a Ruby string.
-
#to_yaml(path = nil) ⇒ Object
Changelog in YAML format.
Constructor Details
#initialize ⇒ Parser
Returns a new instance of Parser.
5 6 7 |
# File 'lib/keepachangelog/parser.rb', line 5 def initialize self.parsed_content = { 'versions' => {} } end |
Instance Attribute Details
#parsed_content ⇒ Object
Returns the value of attribute parsed_content.
3 4 5 |
# File 'lib/keepachangelog/parser.rb', line 3 def parsed_content @parsed_content end |
Instance Method Details
#to_json ⇒ Object
Changelog in JSON format
Example: “‘json {“1.0.0”: { “changes”: { “New”: [“Feature A”] } } } “`
15 16 17 |
# File 'lib/keepachangelog/parser.rb', line 15 def to_json parsed_content.to_json end |
#to_md ⇒ Object
Changelog as Markdown
47 48 49 50 51 52 53 54 55 |
# File 'lib/keepachangelog/parser.rb', line 47 def to_md require 'keepachangelog/printer/markdown' p = MarkdownPrinter.new(parsed_content['versions'], title: parsed_content['title'], intro: parsed_content['intro'], section_order: parsed_content['section_order'], url: parsed_content['url']) p.to_s end |
#to_s ⇒ Object
Changelog as a Ruby string
Example: “‘ruby A”]} “`
42 43 44 |
# File 'lib/keepachangelog/parser.rb', line 42 def to_s parsed_content.to_s end |
#to_yaml(path = nil) ⇒ Object
Changelog in YAML format
Example: “‘yaml
0.1.0:
changes:
New:
- Feature A
“‘
29 30 31 32 33 34 |
# File 'lib/keepachangelog/parser.rb', line 29 def to_yaml(path = nil) path ||= 'changelog' require 'keepachangelog/printer/yaml' p = YamlPrinter.new(parsed_content) p.write(path) end |