Class: AnnotateRb::RouteAnnotator::BaseProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/annotate_rb/route_annotator/base_processor.rb

Overview

This class is abstract class of classes adding and removing annotation to config/routes.rb.

Direct Known Subclasses

AnnotationProcessor, RemovalProcessor

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options, routes_file) ⇒ BaseProcessor

Returns a new instance of BaseProcessor.



19
20
21
22
# File 'lib/annotate_rb/route_annotator/base_processor.rb', line 19

def initialize(options, routes_file)
  @options = options
  @routes_file = routes_file
end

Class Method Details

.execute(options, routes_file) ⇒ String

Parameters:

  • options (Hash)
  • routes_file (String)

Returns:

  • (String)


12
13
14
# File 'lib/annotate_rb/route_annotator/base_processor.rb', line 12

def execute(options, routes_file)
  new(options, routes_file).execute
end

Instance Method Details

#routes_file_exist?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/annotate_rb/route_annotator/base_processor.rb', line 34

def routes_file_exist?
  File.exist?(routes_file)
end

#updateBoolean

Returns:

  • (Boolean)


25
26
27
28
29
30
31
32
# File 'lib/annotate_rb/route_annotator/base_processor.rb', line 25

def update
  if existing_text == new_text
    false
  else
    write(new_text)
    true
  end
end