Sha256: f2d46b97733f5736ae78ce0c3bd44dbdba2bf1367b359cc7ed9bf3a971c0a944

Contents?: true

Size: 1.46 KB

Versions: 4

Compression:

Stored size: 1.46 KB

Contents

module Rack::Less
  
  # Handles configuration for Rack::Less
  # Available config settings:
  # :cache
  #   whether to cache the compilation output to
  #   a corresponding static file. Also determines
  #   what value config#combinations(:key) returns
  # :compress
  #   whether to remove extraneous whitespace from
  #   compilation output
  # :combinations
  #   Rack::Less uses combinations as directives for
  #   combining the output of many stylesheets and
  #   serving them as a single resource.  Combinations
  #   are defined using a hash, where the key is the
  #   resource name and the value is an array of
  #   names specifying the stylesheets to combine
  #   as that resource.  For example:
  #     Rack::Less.config.combinations = {
  #       'web'    => ['reset', 'common', 'app_web'],
  #       'mobile' => ['reset', 'iui', 'common', 'app_mobile']
  #     }
  class Config
    
    ATTRIBUTES = [:cache, :compress, :combinations]
    attr_accessor *ATTRIBUTES
    
    DEFAULTS = {
      :cache        => false,
      :compress     => false,
      :combinations => {}
    }

    def initialize(settings={})
      ATTRIBUTES.each do |a|
        instance_variable_set("@#{a}", settings[a] || DEFAULTS[a])
      end
    end
    
    def cache?
      !!@cache
    end
    
    def compress?
      !!@compress
    end
    
    def combinations(key=nil)
      if key.nil?
        @combinations
      else
        cache? ? key : @combinations[key]
      end
    end
    
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rack-less-1.2.1 lib/rack/less/config.rb
rack-less-1.2.0 lib/rack/less/config.rb
rack-less-1.1.1 lib/rack/less/config.rb
rack-less-1.1.0 lib/rack/less/config.rb