Class: Bonobot::EnginesFilesRegistry
- Inherits:
-
Object
- Object
- Bonobot::EnginesFilesRegistry
- Includes:
- Configuration, Findable, Outputable, Reloadable
- Defined in:
- lib/bonobot/engines_files_registry.rb
Class Method Summary collapse
- .all ⇒ Object
- .deduplicate(engine_files) ⇒ Object
- .file_pattern ⇒ Object
- .generate ⇒ Object
- .root(path) ⇒ Object
Methods included from Reloadable
Methods included from Outputable
Methods included from Findable
Methods included from Configuration
Class Method Details
.all ⇒ Object
10 11 12 |
# File 'lib/bonobot/engines_files_registry.rb', line 10 def self.all @all ||= deduplicate(generate).reject { |engine_file| configuration.excluded_files.include?(engine_file.short_path) } end |
.deduplicate(engine_files) ⇒ Object
22 23 24 |
# File 'lib/bonobot/engines_files_registry.rb', line 22 def self.deduplicate(engine_files) engine_files.group_by(&:path).map { |_, files| files.min_by(&:engine_name) } end |
.file_pattern ⇒ Object
30 31 32 |
# File 'lib/bonobot/engines_files_registry.rb', line 30 def self.file_pattern configuration.files_pattern end |
.generate ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/bonobot/engines_files_registry.rb', line 14 def self.generate Parallel.flat_map(::Rails::Engine.subclasses) do |klass| Dir.glob(root(klass.instance.root).join("**", "*.#{file_pattern}")).map do |path| EngineFile.new(path, klass) end end end |
.root(path) ⇒ Object
26 27 28 |
# File 'lib/bonobot/engines_files_registry.rb', line 26 def self.root(path) Pathname.new(path).join(configuration.included_dirs) end |