Class: AnnotateRb::ModelAnnotator::PatternGetter

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

Defined Under Namespace

Modules: FilePatterns

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options, pattern_types = []) ⇒ PatternGetter

Returns a new instance of PatternGetter.



59
60
61
62
# File 'lib/annotate_rb/model_annotator/pattern_getter.rb', line 59

def initialize(options, pattern_types = [])
  @options = options
  @pattern_types = pattern_types
end

Class Method Details

.call(options, pattern_types = []) ⇒ Object



54
55
56
# File 'lib/annotate_rb/model_annotator/pattern_getter.rb', line 54

def call(options, pattern_types = [])
  new(options, pattern_types).get
end

Instance Method Details

#getObject



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/annotate_rb/model_annotator/pattern_getter.rb', line 64

def get
  current_patterns = []

  @options[:root_dir].each do |root_directory|
    Array(@pattern_types).each do |pattern_type|
      patterns = generate(root_directory, pattern_type)

      current_patterns += if pattern_type.to_sym == :additional_file_patterns
        patterns
      else
        patterns.map { |p| p.sub(/^\/*/, "") }
      end
    end
  end

  current_patterns
end