Sha256: 65814ef5b09851c56d02c0df6298b4ce339806b0639b130bbe6c9bc47485605c

Contents?: true

Size: 893 Bytes

Versions: 2

Compression:

Stored size: 893 Bytes

Contents

require 'rubygems'
require 'haml'
require 'haml/exec'

module Bind
  module Actions
    class RefreshBrowsersHaml
      
      attr_accessor :browsers, :uri
      
      def initialize uri, dest, *browsers
        @uri, @dest, @browsers = uri, dest, browsers
      end
      
      def call file
        build_haml file if haml? file
        build_sass file if sass? file
        @browsers.each { |browser| `open -g -a #{browser} #{uri}` } 
      end
      
      def build_haml file
        opts = Haml::Exec::Haml.new [file.path, File.join(@dest, file.path)]
        opts.parse!
      end
      
      def build_sass file
        opts = Haml::Exec::Sass.new [file.path, File.join(@dest, file.path)]
        opts.parse!
      end
      
      def haml?
        file.path.include? '.haml'
      end
      
      def sass?
        file.path.include? '.sass'
      end
      
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
visionmedia-bind-0.0.6 lib/bind/actions/refresh_browsers_haml.rb
visionmedia-bind-0.0.7 lib/bind/actions/refresh_browsers_haml.rb