Skip to content

Commit 6b64d4e

Browse files
committed
Docs
1 parent 0b32484 commit 6b64d4e

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

lib/github_changelog_generator/parser_file.rb

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,28 @@
33
module GitHubChangelogGenerator
44
ParserError = Class.new(StandardError)
55

6+
# ParserFile is a configuration file reader which sets options in the
7+
# given Hash.
8+
#
9+
# In your project's root, you can put a file named
10+
# <tt>.github_changelog_generator</tt> to override defaults:
11+
#
12+
# Example:
13+
# header_label=# My Super Changelog
14+
# future-release=5.0.0
15+
# since-tag=1.0.0
16+
#
17+
# The configuration format is <tt>some-key=value</tt> or <tt>some_key=value</tt>.
18+
#
619
class ParserFile
7-
FILENAME = ".github_changelog_generator"
8-
9-
# @param options [Hash]
10-
# @param file [nil,IO]
20+
# @param options [Hash] options to be configured from file contents
21+
# @param file [nil,IO] configuration file handle, defaults to opening `.github_changelog_generator`
1122
def initialize(options, file = read_default_file)
1223
@options = options
1324
@file = file
1425
end
1526

16-
def read_default_file
17-
path = Pathname(File.expand_path(FILENAME))
18-
File.open(path) if path.exist?
19-
end
20-
21-
# Set @options using configuration file lines.
27+
# Sets options using configuration file content
2228
def parse!
2329
return unless @file
2430
@file.each_with_index { |line, i| parse_line!(line, i + 1) }
@@ -27,6 +33,13 @@ def parse!
2733

2834
private
2935

36+
FILENAME = ".github_changelog_generator"
37+
38+
def read_default_file
39+
path = Pathname(File.expand_path(FILENAME))
40+
File.open(path) if path.exist?
41+
end
42+
3043
def parse_line!(line, line_number)
3144
option_name, value = extract_pair(line)
3245
@options[option_key_for(option_name)] = convert_value(value, option_name)

0 commit comments

Comments
 (0)