Merge pull request #334 from olleolleolle/feature/refactor-parser-file-to-pathname

[Refactor] ParserFile class use Pathname
This commit is contained in:
Petr Korolev 2016-02-24 16:16:17 +02:00
commit 60517bffe9

View File

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