Module: Moult::Discovery
- Defined in:
- lib/moult/discovery.rb
Overview
Finds the Ruby files to analyse under a root directory.
Inside a git repository we use git ls-files so .gitignore is respected for
free (vendored and generated code is excluded as the repo intends).
Otherwise we glob, explicitly skipping the usual non-source directories.
Constant Summary collapse
- SKIP_DIRS =
%w[vendor tmp node_modules .git].freeze
Class Method Summary collapse
- .from_git(root) ⇒ Object
- .from_glob(root) ⇒ Object
-
.ruby_files(root) ⇒ Array<String>
Absolute paths to .rb files, sorted.
- .skip?(abs, root) ⇒ Boolean
Class Method Details
.from_git(root) ⇒ Object
23 24 25 26 27 |
# File 'lib/moult/discovery.rb', line 23 def from_git(root) Git.listed_files(root) .select { |rel| rel.end_with?(".rb") } .map { |rel| File.join(root, rel) } end |
.from_glob(root) ⇒ Object
29 30 31 |
# File 'lib/moult/discovery.rb', line 29 def from_glob(root) Dir.glob(File.join(root, "**", "*.rb")).reject { |abs| skip?(abs, root) } end |