Class: Compass::Installers::Base
- Inherits:
-
Object
- Object
- Compass::Installers::Base
- Includes:
- Actions
- Defined in:
- lib/compass/installers/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#css_dir ⇒ Object
Returns the value of attribute css_dir.
-
#images_dir ⇒ Object
Returns the value of attribute images_dir.
-
#javascripts_dir ⇒ Object
Returns the value of attribute javascripts_dir.
-
#manifest ⇒ Object
Returns the value of attribute manifest.
-
#options ⇒ Object
Returns the value of attribute options.
-
#sass_dir ⇒ Object
Returns the value of attribute sass_dir.
-
#target_path ⇒ Object
Returns the value of attribute target_path.
-
#template_path ⇒ Object
Returns the value of attribute template_path.
-
#working_path ⇒ Object
Returns the value of attribute working_path.
Attributes included from Actions
Class Method Summary collapse
Instance Method Summary collapse
- #compilation_required? ⇒ Boolean
-
#configure ⇒ Object
The default configure method – it sets up directories from the options and corresponding default_* methods for those not found in the options hash.
- #configure_option_with_default(opt) ⇒ Object
-
#finalize ⇒ Object
The default finalize method – it is a no-op.
-
#init ⇒ Object
Initializes the project to work with compass.
-
#initialize(template_path, target_path, options = {}) ⇒ Base
constructor
A new instance of Base.
-
#install ⇒ Object
The default install method.
- #manifest_file ⇒ Object
-
#prepare ⇒ Object
The default prepare method – it is a no-op.
-
#run(options = {}) ⇒ Object
Runs the installer.
- #stylesheet_links ⇒ Object
-
#targetize(path) ⇒ Object
returns an absolute path given a path relative to the current installation target.
-
#templatize(path) ⇒ Object
returns an absolute path given a path relative to the current template.
Methods included from Actions
#basename, #compile, #copy, #directory, #relativize, #separate, #strip_trailing_separator, #write_file
Constructor Details
#initialize(template_path, target_path, options = {}) ⇒ Base
Returns a new instance of Base.
13 14 15 16 17 18 19 20 21 |
# File 'lib/compass/installers/base.rb', line 13 def initialize(template_path, target_path, = {}) @template_path = template_path @target_path = target_path @working_path = Dir.getwd @options = @manifest = Manifest.new(manifest_file) self.logger = [:logger] configure end |
Instance Attribute Details
#css_dir ⇒ Object
Returns the value of attribute css_dir.
11 12 13 |
# File 'lib/compass/installers/base.rb', line 11 def css_dir @css_dir end |
#images_dir ⇒ Object
Returns the value of attribute images_dir.
11 12 13 |
# File 'lib/compass/installers/base.rb', line 11 def images_dir @images_dir end |
#javascripts_dir ⇒ Object
Returns the value of attribute javascripts_dir.
11 12 13 |
# File 'lib/compass/installers/base.rb', line 11 def javascripts_dir @javascripts_dir end |
#manifest ⇒ Object
Returns the value of attribute manifest.
10 11 12 |
# File 'lib/compass/installers/base.rb', line 10 def manifest @manifest end |
#options ⇒ Object
Returns the value of attribute options.
9 10 11 |
# File 'lib/compass/installers/base.rb', line 9 def @options end |
#sass_dir ⇒ Object
Returns the value of attribute sass_dir.
11 12 13 |
# File 'lib/compass/installers/base.rb', line 11 def sass_dir @sass_dir end |
#target_path ⇒ Object
Returns the value of attribute target_path.
8 9 10 |
# File 'lib/compass/installers/base.rb', line 8 def target_path @target_path end |
#template_path ⇒ Object
Returns the value of attribute template_path.
8 9 10 |
# File 'lib/compass/installers/base.rb', line 8 def template_path @template_path end |
#working_path ⇒ Object
Returns the value of attribute working_path.
8 9 10 |
# File 'lib/compass/installers/base.rb', line 8 def working_path @working_path end |
Class Method Details
.installer(type, &locator) ⇒ Object
84 85 86 87 88 89 90 91 |
# File 'lib/compass/installers/base.rb', line 84 def self.installer(type, &locator) locator ||= lambda{|to| to} loc_method = "install_location_for_#{type}".to_sym define_method loc_method, locator define_method "install_#{type}" do |from, to, | copy templatize(from), targetize(send(loc_method, to)) end end |
Instance Method Details
#compilation_required? ⇒ Boolean
80 81 82 |
# File 'lib/compass/installers/base.rb', line 80 def compilation_required? false end |
#configure ⇒ Object
The default configure method – it sets up directories from the options and corresponding default_* methods for those not found in the options hash. It can be overridden it or augmented for reading config files, prompting the user for more information, etc.
44 45 46 47 48 49 50 51 52 |
# File 'lib/compass/installers/base.rb', line 44 def configure unless @configured [:css_dir, :sass_dir, :images_dir, :javascripts_dir].each do |opt| configure_option_with_default opt end end ensure @configured = true end |
#configure_option_with_default(opt) ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/compass/installers/base.rb', line 59 def configure_option_with_default(opt) value = [opt] value ||= begin default_method = "default_#{opt}".to_sym send(default_method) if respond_to?(default_method) end send("#{opt}=", value) end |
#finalize ⇒ Object
The default finalize method – it is a no-op. This could print out a message or something.
77 78 |
# File 'lib/compass/installers/base.rb', line 77 def finalize end |
#init ⇒ Object
Initializes the project to work with compass
28 29 |
# File 'lib/compass/installers/base.rb', line 28 def init end |
#install ⇒ Object
The default install method. Calls install_<type> methods in the order specified by the manifest.
69 70 71 72 73 |
# File 'lib/compass/installers/base.rb', line 69 def install manifest.each do |entry| send("install_#{entry.type}", entry.from, entry.to, entry.) end end |
#manifest_file ⇒ Object
23 24 25 |
# File 'lib/compass/installers/base.rb', line 23 def manifest_file @manifest_file ||= File.join(template_path, "manifest.rb") end |
#prepare ⇒ Object
The default prepare method – it is a no-op. Generally you would create required directories, etc.
56 57 |
# File 'lib/compass/installers/base.rb', line 56 def prepare end |
#run(options = {}) ⇒ Object
Runs the installer. Every installer must conform to the installation strategy of prepare, install, and then finalize. A default implementation is provided for each step.
34 35 36 37 38 |
# File 'lib/compass/installers/base.rb', line 34 def run( = {}) prepare install finalize unless [:skip_finalization] end |
#stylesheet_links ⇒ Object
119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/compass/installers/base.rb', line 119 def stylesheet_links html = "<head>\n" manifest.each_stylesheet do |stylesheet| media = if stylesheet.[:media] %Q{ media="#{stylesheet.[:media]}"} end ss_line = %Q{ <link href="/stylesheets/#{stylesheet.to.sub(/\.sass$/,'.css')}"#{media} rel="stylesheet" type="text/css" />} if stylesheet.[:ie] ss_line = " <!--[if IE]>\n #{ss_line}\n <![endif]-->" end html << ss_line + "\n" end html << "</head>" end |
#targetize(path) ⇒ Object
returns an absolute path given a path relative to the current installation target. Paths can use unix style “/” and will be corrected for the current platform.
109 110 111 |
# File 'lib/compass/installers/base.rb', line 109 def targetize(path) strip_trailing_separator File.join(target_path, separate(path)) end |
#templatize(path) ⇒ Object
returns an absolute path given a path relative to the current template. Paths can use unix style “/” and will be corrected for the current platform.
115 116 117 |
# File 'lib/compass/installers/base.rb', line 115 def templatize(path) strip_trailing_separator File.join(template_path, separate(path)) end |