Using jshint with Middleman

Has anyone connected jshint with Middleman to automatically run all JavaScript files through jshint when middleman build is run? There is a Ruby Gem called jshintrb. I have added the Gem to my Gemfile and installed it but I am unsure how to call it from my config.rb file.

If I had a Rakefile, I could add the following:

require 'jshintrb/jshinttask'

Jshintrb::JshintTask.new :jshint do |t|
  t.pattern = 'source/assets/**/*.js'
  t.exclude_pattern = 'source/assets/{vendor/**/*,require}.js'
  t.options = JSON.parse(IO.read('.jshintrc'))
end

But is there a way to call this from Middleman’s config.rb file?

Another option I have is to install the command line version of jshint with npm install jshint -g, and then call this command line app from Middleman’s config.rb with:

after_build do
	system("jshint .")
and

This seems to work well and I guess the Ruby gem was probably wrapping around an older version of jshint anyway.