rename methods to match of it's actions

This commit is contained in:
Petr Korolev 2016-07-21 10:51:34 +03:00
parent 85f8ccae03
commit 6fc06a2d3d
2 changed files with 8 additions and 5 deletions

View File

@ -14,7 +14,7 @@ module GitHubChangelogGenerator
parser = setup_parser(options)
parser.parse!
user_and_project_from_git(options)
fetch_user_and_project(options)
abort(parser.banner) unless options[:user] && options[:project]
@ -208,14 +208,17 @@ module GitHubChangelogGenerator
end
# If `:user` or `:project` not set in options, try setting them
def self.user_and_project_from_git(options)
# Valid unnamed parameters:
# 1) in 1 param: repo_name/project
# 2) in 2 params: repo name project
def self.fetch_user_and_project(options)
if options[:user].nil? || options[:project].nil?
detect_user_and_project(options, ARGV[0], ARGV[1])
user_and_project_from_git(options, ARGV[0], ARGV[1])
end
end
# Sets `:user` and `:project` in `options` from CLI arguments or `git remote`
def self.detect_user_and_project(options, arg0 = nil, arg1 = nil)
def self.user_and_project_from_git(options, arg0 = nil, arg1 = nil)
options[:user], options[:project] = user_project_from_option(arg0, arg1, options[:github_site])
return if options[:user] && options[:project]

View File

@ -46,7 +46,7 @@ module GitHubChangelogGenerator
# mimick parse_options
options = Parser.default_options
Parser.user_and_project_from_git(options)
Parser.fetch_user_and_project(options)
OPTIONS.each do |o|
v = instance_variable_get("@#{o}")