Sha256: fb4149bf5b329b0e9f64be40db89a3d2880a9a9e2dfcd481f35f01168402a635
Contents?: true
Size: 1.34 KB
Versions: 7
Compression:
Stored size: 1.34 KB
Contents
#!/usr/bin/env ruby $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib' require 'skeptic' require 'trollop' parser = Trollop::Parser.new do banner <<BANNER Points out annoying things in your Ruby code. Just run with: skeptic [options] <path_to_file> where [options] are: BANNER Skeptic::Rules.table.each_rule do |klass, slug, option_type, description| opt slug, description, type: option_type end opt :file, 'Path to file to analyze', type: :string end opts = Trollop::with_standard_exception_handling parser do parsed = parser.parse ARGV parsed[:file] ||= ARGV.shift unless parsed[:file_given] raise Trollop::HelpNeeded unless parsed[:file] raise Trollop::CommandlineError, "excessive arguments: #{ARGV.join(' ')}" unless ARGV.empty? raise Trollop::CommandlineError, "file does not exist: #{parsed[:file]}" unless File.exist? parsed[:file] parsed end code = File.read opts[:file] critic = Skeptic::Critic.new opts.select { |key, value| Skeptic::Rules.table.slugs.include? key } critic.criticize code if critic.criticism.empty? puts 'OK' exit(0) else messages = Hash.new { |hash, key| hash[key] = [] } critic.criticism.each do |message, type| messages[type] << message end messages.each do |type, messages| puts type messages.each do |message| puts "* #{message}" end puts "" end exit(1) end
Version data entries
7 entries across 7 versions & 1 rubygems
Version | Path |
---|---|
skeptic-0.0.7 | bin/skeptic |
skeptic-0.0.6 | bin/skeptic |
skeptic-0.0.5 | bin/skeptic |
skeptic-0.0.4 | bin/skeptic |
skeptic-0.0.3 | bin/skeptic |
skeptic-0.0.2 | bin/skeptic |
skeptic-0.0.1 | bin/skeptic |