Class: GitHubChangelogGenerator::FileParserChooser

Inherits:
Object
  • Object
show all
Defined in:
lib/github_changelog_generator/file_parser_chooser.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ FileParserChooser

Returns a new instance of FileParserChooser.



7
8
9
10
# File 'lib/github_changelog_generator/file_parser_chooser.rb', line 7

def initialize(options)
  @options = options
  @config_file = Pathname.new(options[:config_file])
end

Instance Method Details

#parse!(_argv) ⇒ Object



12
13
14
15
16
# File 'lib/github_changelog_generator/file_parser_chooser.rb', line 12

def parse!(_argv)
  return nil unless (path = resolve_path)

  ParserFile.new(@options, File.open(path)).parse!
end

#resolve_pathObject



18
19
20
21
22
23
24
25
# File 'lib/github_changelog_generator/file_parser_chooser.rb', line 18

def resolve_path
  return @config_file if @config_file.exist?

  path = @config_file.expand_path
  return path if File.exist?(path)

  nil
end