Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Massive rename: Checkmate is reborn as Panache

  • Loading branch information...
commit 1994c51d2b638b1fc2222480a8a1f18d3844b2d3 1 parent 3300d78
Daniel MacDougall dmac authored
24 README.md
Source Rendered
... ... @@ -1,7 +1,7 @@
1   -Checkmate
2   -=========
  1 +Panache
  2 +=======
3 3
4   -Checkmate is a simple way to create style checkers for various languages. It does simple parsing of source
  4 +Panache is a simple way to create style checkers for various languages. It does simple parsing of source
5 5 files and then applies user-specified rules to detect style violations.
6 6
7 7 Code parsing is *not* full lexing; it is an intentional design goal to limit code introspection in order to
@@ -13,34 +13,34 @@ Usage
13 13 -----
14 14
15 15 ```bash
16   -$ gem install checkmate
17   -$ checkmate [-s checkmate_styles] code_path [code_path ...]
  16 +$ gem install panache
  17 +$ panache [-s panache_styles] code_path [code_path ...]
18 18 ```
19 19
20   -`checkmate_styles` is the directory where your style files are stored and each `code_path` is a file
  20 +`panache_styles` is the directory where your style files are stored and each `code_path` is a file
21 21 or directory to check.
22 22
23   -One of the most useful ways to use checkmate is as a pre-commit or post-commit hook in your repository.
  23 +One of the most useful ways to use Panache is as a pre-commit or post-commit hook in your repository.
24 24 For example, to check each file that was modified after you commit your git post-commit hook could look
25 25 like:
26 26
27 27 ```bash
28 28 #!/bin/sh
29 29
30   -checkmate -s ~/repos/checkmate_styles $(git show --pretty="format:" --name-only)
  30 +panache -s ~/repos/panache_styles $(git show --pretty="format:" --name-only)
31 31 ```
32 32
33 33 Creating new styles
34 34 -------------------
35 35
36   -To create a new style, you will need a Textmate syntax file and a rules file written in the Checkmate DSL.
  36 +To create a new style, you will need a Textmate syntax file and a rules file written in the Panache DSL.
37 37
38 38 The easiest way to get Textmate syntax files is to copy them out of a Textmate installation on your computer.
39 39 They should have the path
40 40
41 41 /Applications/TextMate.app/Contents/SharedSupport/Bundles/<your-language>.tmbundle/Syntaxes/<your-language>.plist
42 42
43   -This is a binary plist file, and Checkmate requires it to be in the text XML format; you can convert it like this:
  43 +This is a binary plist file, and Panache requires it to be in the text XML format; you can convert it like this:
44 44
45 45 $ plutil -convert xml1 <your-language>.plist
46 46
@@ -54,14 +54,14 @@ TODO(caleb): Update steps below.
54 54
55 55 1. Make a file called `<language>_style.rb`, where `<language>` is the type of file you want to check.
56 56 2. Use the DSL implemented in this file to write your style.
57   - * The regex you give to Checkmate::Style#create matches the filenames you wish to check.
  57 + * The regex you give to Panache::Style#create matches the filenames you wish to check.
58 58 * Each rule consists of a regex and a message to indicate what the violation was.
59 59 * The regex may contain a match. The offset of the beginning of this match will be used to indicate
60 60 exactly where a style violation occurred.
61 61
62 62 Dumb example:
63 63
64   - Checkmate::Style.create(/\.txt$/) do
  64 + Panache::Style.create(/\.txt$/) do
65 65 rule /(q)/, "The letter 'q' is not allowed in text files."
66 66 end
67 67
14 bin/checkmate → bin/panache
... ... @@ -1,15 +1,15 @@
1 1 #!/usr/bin/env ruby
2 2
3   -require "checkmate"
  3 +require "panache"
4 4
5 5 # TODO(caleb): multiple output options.
6 6
7 7 def usage
8 8 <<-EOF
9 9 Usage:
10   - checkmate [-s styles_directory] code_path [code_path ...]
  10 + panache [-s styles_directory] code_path [code_path ...]
11 11
12   -The styles_directory may also be specified with the CHECKMATE_STYLES environment variable.
  12 +The styles_directory may also be specified with the PANACHE_STYLES environment variable.
13 13 EOF
14 14 end
15 15
@@ -23,14 +23,14 @@ ARGV.each_with_index do |option, index|
23 23 end
24 24 code_paths << option
25 25 end
26   -style_directory ||= ENV["CHECKMATE_STYLES"]
  26 +style_directory ||= ENV["PANACHE_STYLES"]
