Class: AnnotateRb::ModelAnnotator::RelatedFilesListBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/annotate_rb/model_annotator/related_files_list_builder.rb

Overview

Given a model file and options, this class will return a list of related files (e.g. fixture, controllers, etc) to also annotate

Constant Summary collapse

%w[test fixture factory serializer scaffold controller helper].freeze
EXCLUDE_TEST_OPTIONS =

Valid options when ‘:exclude_tests` is an Array, note that symbols are expected

%i[model controller serializer request routing].freeze

Instance Method Summary collapse

Constructor Details

#initialize(file, model_name, table_name, options) ⇒ RelatedFilesListBuilder

Returns a new instance of RelatedFilesListBuilder.



13
14
15
16
17
18
# File 'lib/annotate_rb/model_annotator/related_files_list_builder.rb', line 13

def initialize(file, model_name, table_name, options)
  @file = file
  @model_name = model_name
  @table_name = table_name
  @options = options
end

Instance Method Details

#buildObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/annotate_rb/model_annotator/related_files_list_builder.rb', line 20

def build
  @list = []

  add_related_test_files if !exclude_model_test_files?
  add_related_fixture_files if !@options[:exclude_fixtures]
  add_related_factory_files if !@options[:exclude_factories]
  add_related_serializer_files if !@options[:exclude_serializers]
  add_related_serializer_test_files if !exclude_serializer_tests?
  add_related_controller_test_files if !exclude_controller_tests?
  add_related_request_spec_files if !exclude_request_specs?
  add_related_routing_spec_files if !exclude_routing_specs?
  add_related_controller_files if !@options[:exclude_controllers]
  add_related_helper_files if !@options[:exclude_helpers]
  add_related_admin_files if @options[:active_admin]
  add_additional_file_patterns if @options[:additional_file_patterns].present?

  @list.uniq
end