Sha256: 5ee05bd8c001c2cc3930f0eb1cb7672db2a941de00ce4d8a822361188686b845

Contents?: true

Size: 564 Bytes

Versions: 10

Compression:

Stored size: 564 Bytes

Contents

module Dasht
  class Reloader
    attr_accessor :parent

    def initialize(parent)
      @parent        = parent
      @last_modified = File.mtime($PROGRAM_NAME)
    end

    def changed?
      @last_modified != File.mtime($PROGRAM_NAME)
    end

    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
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
dasht-0.1.9 lib/dasht/reloader.rb
dasht-0.1.8 lib/dasht/reloader.rb
dasht-0.1.7 lib/dasht/reloader.rb
dasht-0.1.6 lib/dasht/reloader.rb
dasht-0.1.5 lib/dasht/reloader.rb
dasht-0.1.4 lib/dasht/reloader.rb
dasht-0.1.3 lib/dasht/reloader.rb
dasht-0.1.2 lib/dasht/reloader.rb
dasht-0.1.1 lib/dasht/reloader.rb
dasht-0.1.0 lib/dasht/reloader.rb