Sha256: 0e786e1a75a2ec3fdddc9c3034ee89754d7ce8f9aec78839696122bad893029a

Contents?: true

Size: 400 Bytes

Versions: 1

Compression:

Stored size: 400 Bytes

Contents

require "ruby_parser"

module OSHA
  class RubyFile
    PROCESSOR = RubyParser.new

    def initialize(file_path)
      @file_path = file_path
      @sexp = PROCESSOR.parse(File.read(file_path))
    end

    def apply_rules(rules)
      warnings = @sexp.deep_each.flat_map do |sexp|
        rules.map do |rule|
          rule.run(sexp)
        end
      end

      warnings.compact
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
OSHA-0.0.1 lib/osha/ruby_file.rb