lib/locat/matcher.rb in locat-0.1.2 vs lib/locat/matcher.rb in locat-0.2.0

- old
+ new

@@ -7,11 +7,11 @@ # def initialize(*config_files) @rules = [] if config_files.empty? - raise ArgumentError, 'no configuration files' + default end config_files.each do |f| instance_eval(File.read(f)) end @@ -32,8 +32,35 @@ # def size @rules.size end + + private + + # Default configuration if none is supplied by the project. + def default + match 'lib/**.rb' do |file, line| + case line + when /^\s*#/ + 'Comment' + when /^\s*$/ + 'Blank' + else + 'Code' + end + end + match 'test/**.rb' do |file, line| + case line + when /^\s*#/ + 'Comment' + when /^\s*$/ + 'Blank' + else + 'Test' + end + end + end + end end