Class: Textus::Hooks::Loader
- Inherits:
-
Object
- Object
- Textus::Hooks::Loader
- Defined in:
- lib/textus/hooks/loader.rb
Defined Under Namespace
Classes: Dsl
Instance Method Summary collapse
-
#initialize(events:, rpc:) ⇒ Loader
constructor
A new instance of Loader.
- #load_dir(dir) ⇒ Object
Constructor Details
Instance Method Details
#load_dir(dir) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/textus/hooks/loader.rb', line 34 def load_dir(dir) return unless File.directory?(dir) # Discard any leftover blocks from a prior partial load. Textus.drain_hook_blocks Dir.glob(File.join(dir, "**/*.rb")).sort.each do |f| # rubocop:disable Lint/RedundantDirGlobSort load(f) rescue StandardError, ScriptError => e raise UsageError.new("failed loading hook #{File.basename(f)}: #{e.class}: #{e.}") end Textus.drain_hook_blocks.each do |blk| blk.call(@dsl) rescue StandardError, ScriptError => e raise UsageError.new("failed registering hook: #{e.class}: #{e.}") end end |