Class: SourceFinder::SourceFileGlobber

Inherits:
Object
  • Object
show all
Defined in:
lib/source_finder/source_file_globber.rb

Overview

Give configuration, finds source file locations by using an inclusion and exclusion glob

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(globber: Dir) ⇒ SourceFileGlobber

Returns a new instance of SourceFileGlobber.



13
14
15
# File 'lib/source_finder/source_file_globber.rb', line 13

def initialize(globber: Dir)
  @globber = globber
end

Instance Attribute Details

#exclude_files_arrObject

See README.md for documentation on these configuration parameters.



7
8
9
# File 'lib/source_finder/source_file_globber.rb', line 7

def exclude_files_arr
  @exclude_files_arr
end

#extra_ruby_files_arrObject

See README.md for documentation on these configuration parameters.



7
8
9
# File 'lib/source_finder/source_file_globber.rb', line 7

def extra_ruby_files_arr
  @extra_ruby_files_arr
end

#extra_source_files_arrObject

See README.md for documentation on these configuration parameters.



7
8
9
# File 'lib/source_finder/source_file_globber.rb', line 7

def extra_source_files_arr
  @extra_source_files_arr
end

#ruby_dirs_arrObject

See README.md for documentation on these configuration parameters.



7
8
9
# File 'lib/source_finder/source_file_globber.rb', line 7

def ruby_dirs_arr
  @ruby_dirs_arr
end

#ruby_file_extensions_arrObject

See README.md for documentation on these configuration parameters.



7
8
9
# File 'lib/source_finder/source_file_globber.rb', line 7

def ruby_file_extensions_arr
  @ruby_file_extensions_arr
end

#source_dirs_arrObject

See README.md for documentation on these configuration parameters.



7
8
9
# File 'lib/source_finder/source_file_globber.rb', line 7

def source_dirs_arr
  @source_dirs_arr
end

#source_file_extensions_arrObject

See README.md for documentation on these configuration parameters.



7
8
9
# File 'lib/source_finder/source_file_globber.rb', line 7

def source_file_extensions_arr
  @source_file_extensions_arr
end

#source_file_extensions_globObject

See README.md for documentation on these configuration parameters.



7
8
9
# File 'lib/source_finder/source_file_globber.rb', line 7

def source_file_extensions_glob
  @source_file_extensions_glob
end

#source_files_exclude_globObject

See README.md for documentation on these configuration parameters.



7
8
9
# File 'lib/source_finder/source_file_globber.rb', line 7

def source_files_exclude_glob
  @source_files_exclude_glob
end

#source_files_globObject

See README.md for documentation on these configuration parameters.



7
8
9
# File 'lib/source_finder/source_file_globber.rb', line 7

def source_files_glob
  @source_files_glob
end

Instance Method Details

#doc_file_extensions_arrObject



48
49
50
# File 'lib/source_finder/source_file_globber.rb', line 48

def doc_file_extensions_arr
  @doc_file_extensions_arr ||= %w(md)
end

#make_source_files_glob(extra_source_files_arr, dirs_arr, extensions_glob) ⇒ Object



77
78
79
80
81
82
83
84
85
86
# File 'lib/source_finder/source_file_globber.rb', line 77

def make_source_files_glob(extra_source_files_arr,
                           dirs_arr,
                           extensions_glob)
  "{#{extra_source_files_arr.join(',')}," \
  "{*,.*}.{#{extensions_glob}}," +
    File.join("{#{dirs_arr.join(',')}}",
              '**',
              "{*,.*}.{#{extensions_glob}}") +
    '}'
end

#ruby_file_extensions_globObject



96
97
98
# File 'lib/source_finder/source_file_globber.rb', line 96

def ruby_file_extensions_glob
  @ruby_file_extensions_glob ||= ruby_file_extensions_arr.join(',')
end

#ruby_files_arrObject



106
107
108
# File 'lib/source_finder/source_file_globber.rb', line 106

def ruby_files_arr
  @globber.glob(ruby_files_glob) - exclude_files_arr
end

#ruby_files_globObject



100
101
102
103
104
# File 'lib/source_finder/source_file_globber.rb', line 100

def ruby_files_glob
  make_source_files_glob(extra_ruby_files_arr,
                         ruby_dirs_arr,
                         ruby_file_extensions_glob)
end

#source_and_doc_file_extensions_arrObject



56
57
58
# File 'lib/source_finder/source_file_globber.rb', line 56

def source_and_doc_file_extensions_arr
  doc_file_extensions_arr + source_file_extensions_arr
end

#source_and_doc_file_extensions_globObject



60
61
62
63
# File 'lib/source_finder/source_file_globber.rb', line 60

def source_and_doc_file_extensions_glob
  @source_and_doc_file_extensions_glob ||=
    source_and_doc_file_extensions_arr.join(',')
end

#source_and_doc_files_globObject



71
72
73
74
75
# File 'lib/source_finder/source_file_globber.rb', line 71

def source_and_doc_files_glob
  make_source_files_glob(extra_source_files_arr,
                         source_dirs_arr,
                         source_and_doc_file_extensions_glob)
end

#source_files_arrObject



110
111
112
# File 'lib/source_finder/source_file_globber.rb', line 110

def source_files_arr
  @globber.glob(source_files_glob) - exclude_files_arr
end