Sha256: c6af40d9516777ba19d924319a28f5408fcae43050341485958f57f0ea1db02e

Contents?: true

Size: 701 Bytes

Versions: 2

Compression:

Stored size: 701 Bytes

Contents

# frozen_string_literal: true

module PrivateDetective
  class AnalyzeFile

    attr_reader :file_path, :report, :node

    # @param [String] file_path, [Hash] report
    def initialize(file_path:, report:)
      @file_path = file_path
      @report = report
    end

    # @return [Hash] report
    def analyze_file
      @node = Parser::CurrentRuby.parse(File.read(file_path))
      return unless node.is_a?(Parser::AST::Node)

      analyze_node
    end

    private

    # @return [Hash] report
    def analyze_node
      analyze_node = PrivateDetective::AnalyzeNode.new(node: node, file_path: file_path)
      analyze_node.process_node

      report.merge!(analyze_node.report)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
private_detective-0.1.1 lib/private_detective/analyze_file.rb
private_detective-0.1.0 lib/private_detective/analyze_file.rb