Sha256: 11270c98010912c29891bb056f5fe0c146e4edb23362b958ae3fa4a41812af60

Contents?: true

Size: 1.56 KB

Versions: 2

Compression:

Stored size: 1.56 KB

Contents

require 'rails/active_assets'

Rails.application.extend Rails::ActiveAssets

module ActiveAssets
  module ActiveExpansions
    def self.boot!
      if Rails.application.config.active_expansions.respond_to?(:precache_assets)
        Expansions.precache_assets = Rails.application.config.active_expansions.precache_assets
      end

      options = Rails.application.config.active_expansions
      options.each { |k,v| send("#{k}=", v) }

      load_active_expansions(Rails.root)

      Rails.application.expansions.javascripts.register!
      Rails.application.expansions.stylesheets.register!

      if Expansions.precache_assets
        Rails.application.expansions.javascripts.cache!
        Rails.application.expansions.stylesheets.cache!
      end
    end

    private
      def load_active_expansions(root)
        if File.exists?(File.join(root, 'config/assets.rb'))
          load File.join(root, 'config/assets.rb')
        elsif File.directory?(File.join(root, 'config/assets'))
          Dir[File.join(root, 'config/assets/*.rb')].each do |f|
            load f
          end
        end
      end
  end

  module ActiveSprites
    def self.boot!
      if Rails.application.config.active_sprites.respond_to?(:sprite_backend)
        Sprites.sprite_backend = Rails.application.config.active_sprites.sprite_backend
      end

      load_sprite_definition
    end

    private
      def load_sprite_definition
        config_path = File.join(Rails.root, 'config')
        load File.join(config_path, 'sprites.rb') if File.exists?(File.join(config_path, 'sprites.rb'))
      end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
active_assets-0.3.1 test/fixtures/rails_root_23/config/initializers/active_assets.rb
active_assets-0.3.0 test/fixtures/rails_root_23/config/initializers/active_assets.rb