Class: Querly::ScriptEnumerator
- Inherits:
-
Object
- Object
- Querly::ScriptEnumerator
- Defined in:
- lib/querly/script_enumerator.rb
Instance Attribute Summary collapse
-
#paths ⇒ Object
readonly
Returns the value of attribute paths.
-
#preprocessors ⇒ Object
readonly
Returns the value of attribute preprocessors.
Class Method Summary collapse
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize(paths:, preprocessors: {}) ⇒ ScriptEnumerator
constructor
A new instance of ScriptEnumerator.
Constructor Details
#initialize(paths:, preprocessors: {}) ⇒ ScriptEnumerator
Returns a new instance of ScriptEnumerator.
6 7 8 9 |
# File 'lib/querly/script_enumerator.rb', line 6 def initialize(paths:, preprocessors: {}) @paths = paths @preprocessors = preprocessors end |
Instance Attribute Details
#paths ⇒ Object (readonly)
Returns the value of attribute paths.
3 4 5 |
# File 'lib/querly/script_enumerator.rb', line 3 def paths @paths end |
#preprocessors ⇒ Object (readonly)
Returns the value of attribute preprocessors.
4 5 6 |
# File 'lib/querly/script_enumerator.rb', line 4 def preprocessors @preprocessors end |
Class Method Details
.find_loader(path) ⇒ Object
32 33 34 35 |
# File 'lib/querly/script_enumerator.rb', line 32 def self.find_loader(path) basename = path.basename.to_s @loaders.find {|pair| pair.first === basename }&.last end |
.register_loader(pattern, loader) ⇒ Object
28 29 30 |
# File 'lib/querly/script_enumerator.rb', line 28 def self.register_loader(pattern, loader) @loaders << [pattern, loader] end |
Instance Method Details
#each(&block) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/querly/script_enumerator.rb', line 11 def each(&block) if block_given? paths.each do |path| case when path.file? load_script_from_path path, &block when path.directory? enumerate_files_in_dir(path, &block) end end else self.enum_for :each end end |