Class: Bonobot::EnginesFilesRegistry

Inherits:
Object
  • Object
show all
Includes:
Configuration, Findable, Outputable, Reloadable
Defined in:
lib/bonobot/engines_files_registry.rb

Class Method Summary collapse

Methods included from Reloadable

included

Methods included from Outputable

included

Methods included from Findable

included

Methods included from Configuration

included

Class Method Details

.allObject



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_patternObject



30
31
32
# File 'lib/bonobot/engines_files_registry.rb', line 30

def self.file_pattern
  configuration.files_pattern
end

.generateObject



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