Class: Browsable::Sources::Base
- Inherits:
-
Object
- Object
- Browsable::Sources::Base
- Defined in:
- lib/browsable/sources/base.rb
Overview
Base class for a file source. A source expands a set of globs (relative to the project root) into a concrete, de-duplicated list of file paths.
Sources only discover files — routing each file to the right analyzer is the orchestrator’s job, done by extension.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#excludes ⇒ Object
readonly
Returns the value of attribute excludes.
-
#globs ⇒ Object
readonly
Returns the value of attribute globs.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #any? ⇒ Boolean
-
#files ⇒ Object
The discovered files: existing, non-excluded, sorted, unique.
-
#initialize(root:, globs:, excludes: []) ⇒ Base
constructor
A new instance of Base.
-
#name ⇒ Object
A short symbol naming this source, used in reports (e.g. :stylesheets).
Constructor Details
Instance Attribute Details
#excludes ⇒ Object (readonly)
Returns the value of attribute excludes.
11 12 13 |
# File 'lib/browsable/sources/base.rb', line 11 def excludes @excludes end |
#globs ⇒ Object (readonly)
Returns the value of attribute globs.
11 12 13 |
# File 'lib/browsable/sources/base.rb', line 11 def globs @globs end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
11 12 13 |
# File 'lib/browsable/sources/base.rb', line 11 def root @root end |
Instance Method Details
#any? ⇒ Boolean
34 |
# File 'lib/browsable/sources/base.rb', line 34 def any? = files.any? |
#files ⇒ Object
The discovered files: existing, non-excluded, sorted, unique.
25 26 27 28 29 30 31 32 |
# File 'lib/browsable/sources/base.rb', line 25 def files globs .flat_map { |glob| Dir.glob(File.join(root, glob), File::FNM_EXTGLOB) } .select { |path| File.file?(path) } .reject { |path| excluded?(path) } .uniq .sort end |
#name ⇒ Object
A short symbol naming this source, used in reports (e.g. :stylesheets).
20 21 22 |
# File 'lib/browsable/sources/base.rb', line 20 def name self.class.name.split("::").last.gsub(/([a-z])([A-Z])/, '\1_\2').downcase.to_sym end |