Sha256: f82e37c98456ebb529fc97872c43e14ee9a680d6001ad953465a539a248ab1a5

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

require 'optparse'
require 'progressbar'
require 'colored'

options = {}
OptionParser.new do |opts|
  opts.banner = "Usage: rails_best_practices [options]"
  
  opts.on("-d", "--debug", "Debug mode") do
    options['debug'] = true
  end

  ['vendor', 'spec', 'test', 'stories'].each do |pattern|
    opts.on("--#{pattern}", "include #{pattern} files") do
      options[pattern] = true
    end
  end
  
  opts.on_tail('-v', '--version', 'Show this version') do
    puts File.read(File.dirname(__FILE__) + '/../../VERSION')
    exit
  end

  opts.on_tail("-h", "--help", "Show this message") do
    puts opts
    exit
  end

  opts.parse!
end

runner = RailsBestPractices::Core::Runner.new
runner.set_debug if options['debug']

files = RailsBestPractices::analyze_files(ARGV, options)
bar = ProgressBar.new('Analyzing', files.size)
files.each { |file| runner.check_file(file); bar.inc }
bar.finish

runner.errors.each {|error| puts error.to_s.red}
puts "\nPlease go to http://rails-bestpractices.com to see more useful Rails Best Practices.".green
if runner.errors.size > 0
  puts "\nFound #{runner.errors.size} errors.".red
end

exit runner.errors.size

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rails_best_practices-0.4.2 lib/rails_best_practices/command.rb
rails_best_practices-0.4.1 lib/rails_best_practices/command.rb