Class: Sandals::CodeReloader
- Inherits:
-
Object
- Object
- Sandals::CodeReloader
- Defined in:
- lib/sandals/code_reloader.rb
Defined Under Namespace
Classes: Result
Constant Summary collapse
- ANSI_ESCAPE =
/\e\[[0-9;]*m/
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #check ⇒ Object
-
#initialize(path) ⇒ CodeReloader
constructor
A new instance of CodeReloader.
Constructor Details
#initialize(path) ⇒ CodeReloader
Returns a new instance of CodeReloader.
11 12 13 14 15 16 17 |
# File 'lib/sandals/code_reloader.rb', line 11 def initialize(path) @path = File.(path) @signature = signature @version = 1 @error = nil @mutex = Mutex.new end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
9 10 11 |
# File 'lib/sandals/code_reloader.rb', line 9 def path @path end |
Instance Method Details
#check ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/sandals/code_reloader.rb', line 19 def check @mutex.synchronize do current_signature = signature return result unless current_signature != @signature @signature = current_signature application = Sandals.load(path) @version += 1 @error = nil Result.new(@version, application, nil, true) rescue SyntaxError, LoadError, StandardError => error @error = error_details(error) result(changed: true) end end |