Module: RailsStats::PackFinder
Overview
Detects "packs" (packwerk / packs-rails) and "components" (component-based Rails, à la Stephan Hagemann) inside a Rails application so that stats can be reported per pack/component plus a "Core" group for everything else.
A directory is considered a pack when either:
* it contains a `package.yml` file (the packwerk marker), or
* it is a direct child of a `packs/` or `components/` directory and holds
any of the usual code folders (`app`, `lib`, `spec`, `test`).
Nested packs (e.g. packs/a/packs/b) are supported. The root directory
itself is never reported as a pack.
Constant Summary collapse
- CODE_FOLDERS =
%w[app lib spec test].freeze
- PACK_CONTAINERS =
%w[packs components].freeze
- IGNORED_PATH =
Path regex used to filter glob results to skip vendored/generated directories. Built from the shared RailsStats::IGNORED_DIRS list.
%r{/(#{IGNORED_DIRS.map { |dir| Regexp.escape(dir) }.join("|")})/}.freeze
Instance Method Summary collapse
-
#find(root_directory) ⇒ Object
Returns the absolute paths of every detected pack/component, sorted.
Instance Method Details
#find(root_directory) ⇒ Object
Returns the absolute paths of every detected pack/component, sorted.
25 26 27 28 29 30 31 32 33 |
# File 'lib/rails_stats/pack_finder.rb', line 25 def find(root_directory) root = File.absolute_path(root_directory) packs = {} collect_packwerk_packs(root, packs) collect_convention_packs(root, packs) packs.keys.sort end |