Class: CodeReloader

Inherits:
Object
  • Object
show all
Defined in:
lib/pry-moves/code_reloader.rb

Instance Method Summary collapse

Constructor Details

#initializeCodeReloader

Returns a new instance of CodeReloader.



3
4
5
6
7
8
# File 'lib/pry-moves/code_reloader.rb', line 3

def initialize
  @timestamps = {}
  traverse_files do |path|
    @timestamps[path] = File.mtime(path)
  end
end

Instance Method Details

#reloadObject



10
11
12
13
14
15
16
17
18
19
# File 'lib/pry-moves/code_reloader.rb', line 10

def reload
  traverse_files do |path|
    if @timestamps[path] != File.mtime(path)
      if reload_file path
        @timestamps[path] = File.mtime(path)
        # Log.info "⚡️ file reloaded #{path}"
      end
    end
  end
end