No commit activity in last 3 years
No release in over 3 years
Runs several rake tasks or system commands, and filters their output for easy review
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.11
~> 10.0
~> 3.0
~> 0.37.0
~> 0.11
~> 0.8

Runtime

 Project Readme

Gem Version Build Status Code Climate Test Coverage

RakeCommandFilter

RakeCommandFilter allows you to execute multiple rake commands in subprocesses and filter their output for easy review.

Installation

Add this line to your application's Gemfile:

gem 'rake_command_filter'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rake_command_filter

Purpose

Prior to checking in, I wanted to run all my favored validation tools (rubocop, rspec with simplecov, and yard), and review simple output like this:

OK             rubocop                1.27s     15 files
OK             spec                   7.97s     11 passed
OK             spec                   7.97s     96.9 test coverage
OK             yard                   1.46s     100.0 documented

so that I did not need to dig through the results to determine if I was satisfied. Only if they failed did I want to see detailed output from a given command.

RakeCommandFilter does this, and can be extended to process the output of other tools.

Usage

Put this in your Rakefile, then run rake full_validation.

require 'rake_command_filter'

RakeCommandFilter::RakeTask.new(:validate) do
  desc 'Run full validation'
  run_definition(RakeCommandFilter::ScssLintCommandDefinition.new) do
    add_parameter('app/assets/stylesheets')
  end
  run_definition(RakeCommandFilter::RubocopCommandDefinition.new)
  run_definition(RakeCommandFilter::RSpecCommandDefinition.new)
  run_definition(RakeCommandFilter::YardCommandDefinition.new)
end

If you setup a rake command like that above, you can use this as a git pre-commit hook:

#!/bin/bash                                                                                                                                        
rake full_validation
exit $?

in order to see the nice output whenever you commit.

Customization

You can customize rake_command_filter to run and parse the output of other commands by implementing your own CommandDefinition subclass. You can also alter an existing version in a block, as in this example from the tests:

task = RakeCommandFilter::RakeTask.new(:test_warn) do
  desc 'My deployment task'
  run_definition(RakeCommandFilter::YardCommandDefinition.new) do
    add_parameter(' doc yard_warn.rb')
  end
end

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/chrisjones-tripletri/rake_command_filter. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.