Module: Snortor::RuleLoader
- Included in:
- RulefileCollection
- Defined in:
- lib/rule_loader.rb
Instance Method Summary collapse
Instance Method Details
#read_rules_from_dir(d, &block) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/rule_loader.rb', line 10 def read_rules_from_dir(d,&block) Dir.foreach(d) do |filename| full_file_path = File.join(d,filename) next if filename == ".." || filename == "." if File.directory?(full_file_path) read_rules_from_dir(full_file_path,&block) next end read_rules_from_file(full_file_path,&block) if File.extname(full_file_path) == ".rules" end end |
#read_rules_from_file(f, &block) ⇒ Object
3 4 5 6 7 8 |
# File 'lib/rule_loader.rb', line 3 def read_rules_from_file(f,&block) file = File.new(f, "r") while (line = file.gets) block.call(f,line) end end |