class Dasht::Reloader

Attributes

parent[RW]

Public Class Methods

new(parent) click to toggle source
# File lib/dasht/reloader.rb, line 5
def initialize(parent)
  @parent        = parent
  @last_modified = File.mtime($PROGRAM_NAME)
end

Public Instance Methods

changed?() click to toggle source
# File lib/dasht/reloader.rb, line 10
def changed?
  @last_modified != File.mtime($PROGRAM_NAME)
end
run() click to toggle source
# File lib/dasht/reloader.rb, line 14
def run
  Thread.new do
    while true
      unless changed?
        sleep 0.3
        next
      end
      parent.log("Reloading #{$PROGRAM_NAME}...")
      eval(IO.read($PROGRAM_NAME))
      @last_modified = File.mtime($PROGRAM_NAME)
    end
  end
end