Class: ChurnVsComplexity::FileSelector::Excluding

Inherits:
Object
  • Object
show all
Defined in:
lib/churn_vs_complexity/file_selector.rb

Direct Known Subclasses

Predefined

Instance Method Summary collapse

Constructor Details

#initialize(extensions, excluded, convert_to_absolute_path = false) ⇒ Excluding

Returns a new instance of Excluding.



26
27
28
29
30
# File 'lib/churn_vs_complexity/file_selector.rb', line 26

def initialize(extensions, excluded, convert_to_absolute_path = false)
  @extensions = extensions
  @excluded = excluded
  @convert_to_absolute_path = convert_to_absolute_path
end

Instance Method Details

#select_files(folder) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/churn_vs_complexity/file_selector.rb', line 32

def select_files(folder)
  were_excluded = []
  were_included = []
  candidates(folder).each do |f|
    if has_excluded_pattern?(f)
      were_excluded << f
    elsif has_correct_extension?(f) && File.file?(f)
      were_included << f
    end
  end
  if @convert_to_absolute_path
    were_excluded.map! { |f| File.absolute_path(f) }
    were_included.map! { |f| File.absolute_path(f) }
  end
  { explicitly_excluded: were_excluded, included: were_included }
end