Class: Zeus::LoadTracking
- Inherits:
-
Object
- Object
- Zeus::LoadTracking
- Defined in:
- lib/zeus/load_tracking.rb
Class Method Summary collapse
- .add_feature(file) ⇒ Object
-
.clear_feature_pipe ⇒ Object
Internal: This should only be called by Zeus code.
-
.set_feature_pipe(feature_pipe) ⇒ Object
Internal: This should only be called by Zeus code.
-
.track_features_loaded_by ⇒ Object
Internal: This should only be called by Zeus code.
Class Method Details
.add_feature(file) ⇒ Object
4 5 6 7 8 |
# File 'lib/zeus/load_tracking.rb', line 4 def add_feature(file) full_path = File.(file) return unless File.exist?(full_path) && @feature_pipe notify_features([full_path]) end |
.clear_feature_pipe ⇒ Object
Internal: This should only be called by Zeus code
47 48 49 50 51 |
# File 'lib/zeus/load_tracking.rb', line 47 def clear_feature_pipe @feature_pipe.close @feature_pipe = nil @feature_mutex = nil end |
.set_feature_pipe(feature_pipe) ⇒ Object
Internal: This should only be called by Zeus code
41 42 43 44 |
# File 'lib/zeus/load_tracking.rb', line 41 def set_feature_pipe(feature_pipe) @feature_mutex = Mutex.new @feature_pipe = feature_pipe end |
.track_features_loaded_by ⇒ Object
Internal: This should only be called by Zeus code
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/zeus/load_tracking.rb', line 11 def track_features_loaded_by old_features = $LOADED_FEATURES.dup # Catch exceptions so we can determine the features # that were being loaded at the time of the exception. err_features = [] begin yield rescue SyntaxError => err # SyntaxErrors are a bit weird in that the file containing # the error is not in the backtrace, only the error message. match = /\A([^:]+):\d+: syntax error/.match(err.) err_features << match[1] if match raise rescue ScriptError => err raise rescue => err raise ensure if err && err.backtrace err_features += err.backtrace.map { |b| b.split(':').first } .select { |f| f.start_with?('/') } .take_while { |f| f != __FILE__ } end notify_features(Set.new($LOADED_FEATURES) + err_features - old_features) end end |