diff --git a/lib/github_changelog_generator/parser_file.rb b/lib/github_changelog_generator/parser_file.rb index 38cc54d..5100e18 100644 --- a/lib/github_changelog_generator/parser_file.rb +++ b/lib/github_changelog_generator/parser_file.rb @@ -1,21 +1,24 @@ +require 'pathname' + module GitHubChangelogGenerator ParserError = Class.new(StandardError) class ParserFile + FILENAME = ".github_changelog_generator" + def initialize(options) @options = options end + # Destructively change @options using data in configured options file. def parse! - return unless File.exist?(file) - - File.readlines(file).each { |line| parse_line!(line) } + file.each_line { |line| parse_line!(line) } if file.exist? end private def file - @file ||= File.expand_path(@options[:params_file] || ".github_changelog_generator") + @file ||= Pathname(File.expand_path(@options[:params_file] || FILENAME)) end def parse_line!(line)