Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Rule#call renmaed Rule#violation

  • Loading branch information...
commit a6259332864502e73f17ae3901a8bef5f9d740e4 1 parent 259b0bd
Brian Glusman authored
2  lib/outlaw/enforcement.rb
View
@@ -22,7 +22,7 @@ def handle(file)
if file.match(/.rb$/)
text = File.open(file) {|f| f.read}
rules.each do |rule|
- if rule.call(text)
+ if rule.violation?(text)
puts "Outlaw Violation in file: #{file}\nRestriction:" +
"#{rule.restriction}\n\n#{rule.message}"
end
2  lib/outlaw/rule.rb
View
@@ -9,7 +9,7 @@ def initialize(message, restriction, &detection_block)
@detection_block = detection_block
end
- def call(code)
+ def violation?(code)
@detection_block.call(code)
end
30 test/outlaw_test.rb
View
@@ -2,7 +2,7 @@
module Outlaw
describe LawParser do
- it "returns a Rule which is called on code and returns true or false" do
+ it "returns a Rule which is violation?ed on code and returns true or false" do
end
before do
@@ -34,8 +34,8 @@ def badthing(here)
end
}
- class_result = rule1.call(class_var_file)
- result1a = rule1.call(@okay_file)
+ class_result = rule1.violation?(class_var_file)
+ result1a = rule1.violation?(@okay_file)
class_result .must_equal true
end
@@ -52,8 +52,8 @@ def not_really
end
}
- protected_result= rule2.call(protected_file)
- result2a = rule2.call(@okay_file)
+ protected_result= rule2.violation?(protected_file)
+ result2a = rule2.violation?(@okay_file)
protected_result.must_equal true
result2a .must_equal false
@@ -70,8 +70,8 @@ def not_really
end
}
- eval_result = rule3.call(eval_file)
- result3a = rule3.call(@okay_file)
+ eval_result = rule3.violation?(eval_file)
+ result3a = rule3.violation?(@okay_file)
eval_result.must_equal true
result3a.must_equal false
@@ -87,8 +87,8 @@ module Thing
end
}
- module_result = rule4.call(module_file)
- result4a = rule4.call(@okay_file)
+ module_result = rule4.violation?(module_file)
+ result4a = rule4.violation?(@okay_file)
module_result.must_equal true
result4a.must_equal false
@@ -105,8 +105,8 @@ def badthing(here)
end
end
}
- core_result = rule5.call(core_file)
- result5a = rule5.call(@okay_file)
+ core_result = rule5.violation?(core_file)
+ result5a = rule5.violation?(@okay_file)
core_result .must_equal true
result5a.must_equal false
end
@@ -122,8 +122,8 @@ def badthing(here)
"bye"
end
}
- nil_result = rule7.call(nil_file)
- result7a = rule7.call(@okay_file)
+ nil_result = rule7.violation?(nil_file)
+ result7a = rule7.violation?(@okay_file)
nil_result .must_equal true
result7a.must_equal false
end
@@ -136,8 +136,8 @@ def badthing(here)
class MyClass < Struct.new("Customer", :name, :address)
}
- struct_result = rule8.call(struct_file)
- result8a = rule8.call(@okay_file)
+ struct_result = rule8.violation?(struct_file)
+ result8a = rule8.violation?(@okay_file)
struct_result.must_equal true
result8a.must_equal false
Please sign in to comment.
Something went wrong with that request. Please try again.