class Ruumba::RakeTask

Provides a custom Rake task.

Attributes

dir[RW]
name[RW]
options[RW]

Public Class Methods

new(*args) { |*[self, task_args].slice(0, arity)| ... } click to toggle source

Sets up the custom Rake task. @param [Array<String>] args Arguments to the Rake task. @yield If called with a block, we'll call it to ensure additional options are included (e.g. dir).

# File lib/ruumba/rake_task.rb, line 15
def initialize(*args, &block)
  @name = args.shift || :ruumba
  @dir  = []
  @options = nil

  desc 'Run RuboCop on ERB files'
  task(name, *args) do |_, task_args|
    yield(*[self, task_args].slice(0, block.arity)) if block
    run
  end
end

Private Instance Methods

run() click to toggle source

Executes the custom Rake task. @private

# File lib/ruumba/rake_task.rb, line 31
def run
  # Like RuboCop itself, we'll lazy load so the task
  # doesn't substantially impact Rakefile load time.
  require 'ruumba'

  analyzer = Ruumba::Analyzer.new(@options)
  puts 'Running Ruumba...'

  exit(analyzer.run(@dir))
end