class Pipeline::SFL
Public Class Methods
new(trigger, tracker)
click to toggle source
Calls superclass method
Pipeline::BaseTask::new
# File lib/pipeline/tasks/sfl.rb, line 11 def initialize(trigger, tracker) super(trigger,tracker) @name = "SFL" @description = "Sentive Files Lookup" @stage = :code @labels << "code" # Pipeline.debug "initialized SFL" @patterns = read_patterns_file! end
Public Instance Methods
analyze()
click to toggle source
# File lib/pipeline/tasks/sfl.rb, line 27 def analyze begin @files.each do |file| @patterns.each do |pattern| case pattern['part'] when 'filename' if pattern_matched?(File.basename(file), pattern) report pattern['caption'], pattern['description'], @name + ":" + file, 'unknown', 'TBD' end when 'extension' if pattern_matched?(File.extname(file), pattern) report pattern['caption'], pattern['description'], @name + ":" + file, 'unknown', 'TBD' end end end end rescue Exception => e Pipeline.warn e.message end end
pattern_matched?(txt, pattrn)
click to toggle source
# File lib/pipeline/tasks/sfl.rb, line 52 def pattern_matched?(txt, pattrn) case pattrn['type'] when 'match' return txt == pattrn['pattern'] when 'regex' regex = Regexp.new(pattrn['pattern'], Regexp::IGNORECASE) return !regex.match(txt).nil? end end
read_patterns_file!()
click to toggle source
# File lib/pipeline/tasks/sfl.rb, line 62 def read_patterns_file! JSON.parse(File.read("#{File.dirname(__FILE__)}/patterns.json")) rescue JSON::ParserError => e Pipeline.warn "Cannot parse pattern file: #{e.message}" end
run()
click to toggle source
# File lib/pipeline/tasks/sfl.rb, line 21 def run # Pipeline.notify "#{@name}" @files = Find.find(@trigger.path) Pipeline.debug "Found #{@files.count} files" end
supported?()
click to toggle source
# File lib/pipeline/tasks/sfl.rb, line 48 def supported? true end