Sha256: 91a3ce2ecf73b4a900b6550db9c5169b8b581d07adabd9583b6bc417f6efd7bb

Contents?: true

Size: 1.09 KB

Versions: 3

Compression:

Stored size: 1.09 KB

Contents

# encoding: utf-8

require 'singleton'

module ClassyAssets
  class Config
    include Singleton

    attr_accessor :asset_debug, :asset_digest, :asset_host, :asset_paths, :asset_prefix, :asset_root
    attr_accessor :asset_compress, :css_compressor, :js_compressor

    def asset_compress
      @asset_compress if defined? @asset_compress
    end

    def css_compressor
      @css_compressor ||= :yui
    end

    def js_compressor
      @js_compressor ||= :uglifier
    end

    def asset_debug
      @asset_debug = (ENV['RACK_ENV'] == 'development') unless defined? @asset_debug
      @asset_debug
    end

    def asset_digest
      @asset_digest if defined? @asset_digest
    end

    def asset_paths
      @asset_paths = build_asset_paths unless defined? @asset_paths
      @asset_paths.uniq!
      @asset_paths
    end

    def asset_prefix
      @asset_prefix ||= 'assets'
    end

    def asset_root
      raise Errors::NilAssetRoot.new if @asset_root.nil?
      @asset_root
    end

    private
    
    def build_asset_paths
      Dir.glob(File.join(asset_root, asset_prefix, '*'))
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
classy_assets-0.7.2 lib/classy_assets/config.rb
classy_assets-0.7.1 lib/classy_assets/config.rb
classy_assets-0.7.0 lib/classy_assets/config.rb