1
0
Fork 0

Ignore tasks by regexps

This commit is contained in:
Gregory Eremin 2013-06-06 23:12:04 +04:00
parent 04a9f70b26
commit 441acca610
4 changed files with 16 additions and 3 deletions

View File

@ -3,12 +3,17 @@ module BurdenWeb
def index def index
@tasks = Burden::Storage.run.summary @tasks = Burden::Storage.run.summary
(tasks.map(&:name) - @tasks.map(&:name)).each do |nr_task| # Never runned tasks (tasks.map(&:name) - @tasks.map(&:name)).each do |nr_task| # Never runned tasks
next if ignore? nr_task
@tasks << Burden::Storage.run.new( @tasks << Burden::Storage.run.new(
name: nr_task name: nr_task
) )
end end
end end
def ignore? name
Burden.config.ignored_tasks.collect{ |r| (name =~ r) ? 1 : 0 }.map(&:to_i).inject(:+) != 0
end
def run def run
Rails.application.load_tasks Rails.application.load_tasks
Rake::Task[params[:id]].invoke Rake::Task[params[:id]].invoke

View File

@ -1,4 +1,12 @@
Burden.configure do |c| Burden.configure do |c|
c.storage = :active_record c.storage = :active_record
c.ignored_tasks = [:environment] c.ignored_tasks = [
/environment/,
/^db:/,
/^assets:/,
/^doc:/,
/^tmp:/,
/^time:/,
/^rails:/
]
end end

View File

@ -5,7 +5,7 @@ module Burden
def initialize def initialize
@storage = :active_record @storage = :active_record
@ignored_tasks = [:environment] @ignored_tasks = [/environment/]
end end
module Helper module Helper

View File

@ -42,7 +42,7 @@ module Burden
end end
def ignored? 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 end
def save_statistics def save_statistics