Auto parse options from file .github_changelog_generator

This commit is contained in:
Dlani Mendes 2015-09-14 01:02:52 -03:00 committed by Petr Korolev
parent 1c578fec91
commit 0862e54f42
4 changed files with 33 additions and 1 deletions

1
.gitignore vendored
View File

@ -0,0 +1 @@
*.swp

View File

@ -7,6 +7,7 @@ require "benchmark"
require_relative "github_changelog_generator/helper"
require_relative "github_changelog_generator/parser"
require_relative "github_changelog_generator/parser_file"
require_relative "github_changelog_generator/generator/generator"
require_relative "github_changelog_generator/version"
require_relative "github_changelog_generator/reader"

View File

@ -10,9 +10,11 @@ module GitHubChangelogGenerator
options = get_default_options
parser = setup_parser(options)
parser.parse!
parser_file = ParseFile.new options
parser_file.parse!
if options[:user].nil? || options[:project].nil?
detect_user_and_project(options, ARGV[0], ARGV[1])
end

View File

@ -0,0 +1,28 @@
module GitHubChangelogGenerator
class ParseFile
def initialize(options)
@options = options
end
def file
File.expand_path(".github_changelog_generator")
end
def has_file?
File.exists?(file)
end
def file_open
File.open(file)
end
def parse!
return false unless has_file?
file_open.each do |line|
key, value = line.split("=")
key_sym = key.sub('-', '_').to_sym
@options[key_sym] = value.gsub(/[\n\r]+/, '')
end
end
end
end