Rubocop: less complex methods

- Changed one thing: failed return value on printing the banner when
    no user or project was found.
This commit is contained in:
Olle Jonsson 2015-10-21 23:42:33 +02:00
parent 2dda090e6b
commit d227464c33

View File

@ -9,20 +9,14 @@ module GitHubChangelogGenerator
def self.parse_options def self.parse_options
options = get_default_options options = get_default_options
parser_file = ParserFile.new options ParserFile.new(options).parse!
parser_file.parse!
parser = setup_parser(options) parser = setup_parser(options)
parser.parse! parser.parse!
if options[:user].nil? || options[:project].nil? user_and_project_from_git(options)
detect_user_and_project(options, ARGV[0], ARGV[1])
end
if !options[:user] || !options[:project] abort(parser.banner) unless options[:user] && options[:project]
puts parser.banner
exit
end
print_options(options) print_options(options)
@ -198,17 +192,23 @@ module GitHubChangelogGenerator
options options
end end
def self.user_and_project_from_git
if options[:user].nil? || options[:project].nil?
detect_user_and_project(options, ARGV[0], ARGV[1])
end
end
# Detects user and project from git # Detects user and project from git
def self.detect_user_and_project(options, arg0 = nil, arg1 = nil) def self.detect_user_and_project(options, arg0 = nil, arg1 = nil)
options[:user], options[:project] = user_project_from_option(arg0, arg1, options[:github_site]) options[:user], options[:project] = user_project_from_option(arg0, arg1, options[:github_site])
if !options[:user] || !options[:project] return if options[:user] && options[:project]
if ENV["RUBYLIB"] =~ /ruby-debug-ide/
options[:user] = "skywinder" if ENV["RUBYLIB"] =~ /ruby-debug-ide/
options[:project] = "changelog_test" options[:user] = "skywinder"
else options[:project] = "changelog_test"
remote = `git config --get remote.#{options[:git_remote]}.url` else
options[:user], options[:project] = user_project_from_remote(remote) remote = `git config --get remote.#{options[:git_remote]}.url`
end options[:user], options[:project] = user_project_from_remote(remote)
end end
end end