class RubyCritic::RakeTask
end
task.paths = FileList[‘lib/*/.rb’, ‘spec/*/.rb’]
RubyCritic::RakeTask.new do |task|
require ‘rubycritic/rake_task’
Example:
rake rubycritic
This will create a task that can be run with:
A rake task that runs RubyCritic on a set of source files.
def define_task
def define_task desc 'Run RubyCritic' task(name) { run_task } end
def initialize(name = :rubycritic)
def initialize(name = :rubycritic) @name = name @paths = FileList['.'] @options = '' @verbose = false yield self if block_given? define_task end
def options_as_arguments
def options_as_arguments options.split(/\s+/) end
def run_task
def run_task if verbose puts "\n\n!!! Running `#{name}` rake command\n" puts "!!! Inspecting #{paths} #{options.empty? ? '' : "with options #{options}"}\n\n" end application = RubyCritic::Cli::Application.new(options_as_arguments + paths) application.execute end