From e82a75611c592036e373d0add5624bae59cbb4ca Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Sat, 4 Apr 2015 02:30:02 +0300 Subject: [PATCH] refactoring --- .rubocop_todo.yml | 24 +++++++------- lib/github_changelog_generator/parser.rb | 40 +++++++++++++----------- 2 files changed, 34 insertions(+), 30 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index c26d4e4..9bd544a 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,35 +1,35 @@ # This configuration was generated by `rubocop --auto-gen-config` -# on 2015-03-27 03:03:45 +0200 using RuboCop version 0.29.1. +# on 2015-04-04 02:29:34 +0300 using RuboCop version 0.29.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 20 +# Offense count: 21 Metrics/AbcSize: - Max: 114 + Max: 71 -# Offense count: 1 +# Offense count: 2 Metrics/BlockNesting: Max: 4 # Offense count: 2 # Configuration parameters: CountComments. Metrics/ClassLength: - Max: 471 + Max: 457 # Offense count: 6 Metrics/CyclomaticComplexity: - Max: 18 + Max: 15 -# Offense count: 27 +# Offense count: 28 # Configuration parameters: CountComments. Metrics/MethodLength: - Max: 147 + Max: 118 -# Offense count: 6 +# Offense count: 5 Metrics/PerceivedComplexity: - Max: 20 + Max: 18 # Offense count: 3 Style/AccessorMethodName: @@ -41,7 +41,7 @@ Style/AccessorMethodName: Style/AndOr: Enabled: false -# Offense count: 29 +# Offense count: 27 # Cop supports --auto-correct. Style/Blocks: Enabled: false @@ -51,7 +51,7 @@ Style/Blocks: Style/CaseIndentation: Enabled: false -# Offense count: 5 +# Offense count: 4 Style/Documentation: Enabled: false diff --git a/lib/github_changelog_generator/parser.rb b/lib/github_changelog_generator/parser.rb index a49b4d4..8fce304 100644 --- a/lib/github_changelog_generator/parser.rb +++ b/lib/github_changelog_generator/parser.rb @@ -113,6 +113,28 @@ module GitHubChangelogGenerator parser.parse! + detect_user_and_project(options) + + if !options[:user] || !options[:project] + puts parser.banner + exit + end + + if ARGV[1] + options[:tag1] = ARGV[0] + options[:tag2] = ARGV[1] + end + + if options[:verbose] + puts "Performing task with options:" + pp options + puts "" + end + + options + end + + def self.detect_user_and_project(options) if ARGV[0] && !ARGV[1] github_site = options[:github_site] ? options[:github_site] : "github.com" # this match should parse strings such "https://github.com/skywinder/Github-Changelog-Generator" or "skywinder/Github-Changelog-Generator" to user and name @@ -159,24 +181,6 @@ module GitHubChangelogGenerator end end end - - if !options[:user] || !options[:project] - puts parser.banner - exit - end - - if ARGV[1] - options[:tag1] = ARGV[0] - options[:tag2] = ARGV[1] - end - - if options[:verbose] - puts "Performing task with options:" - pp options - puts "" - end - - options end end end