Module: RapperLite::Config

Included in:
Engine
Defined in:
lib/rapper_lite/config.rb

Instance Method Summary collapse

Instance Method Details

#compress?(type) ⇒ Boolean

True if we should compress files of the given type.

Returns:

  • (Boolean)


14
15
16
# File 'lib/rapper_lite/config.rb', line 14

def compress?( type )
  self.config_or_default( "compress", type, false )
end

#destination(type) ⇒ Object

Destination path for files of the given type.



9
10
11
# File 'lib/rapper_lite/config.rb', line 9

def destination( type )
  self.config_or_default( "destination", type, "." )
end

#destination_path(type, name) ⇒ Object



45
46
47
# File 'lib/rapper_lite/config.rb', line 45

def destination_path( type, name )
  File.join( self.destination( type ), "#{name}.#{type}" )
end

#file_paths(type, name) ⇒ Object

Array of source files for the given asset package.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/rapper_lite/config.rb', line 28

def file_paths( type, name )
  @definitions[type][name]["files"].map do |file|
    if file[0] == "+"
      # Include other asset package
      self.file_paths( type, file[1..-1] )
    elsif type == :js
      coffee_path = File.join( self.root( type ), "#{file}.coffee" )
      js_path = File.join( self.root( type ), "#{file}.js" )
      File.exists?( coffee_path ) ? coffee_path : js_path
    else # CSS
      sass_path = File.join( self.root( type ), "#{file}.sass" )
      css_path = File.join( self.root( type ), "#{file}.css" )
      File.exists?( sass_path ) ? sass_path : css_path
    end
  end.flatten
end

#root(type) ⇒ Object

Source path for files of the given type.



4
5
6
# File 'lib/rapper_lite/config.rb', line 4

def root( type )
  self.config_or_default( "root", type, "." )
end

#yui_configObject



18
19
20
21
22
23
24
25
# File 'lib/rapper_lite/config.rb', line 18

def yui_config
  @yui_config ||= {
    "line_break" => 2000,
    "munge" => false,
    "optimize" => true,
    "preserve_semicolons" => false
  }.merge( @config["yui_compressor"] || {} )
end