27 27
28 28 if style_directory.nil? || code_paths.empty?
29 29 puts usage
30 30 exit 1
31 31 end
32 32
33   -Checkmate.load_styles(style_directory)
  33 +Panache.load_styles(style_directory)
34 34 results = {}
35   -code_paths.each { |path| results.merge! Checkmate.check_path(path) }
36   -Checkmate::Printer.new(results).print_results
  35 +code_paths.each { |path| results.merge! Panache.check_path(path) }
  36 +Panache::Printer.new(results).print_results
14 lib/checkmate.rb → lib/panache.rb
... ... @@ -1,11 +1,11 @@
1 1 require "find"
2 2 require "colorize"
3 3
4   -module Checkmate
  4 +module Panache
5 5 @@styles = []
6 6
7 7 DEFAULT_TAB_SPACES = 2
8   - DEFAULT_STYLE_PATH = File.expand_path("~/repos/checkmate/checkmate_styles")
  8 + DEFAULT_STYLE_PATH = File.expand_path("~/repos/panache/panache_styles")
9 9 Violation = Struct.new :line_number, :line, :offset, :style, :rule
10 10
11 11 class Rule
@@ -44,7 +44,7 @@ def initialize(file_regex)
44 44 def self.create(file_regex, &block)
45 45 style = Style.new(file_regex)
46 46 style.instance_eval &block
47   - Checkmate.add_style style
  47 + Panache.add_style style
48 48 end
49 49
50 50 def spaces_per_tab(n)
@@ -77,11 +77,11 @@ def self.add_style(style)
77 77 @@styles << style
78 78 end
79 79
80   - # Load all Checkmate styles (files matching *_style.rb) from a given directory.
  80 + # Load all Panache styles (files matching *_style.rb) from a given directory.
81 81 def self.load_styles(directory = DEFAULT_STYLE_PATH)
82   - raise "Need a directory of Checkmate styles" unless File.directory?(directory)
  82 + raise "Need a directory of Panache styles" unless File.directory?(directory)
83 83 style_files = Dir.glob(File.join(directory, "*_style.rb"))
84   - raise "No Checkmate styles found in #{directory}" if style_files.empty?
  84 + raise "No Panache styles found in #{directory}" if style_files.empty?
85 85 style_files.each do |style|
86 86 puts "Loading #{style}...".green
87 87 load style
@@ -110,7 +110,7 @@ def self.check_path(path)
110 110 end
111 111 puts "Checking #{path}".green
112 112 results = {}
113   - files.each { |file| results[file] = Checkmate.check_file file }
  113 + files.each { |file| results[file] = Panache.check_file file }
114 114 results
115 115 end
116 116
2  lib/checkmate/version.rb → lib/panache/version.rb
... ... @@ -1,3 +1,3 @@
1   -module Checkmate
  1 +module Panache
2 2 VERSION = "0.0.1"
3 3 end
10 checkmate.gemspec → panache.gemspec
... ... @@ -1,20 +1,20 @@
1 1 # -*- encoding: utf-8 -*-
2 2 $:.push File.expand_path("../lib", __FILE__)
3   -require "checkmate/version"
  3 +require "panache/version"
4 4
5 5 Gem::Specification.new do |s|
6   - s.name = "checkmate"
7   - s.version = Checkmate::VERSION
  6 + s.name = "panache"
  7 + s.version = Panache::VERSION
8 8 s.authors = ["Caleb Spare", "Daniel MacDougall"]
9 9 s.email = ["caleb@ooyala.com", "dmac@ooyala.com"]
10 10 s.homepage = ""
11 11 s.summary = %q{Create style checkers for various languages}
12 12 s.description = <<-EOF
13   -Checkmate is a simple way to create style checkers for various languages.
  13 +Panache is a simple way to create style checkers for various languages.
14 14 It does simple parsing of source files and then applies user-specified rules to detect style violations.
15 15 EOF
16 16
17   - s.rubyforge_project = "checkmate"
  17 + s.rubyforge_project = "panache"
18 18
19 19 s.files = `git ls-files`.split("\n")
20 20 s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
2  post-commit
... ... @@ -1,4 +1,4 @@
1 1 #!/bin/sh
2 2
3 3 export RBENV_VERSION="1.9.2-p290"
4   -checkmate -s ~/repos/checkmate_styles $(git show --pretty="format:" --name-only)
  4 +panache -s ~/repos/panache_styles $(git show --pretty="format:" --name-only)

0 comments on commit 1994c51

Please sign in to comment.
Something went wrong with that request. Please try again.