Module: Lich::Common::HMR
- Defined in:
- documented/common/hmr.rb
Class Method Summary collapse
-
.clear_cache ⇒ void
Clears the gem load paths cache.
-
.loaded ⇒ Array<String>
Returns an array of loaded Ruby files.
-
.msg(message) ⇒ void
Sends a message to the appropriate output.
-
.reload(pattern) ⇒ void
Reloads files matching the given pattern.
Class Method Details
.clear_cache ⇒ void
This method returns an undefined value.
Clears the gem load paths cache.
10 11 12 |
# File 'documented/common/hmr.rb', line 10 def self.clear_cache Gem.clear_paths end |
.loaded ⇒ Array<String>
Returns an array of loaded Ruby files.
27 28 29 |
# File 'documented/common/hmr.rb', line 27 def self.loaded $LOADED_FEATURES.select { |path| path.end_with?(".rb") } end |
.msg(message) ⇒ void
This method returns an undefined value.
Sends a message to the appropriate output.
If the message contains HTML, it will be handled by the _respond method if defined.
19 20 21 22 23 |
# File 'documented/common/hmr.rb', line 19 def self.msg() return _respond if defined?(:_respond) && .include?("<b>") return respond if defined?(:respond) puts end |
.reload(pattern) ⇒ void
This method returns an undefined value.
Reloads files matching the given pattern.
This method clears the cache and reloads all files that match the provided regex pattern.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'documented/common/hmr.rb', line 37 def self.reload(pattern) self.clear_cache loaded_paths = self.loaded.grep(pattern) unless loaded_paths.empty? loaded_paths.each { |file| begin load(file) self.msg "<b>[lich.hmr] reloaded %s</b>" % file rescue => exception self.msg exception. self.msg exception.backtrace.join("\n") end } else self.msg "<b>[lich.hmr] nothing matching regex pattern: %s</b>" % pattern.source end end |