From 88c358e193333c9427365b7da7854cf9f9f4cd15 Mon Sep 17 00:00:00 2001 From: adrien Date: Thu, 7 Nov 2013 16:27:42 +0100 Subject: [PATCH 1/4] add ignore option --- lib/metric_fu/metrics/churn/churn.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/metric_fu/metrics/churn/churn.rb b/lib/metric_fu/metrics/churn/churn.rb index 55b473c51..0882716a9 100644 --- a/lib/metric_fu/metrics/churn/churn.rb +++ b/lib/metric_fu/metrics/churn/churn.rb @@ -59,7 +59,8 @@ def has_option?(churn_option) def churn_options { :minimum_churn_count => '--minimum_churn_count', - :start_date => '--start_date' + :start_date => '--start_date', + :ignore_files => '--ignore_files' } end From 97d06a346db649e7ab86dc921dbfce1c39af4bba Mon Sep 17 00:00:00 2001 From: adrien Date: Thu, 7 Nov 2013 16:34:01 +0100 Subject: [PATCH 2/4] add test churn ignore flag --- lib/metric_fu/metrics/churn/churn.rb | 2 +- spec/metric_fu/metrics/churn/churn_spec.rb | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/metric_fu/metrics/churn/churn.rb b/lib/metric_fu/metrics/churn/churn.rb index 0882716a9..8a22b16fc 100644 --- a/lib/metric_fu/metrics/churn/churn.rb +++ b/lib/metric_fu/metrics/churn/churn.rb @@ -47,7 +47,7 @@ def build_churn_options opts = ["--yaml"] churn_options.each do |churn_option, command_flag| if has_option?(churn_option) - opts << "#{command_flag}=#{options[churn_option]}" + opts << %(#{command_flag}="#{options[churn_option]}") end end opts.join(" ") diff --git a/spec/metric_fu/metrics/churn/churn_spec.rb b/spec/metric_fu/metrics/churn/churn_spec.rb index 608d6c368..b54e6cdcb 100644 --- a/spec/metric_fu/metrics/churn/churn_spec.rb +++ b/spec/metric_fu/metrics/churn/churn_spec.rb @@ -22,7 +22,12 @@ it "initializes with given minimum_churn_count option" do churn = MetricFu::ChurnGenerator.new( { :minimum_churn_count => 5 }) - churn.send(:build_churn_options).should == "--yaml --minimum_churn_count=5" + churn.send(:build_churn_options).should == '--yaml --minimum_churn_count="5"' + end + + it "initializes with given ignore option" do + churn = MetricFu::ChurnGenerator.new({:ignore_files => "Gemfile, Gemfile.lock" }) + churn.send(:build_churn_options).should == '--yaml --ignore_files="Gemfile, Gemfile.lock"' end end From 5e431f2b675efc9d72d314e58cf6e84588b16676 Mon Sep 17 00:00:00 2001 From: adrien Date: Thu, 7 Nov 2013 18:12:23 +0100 Subject: [PATCH 3/4] fix churn option parsing --- lib/metric_fu/metrics/churn/churn.rb | 2 +- spec/metric_fu/metrics/churn/churn_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/metric_fu/metrics/churn/churn.rb b/lib/metric_fu/metrics/churn/churn.rb index 8a22b16fc..f0fa2ad13 100644 --- a/lib/metric_fu/metrics/churn/churn.rb +++ b/lib/metric_fu/metrics/churn/churn.rb @@ -47,7 +47,7 @@ def build_churn_options opts = ["--yaml"] churn_options.each do |churn_option, command_flag| if has_option?(churn_option) - opts << %(#{command_flag}="#{options[churn_option]}") + opts << %(#{command_flag}=#{options[churn_option]}) end end opts.join(" ") diff --git a/spec/metric_fu/metrics/churn/churn_spec.rb b/spec/metric_fu/metrics/churn/churn_spec.rb index b54e6cdcb..d7235a24d 100644 --- a/spec/metric_fu/metrics/churn/churn_spec.rb +++ b/spec/metric_fu/metrics/churn/churn_spec.rb @@ -26,7 +26,7 @@ end it "initializes with given ignore option" do - churn = MetricFu::ChurnGenerator.new({:ignore_files => "Gemfile, Gemfile.lock" }) + churn = MetricFu::ChurnGenerator.new({:ignore_files => %q("Gemfile, Gemfile.lock") }) churn.send(:build_churn_options).should == '--yaml --ignore_files="Gemfile, Gemfile.lock"' end end From fde02822d41d2dea5082329f965fc7c74f816212 Mon Sep 17 00:00:00 2001 From: adrien Date: Thu, 7 Nov 2013 18:31:39 +0100 Subject: [PATCH 4/4] add default churn option --- lib/metric_fu/metrics/churn/churn.rb | 3 ++- lib/metric_fu/metrics/churn/init.rb | 2 +- spec/metric_fu/metrics/churn/churn_spec.rb | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/metric_fu/metrics/churn/churn.rb b/lib/metric_fu/metrics/churn/churn.rb index f0fa2ad13..657f7cb72 100644 --- a/lib/metric_fu/metrics/churn/churn.rb +++ b/lib/metric_fu/metrics/churn/churn.rb @@ -47,7 +47,7 @@ def build_churn_options opts = ["--yaml"] churn_options.each do |churn_option, command_flag| if has_option?(churn_option) - opts << %(#{command_flag}=#{options[churn_option]}) + opts << "#{command_flag}=#{options[churn_option]}" end end opts.join(" ") @@ -56,6 +56,7 @@ def build_churn_options def has_option?(churn_option) options.include?(churn_option) end + def churn_options { :minimum_churn_count => '--minimum_churn_count', diff --git a/lib/metric_fu/metrics/churn/init.rb b/lib/metric_fu/metrics/churn/init.rb index eeb93cf6c..76c64a758 100644 --- a/lib/metric_fu/metrics/churn/init.rb +++ b/lib/metric_fu/metrics/churn/init.rb @@ -6,7 +6,7 @@ def name end def default_run_options - { :start_date => %q("1 year ago"), :minimum_churn_count => 10} + { :start_date => %q("1 year ago"), :minimum_churn_count => 10, :ignore_files => "" } end def has_graph? diff --git a/spec/metric_fu/metrics/churn/churn_spec.rb b/spec/metric_fu/metrics/churn/churn_spec.rb index d7235a24d..f70c5a371 100644 --- a/spec/metric_fu/metrics/churn/churn_spec.rb +++ b/spec/metric_fu/metrics/churn/churn_spec.rb @@ -22,7 +22,7 @@ it "initializes with given minimum_churn_count option" do churn = MetricFu::ChurnGenerator.new( { :minimum_churn_count => 5 }) - churn.send(:build_churn_options).should == '--yaml --minimum_churn_count="5"' + churn.send(:build_churn_options).should == '--yaml --minimum_churn_count=5' end it "initializes with given ignore option" do