Sha256: 6f0a9ec7241690e1bb189685645b54083abc387d60ff4fe69b2e7aee346f5548

Contents?: true

Size: 1.72 KB

Versions: 28

Compression:

Stored size: 1.72 KB

Contents

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|
          loc = send("install_location_for_#{entry.type}", entry.to, entry.options)
          File.dirname(loc)
        end

        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_<type> 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 = "<head>\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{  <link href="#{http_stylesheets_path}/#{stylesheet.to.sub(/\.sass$/,'.css')}"#{media} rel="stylesheet" type="text/css" />}
          if stylesheet.options[:condition]
            ss_line = "  <!--[if #{stylesheet.options[:condition]}]>\n    #{ss_line}\n  <![endif]-->"
          end
          html << ss_line + "\n"
        end
        html << "</head>"
      end
    end
  end
end

Version data entries

28 entries across 27 versions & 3 rubygems

Version Path
compass-0.10.2 lib/compass/installers/manifest_installer.rb
compass-0.10.1 lib/compass/installers/manifest_installer.rb
compass-0.10.0 lib/compass/installers/manifest_installer.rb
compass-0.10.0.rc6 lib/compass/installers/manifest_installer.rb
compass-0.10.0.rc5 lib/compass/installers/manifest_installer.rb
compass-0.10.0.rc4 lib/compass/installers/manifest_installer.rb
compass-0.10.0.rc3 lib/compass/installers/manifest_installer.rb
compass-0.10.0.rc2 lib/compass/installers/manifest_installer.rb
compass-0.10.0.rc1 lib/compass/installers/manifest_installer.rb
compass-0.10.0.pre9 lib/compass/installers/manifest_installer.rb
compass-0.10.0.pre8 lib/compass/installers/manifest_installer.rb
compass-0.10.0.pre7 lib/compass/installers/manifest_installer.rb
compass-0.10.0.pre6 lib/compass/installers/manifest_installer.rb
middleman-0.13.1 lib/middleman/vendor/gems/ruby/1.9.1/gems/compass-0.10.0.pre4/lib/compass/installers/manifest_installer.rb
middleman-0.13.1 lib/middleman/vendor/gems/ruby/1.8/gems/compass-0.10.0.pre5/lib/compass/installers/manifest_installer.rb
compass-0.10.0.pre5 lib/compass/installers/manifest_installer.rb
compass-0.10.0.pre4 lib/compass/installers/manifest_installer.rb
compass-0.10.0.pre3 lib/compass/installers/manifest_installer.rb
middleman-0.12.2 lib/middleman/vendor/gems/gems/compass-0.10.0.pre2/lib/compass/installers/manifest_installer.rb
middleman-0.12.1 lib/middleman/vendor/gems/gems/compass-0.10.0.pre2/lib/compass/installers/manifest_installer.rb