Sha256: 53a1162b36960f8c44169ff31d5cc4bc1b8c92988d6fcb869a38172645372173

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

# stdlib
require "ostruct"


module Jekyll
  module AssetsPlugin
    class Configuration
      DEFAULTS = {
        :dirname  => "assets",
        :sources  => %w{_assets/javascripts _assets/stylesheets _assets/images},
        :compress => { :css => nil, :js => nil }
      }.freeze


      def initialize config = {}
        @data = OpenStruct.new DEFAULTS.merge(config)

        @data.sources  = [ @data.sources ] if @data.sources.is_a? String
        @data.compress = OpenStruct.new @data.compress
        @data.dirname  = @data.dirname.gsub(/^\/+|\/+$/, "")

        # if baseurl not given - autoguess base on dirname
        @data.baseurl ||= "/#{@data.dirname}/".squeeze '/'
      end


      def baseurl
        @data.baseurl.chomp "/"
      end


      def js_compressor
        @data.compress.js ? @data.compress.js.to_sym : false
      end


      def css_compressor
        @data.compress.css ? @data.compress.css.to_sym : false
      end


      def method_missing name, *args, &block
        @data.send name, *args, &block
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jekyll-assets-0.3.1 lib/jekyll/assets_plugin/configuration.rb