From 441acca610c488423a2d288eb43e435cbf2746e2 Mon Sep 17 00:00:00 2001 From: Gregory Eremin Date: Thu, 6 Jun 2013 23:12:04 +0400 Subject: [PATCH] Ignore tasks by regexps --- .../app/controllers/burden_web/tasks_controller.rb | 5 +++++ burden_web/spec/dummy/config/initializers/burden.rb | 10 +++++++++- lib/burden/config.rb | 2 +- lib/burden/wrapper.rb | 2 +- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/burden_web/app/controllers/burden_web/tasks_controller.rb b/burden_web/app/controllers/burden_web/tasks_controller.rb index 9474144..61be57b 100644 --- a/burden_web/app/controllers/burden_web/tasks_controller.rb +++ b/burden_web/app/controllers/burden_web/tasks_controller.rb @@ -3,12 +3,17 @@ module BurdenWeb def index @tasks = Burden::Storage.run.summary (tasks.map(&:name) - @tasks.map(&:name)).each do |nr_task| # Never runned tasks + next if ignore? nr_task @tasks << Burden::Storage.run.new( name: nr_task ) end end + def ignore? name + Burden.config.ignored_tasks.collect{ |r| (name =~ r) ? 1 : 0 }.map(&:to_i).inject(:+) != 0 + end + def run Rails.application.load_tasks Rake::Task[params[:id]].invoke diff --git a/burden_web/spec/dummy/config/initializers/burden.rb b/burden_web/spec/dummy/config/initializers/burden.rb index ef5472f..acf61a6 100644 --- a/burden_web/spec/dummy/config/initializers/burden.rb +++ b/burden_web/spec/dummy/config/initializers/burden.rb @@ -1,4 +1,12 @@ Burden.configure do |c| c.storage = :active_record - c.ignored_tasks = [:environment] + c.ignored_tasks = [ + /environment/, + /^db:/, + /^assets:/, + /^doc:/, + /^tmp:/, + /^time:/, + /^rails:/ + ] end diff --git a/lib/burden/config.rb b/lib/burden/config.rb index f6d9c39..ebeed59 100644 --- a/lib/burden/config.rb +++ b/lib/burden/config.rb @@ -5,7 +5,7 @@ module Burden def initialize @storage = :active_record - @ignored_tasks = [:environment] + @ignored_tasks = [/environment/] end module Helper diff --git a/lib/burden/wrapper.rb b/lib/burden/wrapper.rb index d83c592..0528c16 100644 --- a/lib/burden/wrapper.rb +++ b/lib/burden/wrapper.rb @@ -42,7 +42,7 @@ module Burden end def ignored? - Burden.config.ignored_tasks.include?(name.to_sym) + Burden.config.ignored_tasks.collect{ |r| (name =~ r) ? 1 : 0 }.map(&:to_i).inject(:+) != 0 end def save_statistics