Last active
August 29, 2015 13:57
-
-
Save JavascriptMick/9484085 to your computer and use it in GitHub Desktop.
poc using registry to look at files existing as @ listen
This file contains hidden or 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
Michaels-MacBook-Pro:hackify_ruby michael$ bundle exec ruby poc.rb | |
b.js | |
subfolder | |
a.js | |
^Cpoc.rb:16:in `sleep': Interrupt | |
from poc.rb:16:in `<main>' | |
Michaels-MacBook-Pro:hackify_ruby michael$ bundle exec ruby poc.rb | |
fiddleWithAsync.js | |
^Cpoc.rb:16:in `sleep': Interrupt | |
from poc.rb:16:in `<main>' | |
Michaels-MacBook-Pro:hackify_ruby michael$ bundle exec ruby poc.rb | |
TODO.txt | |
^Cpoc.rb:16:in `sleep': Interrupt | |
from poc.rb:16:in `<main>' | |
This file contains hidden or 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
Michaels-MacBook-Pro:hackify_ruby michael$ bundle exec ruby poc.rb | |
subfolder | |
a.js | |
fiddleWithAsync.js | |
TODO.txt | |
z.css | |
z.js | |
b.js | |
^Cpoc.rb:18:in `sleep': Interrupt | |
from poc.rb:18:in `<main>' | |
Michaels-MacBook-Pro:hackify_ruby michael$ bundle exec ruby poc.rb | |
subfolder | |
b.js | |
fiddleWithAsync.js | |
TODO.txt | |
z.css | |
z.js | |
a.js | |
^Cpoc.rb:18:in `sleep': Interrupt | |
from poc.rb:18:in `<main>' | |
Michaels-MacBook-Pro:hackify_ruby michael$ |
This file contains hidden or 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
Michaels-MacBook-Pro:hackify_ruby michael$ bundle exec ruby poc.rb | |
a.js | |
b.js | |
fiddleWithAsync.js | |
TODO.txt | |
z.js | |
subfolder |
This file contains hidden or 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 'listen' | |
listener = Listen.to("/Users/michael/Workspace/temp/sharetest", ignore: [/\.csxs$/] ) do |modified, added, removed| | |
# etc | |
end | |
listener.start # not blocking | |
listener.registry[:record].dir_entries("/Users/michael/Workspace/temp/sharetest").each do |record| | |
puts record[0] | |
end | |
sleep |
This file contains hidden or 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 'listen' | |
require 'waitutil' | |
listener = Listen.to("/Users/michael/Workspace/temp/sharetest", ignore: [/\.csxs$/] ) do |modified, added, removed| | |
# etc | |
end | |
listener.start # not blocking | |
WaitUtil.wait_for_condition(listener.listen?, :timeout_sec => 30,:delay_sec => 0.5) do | |
listener.registry[:record].dir_entries("/Users/michael/Workspace/temp/sharetest").each do |record| | |
puts record[0] | |
end | |
end | |
sleep |
This file contains hidden or 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 'listen' | |
require 'waitutil' | |
listener = Listen.to("/Users/michael/Workspace/temp/sharetest", ignore: [/\.csxs$/] ) do |modified, added, removed| | |
# etc | |
end | |
listener.start # not blocking | |
sleep(1) | |
WaitUtil.wait_for_condition(listener.listen?, :timeout_sec => 30,:delay_sec => 0.5) do | |
listener.registry[:record].dir_entries("/Users/michael/Workspace/temp/sharetest").each do |record| | |
puts record[0] | |
end | |
end | |
sleep |
This file contains hidden or 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
# This approach does work as long as you use listen >= 2.7.6 | |
require 'listen' | |
require 'waitutil' | |
listener = Listen.to("/Users/michael/Workspace/temp/sharetest", ignore: [/\.css$/] ) do |modified, added, removed| | |
# etc | |
puts "something happenned" | |
end | |
listener.start # not blocking | |
listener.pause | |
listener.registry[:record].dir_entries("/Users/michael/Workspace/temp/sharetest", nil).each do |record| | |
# need to manually apply inore because the registry list is pre-ignore | |
unless /\.css$/.match(record[0]) | |
puts record[0] | |
end | |
end | |
listener.unpause | |
sleep |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment