Skip to content

Commit

Permalink
whitespace handling
Browse files Browse the repository at this point in the history
  • Loading branch information
bglusman committed Feb 1, 2012
1 parent 660dc6b commit 9f4fad4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/outlaw.rb
Expand Up @@ -19,6 +19,7 @@ def enforce(dir=".")
end
PARAM_TYPES = [:on_const, :on_ident, :on_ivar, :on_cvar]
self.ignore_types = [:on_sp, :on_nl, :on_ignored_nl, :on_rparen, :on_lparen]
WHITESPACE = [:on_sp, :on_nl, :on_ignored_nl]
SPECIAL_CASES = [:whitespace_sensitive]
#these come from ripper's Lexer
CORE_CLASSES_FILE = File.expand_path("../../data/core_classes.txt", __FILE__)
Expand Down
3 changes: 2 additions & 1 deletion lib/outlaw/law_parser.rb
Expand Up @@ -26,7 +26,8 @@ def parse(restriction, rule)
private

def handle_special(token, rule)
rule.modifications = token
rule.modifications ||= []
rule.modifications << token
end

def special_case?(token)
Expand Down
5 changes: 5 additions & 0 deletions lib/outlaw/rule.rb
Expand Up @@ -24,6 +24,11 @@ def detect_violation(code)

def apply_modifications(restore=nil)
return nil if restore.nil?
defaults = Outlaw.ignore_types
Outlaw.ignore_types.delete(WHITESPACE) if modifications
.include?(:whitespace_sensitive)
Outlaw.ignore_types = restore if restore
defaults
end


Expand Down

0 comments on commit 9f4fad4

Please sign in to comment.