Sha256: a1caa857c243ec9eca13e651902c37aec3efff2cb0c9916f2538ed64222c921e

Contents?: true

Size: 963 Bytes

Versions: 2

Compression:

Stored size: 963 Bytes

Contents

# frozen_string_literal: true

module StrictTodo
  class FindWord
    private_class_method :new

    class << self
      def perform(file_path:)
        results = {}
        File.readlines(file_path, chomp: true).each.with_index(1) do |line, index|
          if line.include?('TODO')
            results["#{file_path}:#{index.to_s}"] = {
              header: extraction_todo(file_path: file_path, index: index),
              description: line
            }
          end

          if line.include?('FIXME')
            results["#{file_path}:#{index.to_s}"] = {
              header: extraction_fixme(file_path: file_path, index: index),
              description: line
            }
          end
        end
        results
      end

      private

      def extraction_todo(file_path:, index:)
        "TODO(#{file_path}:#{index})"
      end

      def extraction_fixme(file_path:, index:)
        "FIXME(#{file_path}:#{index})"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
strict-todo-0.0.2 lib/strict_todo/find_word.rb
strict-todo-0.0.1 lib/strict_todo/find_word.rb