Sha256: 95fc0f0dafa2fd9ae0fa950471bfecff2b11e063375f8432b71e16352846ec32

Contents?: true

Size: 1.21 KB

Versions: 3

Compression:

Stored size: 1.21 KB

Contents

module Archetype::SassExtensions::Styleguide

  private

  #
  # keep a registry of styleguide themes
  #
  # *Parameters*:
  # - <tt>theme</tt> {String} the theme to use
  # *Returns*:
  # - {Hash} the theme
  #
  def get_theme(theme)
    if @@styleguide_themes.nil?
      # bind a callback to file save to cleanup the cache if needed
      Compass.configuration.on_stylesheet_saved do |filename|
        ::Archetype::SassExtensions::Styleguide.reset!(filename) unless Compass.configuration.memoize == :aggressive
      end
    end
    @@styleguide_themes ||= {}
    theme_name = helpers.to_str(theme || environment.var('CONFIG_THEME') || Archetype.name)
    key = nil
    begin
      key = environment.options[:css_filename]
    end
    # if we're aggressively memoizing, store everything across the session
    if Compass.configuration.memoize == :aggressive or not key
      styleguide_store = @@styleguide_themes
    #otherwise, just store it per this file instance
    else
      styleguide_store = @@styleguide_themes[key] ||= {}
    end
    theme = styleguide_store[theme_name] ||= {}
    theme[:name] ||= theme_name
    theme[:components] ||= {}
    theme[:extensions] ||= []
    theme[:frozen] ||= Set.new
    return theme
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
archetype-1.0.0.alpha.5 lib/archetype/sass_extensions/functions/styleguide/themes.rb
archetype-1.0.0.alpha.4 lib/archetype/sass_extensions/functions/styleguide/themes.rb
archetype-1.0.0.alpha.3 lib/archetype/sass_extensions/functions/styleguide/themes.rb