Resolved #214. Added tests for this case. small refacroting
This commit is contained in:
parent
957fa0d3a3
commit
783d8f306e
|
@ -6,3 +6,11 @@ Metrics/LineLength:
|
||||||
#http://viget.com/extend/just-use-double-quoted-ruby-strings
|
#http://viget.com/extend/just-use-double-quoted-ruby-strings
|
||||||
Style/StringLiterals:
|
Style/StringLiterals:
|
||||||
EnforcedStyle: double_quotes
|
EnforcedStyle: double_quotes
|
||||||
|
|
||||||
|
# Configuration parameters: CountComments.
|
||||||
|
Metrics/ClassLength:
|
||||||
|
Enabled: false
|
||||||
|
|
||||||
|
# Configuration parameters: CountComments.
|
||||||
|
Metrics/MethodLength:
|
||||||
|
Enabled: false
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# This configuration was generated by `rubocop --auto-gen-config`
|
# This configuration was generated by `rubocop --auto-gen-config`
|
||||||
# on 2015-05-25 17:16:04 +0300 using RuboCop version 0.31.0.
|
# on 2015-05-26 16:00:55 +0300 using RuboCop version 0.31.0.
|
||||||
# The point is for the user to remove these configuration records
|
# The point is for the user to remove these configuration records
|
||||||
# one by one as the offenses are removed from the code base.
|
# one by one as the offenses are removed from the code base.
|
||||||
# Note that changes in the inspected code, or installation of new
|
# Note that changes in the inspected code, or installation of new
|
||||||
|
@ -7,22 +7,12 @@
|
||||||
|
|
||||||
# Offense count: 14
|
# Offense count: 14
|
||||||
Metrics/AbcSize:
|
Metrics/AbcSize:
|
||||||
Max: 57
|
Max: 59
|
||||||
|
|
||||||
# Offense count: 4
|
|
||||||
# Configuration parameters: CountComments.
|
|
||||||
Metrics/ClassLength:
|
|
||||||
Max: 182
|
|
||||||
|
|
||||||
# Offense count: 1
|
# Offense count: 1
|
||||||
Metrics/CyclomaticComplexity:
|
Metrics/CyclomaticComplexity:
|
||||||
Max: 7
|
Max: 7
|
||||||
|
|
||||||
# Offense count: 22
|
|
||||||
# Configuration parameters: CountComments.
|
|
||||||
Metrics/MethodLength:
|
|
||||||
Max: 84
|
|
||||||
|
|
||||||
# Offense count: 1
|
# Offense count: 1
|
||||||
Metrics/PerceivedComplexity:
|
Metrics/PerceivedComplexity:
|
||||||
Max: 8
|
Max: 8
|
||||||
|
|
|
@ -37,7 +37,11 @@ module GitHubChangelogGenerator
|
||||||
#
|
#
|
||||||
# @return [Array]
|
# @return [Array]
|
||||||
def get_filtered_tags(all_tags)
|
def get_filtered_tags(all_tags)
|
||||||
all_tags = all_tags
|
filtered_tags = filter_between_tags(all_tags)
|
||||||
|
filter_excluded_tags(filtered_tags)
|
||||||
|
end
|
||||||
|
|
||||||
|
def filter_between_tags(all_tags)
|
||||||
filtered_tags = all_tags
|
filtered_tags = all_tags
|
||||||
if @options[:between_tags]
|
if @options[:between_tags]
|
||||||
@options[:between_tags].each do |tag|
|
@options[:between_tags].each do |tag|
|
||||||
|
@ -49,5 +53,18 @@ module GitHubChangelogGenerator
|
||||||
end
|
end
|
||||||
filtered_tags
|
filtered_tags
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def filter_excluded_tags(all_tags)
|
||||||
|
filtered_tags = all_tags
|
||||||
|
if @options[:exclude_tags]
|
||||||
|
@options[:exclude_tags].each do |tag|
|
||||||
|
unless all_tags.include? tag
|
||||||
|
puts "Warning: can't find tag #{tag}, specified with --between-tags option.".yellow
|
||||||
|
end
|
||||||
|
end
|
||||||
|
filtered_tags = all_tags.reject { |tag| @options[:exclude_tags].include? tag }
|
||||||
|
end
|
||||||
|
filtered_tags
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -84,9 +84,12 @@ module GitHubChangelogGenerator
|
||||||
opts.on("--exclude-labels x,y,z", Array, 'Issues with the specified labels will be always excluded from changelog. Default is \'duplicate,question,invalid,wontfix\'') do |list|
|
opts.on("--exclude-labels x,y,z", Array, 'Issues with the specified labels will be always excluded from changelog. Default is \'duplicate,question,invalid,wontfix\'') do |list|
|
||||||
options[:exclude_labels] = list
|
options[:exclude_labels] = list
|
||||||
end
|
end
|
||||||
opts.on("--between-tags x,y,z", Array, "Change log will be filed only between specified tags") do |list|
|
opts.on("--between-tags x,y,z", Array, "Change log will be filled only between specified tags") do |list|
|
||||||
options[:between_tags] = list
|
options[:between_tags] = list
|
||||||
end
|
end
|
||||||
|
opts.on("--exclude-tags x,y,z", Array, "Change log will be exclude specified tags") do |list|
|
||||||
|
options[:exclude_tags] = list
|
||||||
|
end
|
||||||
opts.on("--max-issues [NUMBER]", Integer, "Max number of issues to fetch from GitHub. Default is unlimited") do |max|
|
opts.on("--max-issues [NUMBER]", Integer, "Max number of issues to fetch from GitHub. Default is unlimited") do |max|
|
||||||
options[:max_issues] = max
|
options[:max_issues] = max
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
describe GitHubChangelogGenerator::Generator do
|
describe GitHubChangelogGenerator::Generator do
|
||||||
describe "#get_filtered_tags" do
|
describe "#filter_between_tags" do
|
||||||
context "when between_tags nil" do
|
context "when between_tags nil" do
|
||||||
before do
|
before do
|
||||||
@generator = GitHubChangelogGenerator::Generator.new(between_tags: nil)
|
@generator = GitHubChangelogGenerator::Generator.new(between_tags: nil)
|
||||||
|
@ -45,4 +45,25 @@ describe GitHubChangelogGenerator::Generator do
|
||||||
it { is_expected.to match_array(%w(1)) }
|
it { is_expected.to match_array(%w(1)) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#get_filtered_tags" do
|
||||||
|
subject { generator.get_filtered_tags(%w(1 2 3 4 5)) }
|
||||||
|
# before { generator.get_filtered_tags(%w(1 2 3 4 5)) }
|
||||||
|
|
||||||
|
context "with excluded and between tags" do
|
||||||
|
let(:generator) { GitHubChangelogGenerator::Generator.new(between_tags: %w(1 2 3), exclude_tags: %w(2)) }
|
||||||
|
it { is_expected.to be_a Array }
|
||||||
|
it { is_expected.to match_array(%w(1 3)) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "#filter_excluded_tags" do
|
||||||
|
subject { generator.filter_excluded_tags(%w(1 2 3)) }
|
||||||
|
|
||||||
|
context "with valid excluded tags" do
|
||||||
|
let(:generator) { GitHubChangelogGenerator::Generator.new(exclude_tags: %w(3)) }
|
||||||
|
it { is_expected.to be_a Array }
|
||||||
|
it { is_expected.to match_array(%w(1 2)) }
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user