Created
May 24, 2014 10:07
-
-
Save net1957/3c82f1d6afe4a4eea05b to your computer and use it in GitHub Desktop.
Window, ruby 1.9.3 listen and wdm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'bundler' | |
Bundler.setup(:default) # set the load path | |
Bundler.require(:default) # require the gems | |
require 'logger' | |
module Lis | |
extend self | |
def listener | |
Listen.to('xxx', debug: 2, ignore!: /foobar/) do |modified, added, removed| | |
puts "modified absolute path: #{modified}" unless modified.empty? | |
puts "added absolute path: #{added}" unless added.empty? | |
puts "removed absolute path: #{removed}" unless removed.empty? | |
end | |
end | |
def start(listener = listener) | |
puts "env: LISTEN_GEM_DEBUGGING=#{ENV['LISTEN_GEM_DEBUGGING']}" | |
puts 'Listen: Running the monitor...' | |
listener.start | |
puts 'Listen: Started...' | |
sleep 20 | |
rescue Interrupt | |
listener.stop | |
puts 'User Interrupt...' | |
end | |
end | |
module Wdm | |
extend self | |
def listener | |
monitor = WDM::Monitor.new | |
monitor.watch_recursively('D:/Dvlt/ruby/projects/_tmp/listen/xxx') do |change| | |
puts "#{change.type.to_s.upcase}: '#{change.path}'" | |
end | |
monitor | |
end | |
def start(listener = listener) | |
puts 'Wdm: Running the monitor...' | |
thread = Thread.new { listener.run! } | |
sleep 20 | |
rescue Interrupt | |
puts 'User Interrupt...' | |
ensure | |
puts 'Stopping the monitor...' | |
listener.stop | |
thread.join | |
end | |
end | |
Wdm.start if ARGV.include?('w') | |
Lis.start if ARGV.include?('l') | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
# # include at least one source and the gem | |
source 'https://rubygems.org' | |
ruby '1.9.3' | |
require 'rbconfig' | |
gem 'wdm', path: 'D:\Dvlt\ruby\projects\_test\wdm' | |
gem 'celluloid' | |
gem 'listen' , path: 'D:\Dvlt\ruby\projects\_test\listen' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
D:\Dvlt\ruby\projects\_tmp\listen>bundle exec ruby code.rb l | |
[DEBUG] (../../../../ext/wdm/wdm.c@37): Registering WDM with Ruby! | |
[DEBUG] (../../../../ext/wdm/rb_monitor.c@556): Registering WDM::Monitor with Ruby! | |
[DEBUG] (../../../../ext/wdm/rb_change.c@185): Registering WDM::Event with Ruby! | |
I, [2014-05-24T12:00:06.287539 #18388] INFO -- : Celluloid loglevel set to: 0 | |
env: LISTEN_GEM_DEBUGGING=2 | |
Listen: Running the monitor... | |
D, [2014-05-24T12:00:06.299257 #18388] DEBUG -- : Adapter: considering TCP ... | |
D, [2014-05-24T12:00:06.299257 #18388] DEBUG -- : Adapter: considering polling ... | |
D, [2014-05-24T12:00:06.299257 #18388] DEBUG -- : Adapter: considering optimized backend... | |
Listen: Started... | |
D, [2014-05-24T12:00:06.299257 #18388] DEBUG -- : wdm - starting... | |
[DEBUG] (../../../../ext/wdm/rb_monitor.c@105): -------------------------------- | |
[DEBUG] (../../../../ext/wdm/rb_monitor.c@106): Allocating a new monitor object! | |
[DEBUG] (../../../../ext/wdm/rb_monitor.c@107): -------------------------------- | |
D, [2014-05-24T12:00:06.310977 #18388] DEBUG -- : wdm - watching recursively: "D:/Dvlt/ruby/projects/_tmp/listen/xxx" | |
[DEBUG] (../../../../ext/wdm/rb_monitor.c@199): New path to watch: 'D:/Dvlt/ruby/projects/_tmp/listen/xxx' | |
[DEBUG] (../../../../ext/wdm/rb_monitor.c@200): - SK 0 - |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
D:\Dvlt\ruby\projects\_tmp\listen>bundle exec ruby code.rb w | |
[DEBUG] (../../../../ext/wdm/wdm.c@37): Registering WDM with Ruby! | |
[DEBUG] (../../../../ext/wdm/rb_monitor.c@556): Registering WDM::Monitor with Ruby! | |
[DEBUG] (../../../../ext/wdm/rb_change.c@185): Registering WDM::Event with Ruby! | |
[DEBUG] (../../../../ext/wdm/rb_monitor.c@105): -------------------------------- | |
[DEBUG] (../../../../ext/wdm/rb_monitor.c@106): Allocating a new monitor object! | |
[DEBUG] (../../../../ext/wdm/rb_monitor.c@107): -------------------------------- | |
[DEBUG] (../../../../ext/wdm/rb_monitor.c@199): New path to watch: 'D:/Dvlt/ruby/projects/_tmp/listen/xxx' | |
[DEBUG] (../../../../ext/wdm/rb_monitor.c@200): - SK 0 - | |
[DEBUG] (../../../../ext/wdm/utils.c@29): - SK x1 - | |
[DEBUG] (../../../../ext/wdm/utils.c@34): - SK x3 - | |
[DEBUG] (../../../../ext/wdm/utils.c@37): - SK x4 - | |
[DEBUG] (../../../../ext/wdm/utils.c@40): - SK x5 - | |
[DEBUG] (../../../../ext/wdm/utils.c@42): - SK x6 - | |
[DEBUG] (../../../../ext/wdm/utils.c@45): - SK x7 - | |
[DEBUG] (../../../../ext/wdm/utils.c@48): - SK x8 - | |
[DEBUG] (../../../../ext/wdm/rb_monitor.c@204): - SK 1 - | |
[DEBUG] (../../../../ext/wdm/rb_monitor.c@211): - SK 1A - | |
[DEBUG] (../../../../ext/wdm/rb_monitor.c@218): - SK 2 - | |
[DEBUG] (../../../../ext/wdm/rb_monitor.c@221): - SK 3 - | |
[DEBUG] (../../../../ext/wdm/rb_monitor.c@235): - SK 4 - | |
[DEBUG] (../../../../ext/wdm/rb_monitor.c@241): - SK 5 - | |
[DEBUG] (../../../../ext/wdm/rb_monitor.c@246): - SK 6 - | |
[DEBUG] (../../../../ext/wdm/rb_monitor.c@250): Watching directory: 'D:\Dvlt\ruby\projects\_tmp\listen\xxx\' | |
Wdm: Running the monitor... | |
[DEBUG] (../../../../ext/wdm/rb_monitor.c@481): Running the monitor! | |
[DEBUG] (../../../../ext/wdm/rb_monitor.c@348): Starting the monitoring thread! | |
Stopping the monitor... | |
[DEBUG] (../../../../ext/wdm/rb_monitor.c@446): Stopping the monitor! | |
[DEBUG] (../../../../ext/wdm/rb_monitor.c@375): Exiting the monitoring thread! | |
[DEBUG] (../../../../ext/wdm/rb_monitor.c@548): Stopped the monitor! | |
[DEBUG] (../../../../ext/wdm/rb_monitor.c@83): Freeing a monitor object! | |
[DEBUG] (../../../../ext/wdm/rb_monitor.c@446): Stopping the monitor! | |
[DEBUG] (../../../../ext/wdm/rb_monitor.c@458): Can't stop monitoring because it's already stopped (or it's never been started)!! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment