All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gems.compass-1.0.3.lib.compass.installers.manifest_installer.rb Maven / Gradle / Ivy

There is a newer version: 3.7.2
Show newest version
module Compass
  module Installers

    class ManifestInstaller < Base

      attr_accessor :manifest

      def initialize(template_path, target_path, options = {})
        super
        @manifest = Manifest.new(manifest_file, options) if template_path
      end

      def manifest_file
        @manifest_file ||= File.join(template_path, "manifest.rb")
      end

      # Initializes the project to work with compass
      def init
        dirs = manifest.map do |entry|
          unless entry.type == :directory
            loc = send("install_location_for_#{entry.type}", entry.to, entry.options)
            File.dirname(loc)
          end
        end.compact

        if manifest.has_stylesheet?
          dirs << sass_dir
          dirs << css_dir
        end

        dirs.uniq.sort.each do |dir|
          directory targetize(dir)
        end
      end

      # The default install method. Calls install_ methods in the order specified by the manifest.
      def install
        manifest.each do |entry|
          send("install_#{entry.type}", entry.from, entry.to, entry.options)
        end
      end

      def stylesheet_links
        html = "\n"
        manifest.each_stylesheet do |stylesheet|
          # Skip partials.
          next if File.basename(stylesheet.from)[0..0] == "_"
          media = if stylesheet.options[:media]
            %Q{ media="#{stylesheet.options[:media]}"}
          end
          ss_line = %Q{  }
          if stylesheet.options[:condition]
            ss_line = "  "
          end
          html << ss_line + "\n"
        end
        html << ""
      end
    end
  end
end




© 2015 - 2025 Weber Informatics LLC | Privacy Policy