Sha256: 745d635e0d5e601ba30d41bc8f801b44d7caf9343074b265c579c19119ab5d3c

Contents?: true

Size: 1.18 KB

Versions: 15

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

# This module provides methods for annotating config/routes.rb.
module AnnotateRb
  module RouteAnnotator
    # This class is abstract class of classes adding and removing annotation to config/routes.rb.
    class RemovalProcessor < BaseProcessor
      # @return [String]
      def execute
        if routes_file_exist?
          if update
            "Annotations were removed from #{routes_file}."
          else
            "#{routes_file} was not changed (Annotation did not exist)."
          end
        else
          "#{routes_file} could not be found."
        end
      end

      private

      def generate_new_content_array(content, header_position)
        if header_position == :before
          content.shift while content.first == ""
        elsif header_position == :after
          content.pop while content.last == ""
        end

        # Make sure we end on a trailing newline.
        content << "" unless content.last == ""

        # TODO: If the user buried it in the middle, we should probably see about
        # TODO: preserving a single line of space between the content above and
        # TODO: below...
        content
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
annotaterb-4.13.0 lib/annotate_rb/route_annotator/removal_processor.rb
annotaterb-4.12.0 lib/annotate_rb/route_annotator/removal_processor.rb
annotaterb-4.11.0 lib/annotate_rb/route_annotator/removal_processor.rb
annotaterb-4.10.2 lib/annotate_rb/route_annotator/removal_processor.rb
annotaterb-4.10.1 lib/annotate_rb/route_annotator/removal_processor.rb
annotaterb-4.10.0 lib/annotate_rb/route_annotator/removal_processor.rb
annotaterb-4.9.0 lib/annotate_rb/route_annotator/removal_processor.rb
annotaterb-4.7.0 lib/annotate_rb/route_annotator/removal_processor.rb
annotaterb-4.6.0 lib/annotate_rb/route_annotator/removal_processor.rb
annotaterb-4.5.0 lib/annotate_rb/route_annotator/removal_processor.rb
annotaterb-4.4.1 lib/annotate_rb/route_annotator/removal_processor.rb
annotaterb-4.4.0 lib/annotate_rb/route_annotator/removal_processor.rb
annotaterb-4.3.1 lib/annotate_rb/route_annotator/removal_processor.rb
annotaterb-4.3.0 lib/annotate_rb/route_annotator/removal_processor.rb
annotaterb-4.2.0 lib/annotate_rb/route_annotator/removal_processor.rb