diff --git a/README.md b/README.md index b6b5636..b33c7ae 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -Checkmate -========= +Panache +======= -Checkmate is a simple way to create style checkers for various languages. It does simple parsing of source +Panache is a simple way to create style checkers for various languages. It does simple parsing of source files and then applies user-specified rules to detect style violations. Code parsing is *not* full lexing; it is an intentional design goal to limit code introspection in order to @@ -13,34 +13,34 @@ Usage ----- ```bash -$ gem install checkmate -$ checkmate [-s checkmate_styles] code_path [code_path ...] +$ gem install panache +$ panache [-s panache_styles] code_path [code_path ...] ``` -`checkmate_styles` is the directory where your style files are stored and each `code_path` is a file +`panache_styles` is the directory where your style files are stored and each `code_path` is a file or directory to check. -One of the most useful ways to use checkmate is as a pre-commit or post-commit hook in your repository. +One of the most useful ways to use Panache is as a pre-commit or post-commit hook in your repository. For example, to check each file that was modified after you commit your git post-commit hook could look like: ```bash #!/bin/sh -checkmate -s ~/repos/checkmate_styles $(git show --pretty="format:" --name-only) +panache -s ~/repos/panache_styles $(git show --pretty="format:" --name-only) ``` Creating new styles ------------------- -To create a new style, you will need a Textmate syntax file and a rules file written in the Checkmate DSL. +To create a new style, you will need a Textmate syntax file and a rules file written in the Panache DSL. The easiest way to get Textmate syntax files is to copy them out of a Textmate installation on your computer. They should have the path /Applications/TextMate.app/Contents/SharedSupport/Bundles/.tmbundle/Syntaxes/.plist -This is a binary plist file, and Checkmate requires it to be in the text XML format; you can convert it like this: +This is a binary plist file, and Panache requires it to be in the text XML format; you can convert it like this: $ plutil -convert xml1 .plist @@ -54,14 +54,14 @@ TODO(caleb): Update steps below. 1. Make a file called `_style.rb`, where `` is the type of file you want to check. 2. Use the DSL implemented in this file to write your style. - * The regex you give to Checkmate::Style#create matches the filenames you wish to check. + * The regex you give to Panache::Style#create matches the filenames you wish to check. * Each rule consists of a regex and a message to indicate what the violation was. * The regex may contain a match. The offset of the beginning of this match will be used to indicate exactly where a style violation occurred. Dumb example: - Checkmate::Style.create(/\.txt$/) do + Panache::Style.create(/\.txt$/) do rule /(q)/, "The letter 'q' is not allowed in text files." end diff --git a/bin/checkmate b/bin/panache similarity index 51% rename from bin/checkmate rename to bin/panache index bb9d0ab..b57919e 100755 --- a/bin/checkmate +++ b/bin/panache @@ -1,15 +1,15 @@ #!/usr/bin/env ruby -require "checkmate" +require "panache" # TODO(caleb): multiple output options. def usage <<-EOF Usage: - checkmate [-s styles_directory] code_path [code_path ...] + panache [-s styles_directory] code_path [code_path ...] -The styles_directory may also be specified with the CHECKMATE_STYLES environment variable. +The styles_directory may also be specified with the PANACHE_STYLES environment variable. EOF end @@ -23,14 +23,14 @@ ARGV.each_with_index do |option, index| end code_paths << option end -style_directory ||= ENV["CHECKMATE_STYLES"] +style_directory ||= ENV["PANACHE_STYLES"] if style_directory.nil? || code_paths.empty? puts usage exit 1 end -Checkmate.load_styles(style_directory) +Panache.load_styles(style_directory) results = {} -code_paths.each { |path| results.merge! Checkmate.check_path(path) } -Checkmate::Printer.new(results).print_results +code_paths.each { |path| results.merge! Panache.check_path(path) } +Panache::Printer.new(results).print_results diff --git a/lib/checkmate.rb b/lib/panache.rb similarity index 89% rename from lib/checkmate.rb rename to lib/panache.rb index 4a2b388..72ac3b0 100644 --- a/lib/checkmate.rb +++ b/lib/panache.rb @@ -1,11 +1,11 @@ require "find" require "colorize" -module Checkmate +module Panache @@styles = [] DEFAULT_TAB_SPACES = 2 - DEFAULT_STYLE_PATH = File.expand_path("~/repos/checkmate/checkmate_styles") + DEFAULT_STYLE_PATH = File.expand_path("~/repos/panache/panache_styles") Violation = Struct.new :line_number, :line, :offset, :style, :rule class Rule @@ -44,7 +44,7 @@ def initialize(file_regex) def self.create(file_regex, &block) style = Style.new(file_regex) style.instance_eval &block - Checkmate.add_style style + Panache.add_style style end def spaces_per_tab(n) @@ -77,11 +77,11 @@ def self.add_style(style) @@styles << style end - # Load all Checkmate styles (files matching *_style.rb) from a given directory. + # Load all Panache styles (files matching *_style.rb) from a given directory. def self.load_styles(directory = DEFAULT_STYLE_PATH) - raise "Need a directory of Checkmate styles" unless File.directory?(directory) + raise "Need a directory of Panache styles" unless File.directory?(directory) style_files = Dir.glob(File.join(directory, "*_style.rb")) - raise "No Checkmate styles found in #{directory}" if style_files.empty? + raise "No Panache styles found in #{directory}" if style_files.empty? style_files.each do |style| puts "Loading #{style}...".green load style @@ -110,7 +110,7 @@ def self.check_path(path) end puts "Checking #{path}".green results = {} - files.each { |file| results[file] = Checkmate.check_file file } + files.each { |file| results[file] = Panache.check_file file } results end diff --git a/lib/checkmate/version.rb b/lib/panache/version.rb similarity index 58% rename from lib/checkmate/version.rb rename to lib/panache/version.rb index 05d076a..7593653 100644 --- a/lib/checkmate/version.rb +++ b/lib/panache/version.rb @@ -1,3 +1,3 @@ -module Checkmate +module Panache VERSION = "0.0.1" end diff --git a/checkmate.gemspec b/panache.gemspec similarity index 78% rename from checkmate.gemspec rename to panache.gemspec index 1aee4f5..6a3f164 100644 --- a/checkmate.gemspec +++ b/panache.gemspec @@ -1,20 +1,20 @@ # -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", __FILE__) -require "checkmate/version" +require "panache/version" Gem::Specification.new do |s| - s.name = "checkmate" - s.version = Checkmate::VERSION + s.name = "panache" + s.version = Panache::VERSION s.authors = ["Caleb Spare", "Daniel MacDougall"] s.email = ["caleb@ooyala.com", "dmac@ooyala.com"] s.homepage = "" s.summary = %q{Create style checkers for various languages} s.description = <<-EOF -Checkmate is a simple way to create style checkers for various languages. +Panache is a simple way to create style checkers for various languages. It does simple parsing of source files and then applies user-specified rules to detect style violations. EOF - s.rubyforge_project = "checkmate" + s.rubyforge_project = "panache" s.files = `git ls-files`.split("\n") s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") diff --git a/post-commit b/post-commit index e3ef91a..86a4cd8 100755 --- a/post-commit +++ b/post-commit @@ -1,4 +1,4 @@ #!/bin/sh export RBENV_VERSION="1.9.2-p290" -checkmate -s ~/repos/checkmate_styles $(git show --pretty="format:" --name-only) +panache -s ~/repos/panache_styles $(git show --pretty="format:" --name-only)