Sha256: 09bceab8dd0126db57e5fd73b38c11e9221948dc29e5d1b9e33bd91886f5748c

Contents?: true

Size: 1.65 KB

Versions: 18

Compression:

Stored size: 1.65 KB

Contents

require "rails"
require "rails/active_expansions"
require 'active_support/ordered_options'

module ActiveAssets
  module ActiveExpansions
    class Railtie < Rails::Railtie
      rake_tasks do
        Dir[File.expand_path("../../../tasks/active_expansions/*.rake", __FILE__)].each {|f| load f}
      end

      config.active_expansions = ActiveSupport::OrderedOptions.new

      initializer 'active_expansion-extend-application' do
        Rails.application.extend(Rails::ActiveExpansions)
      end

      initializer 'active_expansions-load-definitons' do
        load_active_assets(Rails.root)
        Rails.application.railties.engines.each {|e| load_active_assets(e.root) }
      end

      initializer 'active_expansions-register' do
        Rails.application.expansions.javascripts.register!
        Rails.application.expansions.stylesheets.register!
      end

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

      initializer 'active_expansions-cache' do
        if Expansions.precache_assets
          Rails.application.expansions.javascripts.cache! and Rails.application.expansions.stylesheets.cache!
        end
      end

      private
        def load_active_assets(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
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
active_assets-1.1.0 lib/active_assets/active_expansions/railtie.rb
active_assets-1.0.2 lib/active_assets/active_expansions/railtie.rb
active_assets-1.0.1 lib/active_assets/active_expansions/railtie.rb
active_assets-1.0.0 lib/active_assets/active_expansions/railtie.rb
active_assets-1.0.0.rc1 lib/active_assets/active_expansions/railtie.rb
active_assets-0.2.8 lib/active_assets/active_expansions/railtie.rb
active_assets-0.2.7 lib/active_assets/active_expansions/railtie.rb
active_assets-0.2.6 lib/active_assets/active_expansions/railtie.rb
active_assets-0.2.5 lib/active_assets/active_expansions/railtie.rb
active_assets-0.2.4 lib/active_assets/active_expansions/railtie.rb
active_assets-0.2.3 lib/active_assets/active_expansions/railtie.rb
active_assets-0.2.2 lib/active_assets/active_expansions/railtie.rb
active_assets-0.2.1 lib/active_assets/active_expansions/railtie.rb
active_assets-0.2.0 lib/active_assets/active_expansions/railtie.rb
active_assets-0.2.0.rc4 lib/active_assets/active_expansions/railtie.rb
active_assets-0.2.0.rc3 lib/active_assets/active_expansions/railtie.rb
active_assets-0.2.0.rc2 lib/active_assets/active_expansions/railtie.rb
active_assets-0.2.0.rc lib/active_assets/active_expansions/railtie.rb