Auto parse options from file .github_changelog_generator
This commit is contained in:
parent
ff4e5612af
commit
fbd8207ff4
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -0,0 +1 @@
|
|||
*.swp
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
28
lib/github_changelog_generator/parser_file.rb
Normal file
28
lib/github_changelog_generator/parser_file.rb
Normal 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
|
Loading…
Reference in New Issue
Block a user