Class: Compass::Installers::ManifestInstaller

Inherits:
Base
  • Object
show all
Defined in:
lib/compass/installers/manifest_installer.rb,
lib/compass/app_integration/stand_alone/installer.rb

Direct Known Subclasses

AppIntegration::StandAlone::Installer

Instance Attribute Summary collapse

Attributes inherited from Base

#options, #target_path, #template_path, #working_path

Attributes included from Actions

#logger

Instance Method Summary collapse

Methods inherited from Base

#compilation_required?, #finalize, #install_directory, #install_html, #install_html_without_haml, #install_stylesheet, installer, #pattern_name_as_dir, #prepare, #run, #targetize, #templatize

Methods included from Actions

#basename, #copy, #directory, #log_action, #process_erb, #relativize, #remove, #separate, #strip_trailing_separator, #write_file

Constructor Details

#initialize(template_path, target_path, options = {}) ⇒ ManifestInstaller

Returns a new instance of ManifestInstaller.



8
9
10
11
# File 'lib/compass/installers/manifest_installer.rb', line 8

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

Instance Attribute Details

#manifestObject

Returns the value of attribute manifest.



6
7
8
# File 'lib/compass/installers/manifest_installer.rb', line 6

def manifest
  @manifest
end

Instance Method Details

#initObject

Initializes the project to work with compass



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/compass/installers/manifest_installer.rb', line 18

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

#installObject

The default install method. Calls install_<type> methods in the order specified by the manifest.



37
38
39
40
41
# File 'lib/compass/installers/manifest_installer.rb', line 37

def install
  manifest.each do |entry|
    send("install_#{entry.type}", entry.from, entry.to, entry.options)
  end
end

#manifest_fileObject



13
14
15
# File 'lib/compass/installers/manifest_installer.rb', line 13

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


43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/compass/installers/manifest_installer.rb', line 43

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(/\.s[ac]ss$/,'.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