Permalink
Browse files

Massive rename: Checkmate is reborn as Panache

  • Loading branch information...
1 parent 3300d78 commit 1994c51d2b638b1fc2222480a8a1f18d3844b2d3 @dmac dmac committed Nov 10, 2011
View
@@ -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/<your-language>.tmbundle/Syntaxes/<your-language>.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 <your-language>.plist
@@ -54,14 +54,14 @@ TODO(caleb): Update steps below.
1. Make a file called `<language>_style.rb`, where `<language>` 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
@@ -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
@@ -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
@@ -1,3 +1,3 @@
-module Checkmate
+module Panache
VERSION = "0.0.1"
end
@@ -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")
View
@@ -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)

0 comments on commit 1994c51

Please sign in to comment.