Class: SourceFinder::SourceFileGlobber
- Inherits:
-
Object
- Object
- SourceFinder::SourceFileGlobber
- 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
-
#exclude_files_arr ⇒ Object
See README.md for documentation on these configuration parameters.
-
#extra_source_files_arr ⇒ Object
See README.md for documentation on these configuration parameters.
-
#source_dirs_arr ⇒ Object
See README.md for documentation on these configuration parameters.
-
#source_file_extensions_arr ⇒ Object
See README.md for documentation on these configuration parameters.
-
#source_files_exclude_glob ⇒ Object
See README.md for documentation on these configuration parameters.
-
#source_files_glob ⇒ Object
See README.md for documentation on these configuration parameters.
Attributes included from PythonSourceFileGlobber
#extra_python_files_arr, #python_dirs_arr, #python_file_extensions_arr
Attributes included from JsSourceFileGlobber
#extra_js_files_arr, #js_dirs_arr, #js_file_extensions_arr
Attributes included from RubySourceFileGlobber
#extra_ruby_files_arr, #ruby_dirs_arr, #ruby_file_extensions_arr
Instance Method Summary collapse
- #arr2glob(arr) ⇒ Object
- #default_source_file_extensions_arr ⇒ Object
- #default_source_files_exclude_glob ⇒ Object
- #doc_file_extensions_arr ⇒ Object
- #emacs_lockfile?(filename) ⇒ Boolean
- #exclude_garbage(files_arr) ⇒ Object
-
#initialize(globber: Dir) ⇒ SourceFileGlobber
constructor
A new instance of SourceFileGlobber.
- #make_extensions_arr(arr_var, default_arr) ⇒ Object
- #make_files_glob(extra_source_files_arr, dirs_arr, extensions_glob) ⇒ Object
- #source_and_doc_file_extensions_arr ⇒ Object
- #source_and_doc_file_extensions_glob ⇒ Object
- #source_and_doc_files_glob ⇒ Object
- #source_file_extensions_glob ⇒ Object
- #source_files_arr ⇒ Object
Methods included from PythonSourceFileGlobber
#python_file_extensions_glob, #python_files_arr, #python_files_glob
Methods included from JsSourceFileGlobber
#js_file_extensions_glob, #js_files_arr, #js_files_glob
Methods included from RubySourceFileGlobber
#ruby_file_extensions_glob, #ruby_files_arr, #ruby_files_glob
Constructor Details
#initialize(globber: Dir) ⇒ SourceFileGlobber
Returns a new instance of SourceFileGlobber.
18 19 20 |
# File 'lib/source_finder/source_file_globber.rb', line 18 def initialize(globber: Dir) @globber = globber end |
Instance Attribute Details
#exclude_files_arr ⇒ Object
See README.md for documentation on these configuration parameters.
10 11 12 |
# File 'lib/source_finder/source_file_globber.rb', line 10 def exclude_files_arr @exclude_files_arr end |
#extra_source_files_arr ⇒ Object
See README.md for documentation on these configuration parameters.
10 11 12 |
# File 'lib/source_finder/source_file_globber.rb', line 10 def extra_source_files_arr @extra_source_files_arr end |
#source_dirs_arr ⇒ Object
See README.md for documentation on these configuration parameters.
10 11 12 |
# File 'lib/source_finder/source_file_globber.rb', line 10 def source_dirs_arr @source_dirs_arr end |
#source_file_extensions_arr ⇒ Object
See README.md for documentation on these configuration parameters.
10 11 12 |
# File 'lib/source_finder/source_file_globber.rb', line 10 def source_file_extensions_arr @source_file_extensions_arr end |
#source_files_exclude_glob ⇒ Object
See README.md for documentation on these configuration parameters.
10 11 12 |
# File 'lib/source_finder/source_file_globber.rb', line 10 def source_files_exclude_glob @source_files_exclude_glob end |
#source_files_glob ⇒ Object
See README.md for documentation on these configuration parameters.
10 11 12 |
# File 'lib/source_finder/source_file_globber.rb', line 10 def source_files_glob @source_files_glob end |
Instance Method Details
#arr2glob(arr) ⇒ Object
95 96 97 |
# File 'lib/source_finder/source_file_globber.rb', line 95 def arr2glob(arr) !arr.empty? ? "#{arr.join(',')}," : '' end |
#default_source_file_extensions_arr ⇒ Object
56 57 58 |
# File 'lib/source_finder/source_file_globber.rb', line 56 def default_source_file_extensions_arr %w(swift cpp c html java py clj cljs scala yml sh json) end |
#default_source_files_exclude_glob ⇒ Object
33 34 35 |
# File 'lib/source_finder/source_file_globber.rb', line 33 def default_source_files_exclude_glob '**/vendor/**' end |
#doc_file_extensions_arr ⇒ Object
68 69 70 |
# File 'lib/source_finder/source_file_globber.rb', line 68 def doc_file_extensions_arr @doc_file_extensions_arr ||= %w(md) end |
#emacs_lockfile?(filename) ⇒ Boolean
109 110 111 |
# File 'lib/source_finder/source_file_globber.rb', line 109 def emacs_lockfile?(filename) File.basename(filename) =~ /^\.#/ end |
#exclude_garbage(files_arr) ⇒ Object
113 114 115 |
# File 'lib/source_finder/source_file_globber.rb', line 113 def exclude_garbage(files_arr) files_arr.reject { |filename| emacs_lockfile?(filename) }.sort.uniq end |
#make_extensions_arr(arr_var, default_arr) ⇒ Object
105 106 107 |
# File 'lib/source_finder/source_file_globber.rb', line 105 def make_extensions_arr(arr_var, default_arr) arr_var || default_arr end |
#make_files_glob(extra_source_files_arr, dirs_arr, extensions_glob) ⇒ Object
99 100 101 102 103 |
# File 'lib/source_finder/source_file_globber.rb', line 99 def make_files_glob(extra_source_files_arr, dirs_arr, extensions_glob) '{' + arr2glob(extra_source_files_arr) + "{*,.*}.{#{extensions_glob}}," + File.join("{#{dirs_arr.join(',')}}", '**', "{*,.*}.{#{extensions_glob}}") + '}' end |
#source_and_doc_file_extensions_arr ⇒ Object
76 77 78 |
# File 'lib/source_finder/source_file_globber.rb', line 76 def source_and_doc_file_extensions_arr exclude_garbage(doc_file_extensions_arr + source_file_extensions_arr) end |
#source_and_doc_file_extensions_glob ⇒ Object
80 81 82 |
# File 'lib/source_finder/source_file_globber.rb', line 80 def source_and_doc_file_extensions_glob source_and_doc_file_extensions_arr.join(',') end |
#source_and_doc_files_glob ⇒ Object
90 91 92 93 |
# File 'lib/source_finder/source_file_globber.rb', line 90 def source_and_doc_files_glob make_files_glob(extra_source_files_arr, source_dirs_arr, source_and_doc_file_extensions_glob) end |
#source_file_extensions_glob ⇒ Object
72 73 74 |
# File 'lib/source_finder/source_file_globber.rb', line 72 def source_file_extensions_glob source_file_extensions_arr.join(',') end |
#source_files_arr ⇒ Object
117 118 119 |
# File 'lib/source_finder/source_file_globber.rb', line 117 def source_files_arr exclude_garbage(@globber.glob(source_files_glob) - exclude_files_arr) end |