Sha256: 7eb1929823bd684491b456c996bc968e0d22a09650fc749ad98c36ebc100e5ca

Contents?: true

Size: 1.27 KB

Versions: 2

Compression:

Stored size: 1.27 KB

Contents

require 'rails'
require 'rails/railtie'
require 'rails/active_sprites'
require 'active_assets/active_sprites'

module ActiveAssets
  module ActiveSprites
    class Railtie < Rails::Railtie
      config.active_sprites = ActiveSupport::OrderedOptions.new

      rake_tasks do
        ActiveAssets::ActiveSprites.define_tasks
      end

      initializer 'active_sprites-extend-application' do
        Rails.application.extend(Rails::ActiveSprites)
      end

      initializer 'active_sprites-load-definitons' do
        Rails.application.config.paths.config.paths.each {|config_path| load_sprite_definition(config_path) }
        if config.active_sprites.load_engine_sprite_definitions
          Rails.application.railties.engines.map(&:config).map(&:paths).map(&:config).map(&:paths).each do |config_path|
            load_sprite_definition(config_path)
          end
        end
      end

      initializer 'active_sprites-set-configs' do
        options = config.active_sprites
        ActiveSupport.on_load(:active_sprites) do
          options.each { |k,v| send("#{k}=", v) }
        end
      end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
active_assets-0.3.1 lib/active_assets/active_sprites/railtie.rb
active_assets-0.3.0 lib/active_assets/active_sprites/railtie.rb