Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Allam committed May 26, 2011
0 parents commit 645bb08
Show file tree
Hide file tree
Showing 38 changed files with 2,337 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
@@ -0,0 +1,5 @@
*.gem
.bundle
Gemfile.lock
pkg/*
.rvmrc
4 changes: 4 additions & 0 deletions Gemfile
@@ -0,0 +1,4 @@
source "http://rubygems.org"

# Specify your gem's dependencies in ruby_cop.gemspec
gemspec
Empty file added README
Empty file.
2 changes: 2 additions & 0 deletions Rakefile
@@ -0,0 +1,2 @@
require 'bundler'
Bundler::GemHelper.install_tasks
12 changes: 12 additions & 0 deletions lib/ruby_cop.rb
@@ -0,0 +1,12 @@
module RubyCop
# Your code goes here...
end

require 'ripper'

require 'ruby_cop/ruby'
require 'ruby_cop/node_builder'
require 'ruby_cop/gray_list'
require 'ruby_cop/policy'


26 changes: 26 additions & 0 deletions lib/ruby_cop/gray_list.rb
@@ -0,0 +1,26 @@
require 'set'

module RubyCop
# Combination blacklist and whitelist.
class GrayList
def initialize
@blacklist = Set.new
@whitelist = Set.new
end

# An item is allowed if it's whitelisted, or if it's not blacklisted.
def allow?(item)
@whitelist.include?(item) || !@blacklist.include?(item)
end

def blacklist(item)
@whitelist.delete(item)
@blacklist.add(item)
end

def whitelist(item)
@blacklist.delete(item)
@whitelist.add(item)
end
end
end

0 comments on commit 645bb08

Please sign in to comment.