lib/jruby_art/runners/watch.rb in jruby_art-0.4.0 vs lib/jruby_art/runners/watch.rb in jruby_art-0.4.2
- old
+ new
@@ -1,12 +1,25 @@
require_relative 'base'
+require_relative '../config'
module Processing
+ class WatchException < StandardError
+ end
+
# A sketch loader, observer, and reloader, to tighten
# the feedback between code and effect.
class Watcher
# Sic a new Processing::Watcher on the sketch
+ WATCH_MESSAGE ||= <<-EOS
+ Warning:
+ To protect you from running watch mode in a top level
+ directory with lots of nested ruby or GLSL files we
+ limit the number of files to watch to %d.
+ If you really want to watch %d files you should
+ increase MAX_WATCH in ~/.jruby_art/config.yml
+
+ EOS
SLEEP_TIME = 0.2
def initialize
reload_files_to_watch
@time = Time.now
start_watching
@@ -50,9 +63,14 @@
end
end
def reload_files_to_watch
@files = Dir.glob(File.join(SKETCH_ROOT, '**/*.{rb,glsl}'))
+ count = @files.length
+ max_watch = RP_CONFIG.fetch('MAX_WATCH', 20)
+ return unless count > max_watch
+ warn format(WATCH_MESSAGE, max_watch, count)
+ abort
end
end
end
Processing::Watcher.new