Class: Controller
Instance Attribute Summary collapse
-
#listener ⇒ Object
readonly
Returns the value of attribute listener.
Instance Method Summary collapse
- #file_run(pattern, type = nil) ⇒ Object
- #run ⇒ Object
- #run_files(files, type) ⇒ Object
- #stop ⇒ Object
Instance Attribute Details
#listener ⇒ Object (readonly)
Returns the value of attribute listener.
9 10 11 |
# File 'lib/cuco/controller.rb', line 9 def listener @listener end |
Instance Method Details
#file_run(pattern, type = nil) ⇒ Object
42 43 44 45 46 |
# File 'lib/cuco/controller.rb', line 42 def file_run(pattern, type = nil) puts "*** file_run(#{pattern}, #{type})" if debug rules = find_rules(pattern, type) rules.each { |rule| match_run(rule, pattern) } end |
#run ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/cuco/controller.rb', line 11 def run puts "*** Controller.run" if debug @listener = Listen.to(".") do |modified, added, removed| run_files(modified, :modified) run_files(added, :added) end @listener.start puts "*** Listen started" if debug # sleep # fails with Ruby 4.0.0 sleep 24 * 60 * 60 end |
#run_files(files, type) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/cuco/controller.rb', line 31 def run_files(files, type) puts "*** Controller.run_files(#{files}, #{type})" if debug if files.include?(G.scriptname) G.script = Script.new File.read(G.scriptname) return end files.map! { |filename| filename[G.pwd_length + 1..] } files.each { |filename| file_run(filename, type) } end |