Comments (3)
technically, that second block shouldn't be running at all. so yes, this is either a ruby quirk, backend quirk, or undocumented "feature"... just not in the way you had expected. the end of the monitor block should result in entering a runloop immediately where nothing happens from then on but firing callbacks. in ruby 1.8.x that means only one monitor. in ruby 1.9.x and jruby (in either mode) that means one monitor per thread.
what you want to do instead is use the block parameter form and set up two "paths", each with their own set of callbacks. OR switch your glob to {haml,sass} and dispatch to a generic callback handler that then decides what to do.
Or... well... Have you heard of minuteman? It does static compilation of sites including less, sass, haml, and coffee alongside bundling and compression. If all you want is something that compiles haml and sass, there are an abundance of tools out there that do just that.
from fssm.
Thanks. My Ruby skills are crap so I'm trying to figure out this stuff on my own for now.
from fssm.
Oh man. I freely admit to FSSM being ugly. There are workarounds, ickiness, and my implementation of tree refresh... well, lets be gentle and call it "suboptimal". I'd hope you're not learning ruby from code in FSSM itself. ;)
The best example of having FSSM handle multiple things at once is from compass:
FSSM.monitor do |monitor|
Compass.configuration.sass_load_paths.each do |load_path|
next unless load_path.is_a? String
monitor.path load_path do |path|
path.glob '**/*.s[ac]ss'
path.update &method(:recompile)
path.delete {|base, relative| remove_obsolete_css(base,relative); recompile(base, relative)}
path.create &method(:recompile)
end
end
Compass.configuration.watches.each do |glob, callback|
monitor.path Compass.configuration.project_path do |path|
path.glob glob
path.update do |base, relative|
puts ">>> Change detected to: #{relative}"
callback.call(base, relative)
end
path.create do |base, relative|
puts ">>> New file detected: #{relative}"
callback.call(base, relative)
end
path.delete do |base, relative|
puts ">>> File Removed: #{relative}"
callback.call(base, relative)
end
end
end
end
Note the singular monitor block, but that the "block parameter" form is being used so that there's a way to get at the monitor object as well as objects external to the block. This is extremely non-obvious, and I've recently discovered a major stumbling block for new users, but the parameter-free form does an instance_eval and prevents you from referencing anything that isn't global scope. My idea was to make the simple case as simple as possible, but that has backfired on me as the syntax quirk isn't explained well.
from fssm.
Related Issues (20)
- improve documentation around using FSSM inside an OO class HOT 2
- rb-fsevent backend doesn't work HOT 6
- crazy talk from FSSM on Ubuntu HOT 6
- rb-inotify breaks threads HOT 5
- Incorrect path segments for cygwin path HOT 1
- fssm 0.2.7 fails tests with rb-inotify 0.8.6 installed HOT 5
- "An optimized backend is available for this platform!" HOT 6
- FSSM Crashes for filename changes HOT 3
- Detecting modifications between 2 given times. HOT 3
- Do not alter $LOAD_PATH from library itself HOT 6
- fssm 0.2.8 builds native extension in wrong place HOT 2
- Fssm breaks with jruby HOT 12
- Callback for all changes HOT 1
- Suppress undesired recommendation
- FSSM is essentially dead HOT 1
- License missing from gemspec
- notification instead of polling on windows
- Can FSSM use regular expression to match string not containing a word?
- Please teach me how to monitoring unit test
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fssm.