Sha256: 4e004534c9197d3d84a2894e7ecebe647c2140fc236e678bae7d7791ada299dc

Contents?: true

Size: 812 Bytes

Versions: 5

Compression:

Stored size: 812 Bytes

Contents

# frozen_string_literal: true

module Jiminy
  module Reporting
    class NPlusOne
      require "erb"

      # https://docs.ruby-lang.org/en/2.3.0/ERB.html#method-c-new
      ERB_SAFE_LEVEL = nil

      TRIM_MODE = "-"

      attr_reader :file, :line, :method, :examples

      attr_accessor :blob_url

      def initialize(file:, line:, method:, examples: [])
        @examples = examples
        @file = file
        @line = line
        @method = method
      end

      def to_markdown
        ERB.new(markdown_template, trim_mode: TRIM_MODE).result(binding)
      end

      def blob_url_with_line
        "#{blob_url}#L#{line}"
      end

      private

        def markdown_template
          @_markdown_template ||= File.read(File.join(TEMPLATES_DIR, "n_plus_one.md.erb"))
        end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
jiminy-0.4.0 lib/jiminy/reporting/n_plus_one.rb
jiminy-0.3.0 lib/jiminy/reporting/n_plus_one.rb
jiminy-0.2.0 lib/jiminy/reporting/n_plus_one.rb
jiminy-0.1.1 lib/jiminy/reporting/n_plus_one.rb
jiminy-0.1.0 lib/jiminy/reporting/n_plus_one.rb