class SyntaxTree::Rake::Task

A parent Rake task that runs a command on a set of source files.

def command

This method needs to be overridden in the child tasks.
def command
  raise NotImplementedError
end

def define_task

def define_task
  desc "Runs `stree #{command}` over source files"
  task(name) { run_task }
end

def initialize(

def initialize(
  name = :"stree:#{command}",
  source_files = ::Rake::FileList["lib/**/*.rb"],
  plugins = [],
  print_width = DEFAULT_PRINT_WIDTH,
  target_ruby_version = Gem::Version.new(RUBY_VERSION),
  ignore_files = ""
)
  @name = name
  @source_files = source_files
  @plugins = plugins
  @print_width = print_width
  @target_ruby_version = target_ruby_version
  @ignore_files = ignore_files
  yield self if block_given?
  define_task
end

def run_task

def run_task
  arguments = [command]
  arguments << "--plugins=#{plugins.join(",")}" if plugins.any?
  if print_width != DEFAULT_PRINT_WIDTH
    arguments << "--print-width=#{print_width}"
  end
  if target_ruby_version != Gem::Version.new(RUBY_VERSION)
    arguments << "--target-ruby-version=#{target_ruby_version}"
  end
  arguments << "--ignore-files=#{ignore_files}" if ignore_files != ""
  abort if SyntaxTree::CLI.run(arguments + Array(source_files)) != 0
end