Git Product home page Git Product logo

Comments (3)

ttilley avatar ttilley commented on August 28, 2024

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.

mybuddymichael avatar mybuddymichael commented on August 28, 2024

Thanks. My Ruby skills are crap so I'm trying to figure out this stuff on my own for now.

from fssm.

ttilley avatar ttilley commented on August 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.