Sha256: 954067b65eee114b25f5ef3ff2823025b113616450b064b5f20b008cbc268605

Contents?: true

Size: 1.22 KB

Versions: 9

Compression:

Stored size: 1.22 KB

Contents

module RailsAdmin
  module Bootstrap
    class FrameworkNotFound < StandardError; end

    # Inspired by Kaminari
    def self.load!
      if compass?
        require 'rails_admin/bootstrap-sass/compass_functions'
        register_compass_extension
      elsif asset_pipeline?
        require 'rails_admin/bootstrap-sass/sass_functions'
      end

      require 'sass-rails' if rails?

      unless rails? || compass?
        raise(Bootstrap::FrameworkNotFound.new('bootstrap-sass requires either Rails > 3.1 or Compass, neither of which are loaded'))
      end

      stylesheets = File.expand_path(File.join('..', 'vendor', 'assets', 'stylesheets'))
      ::Sass.load_paths << stylesheets
    end

    def self.asset_pipeline?
      defined?(::Sprockets)
    end

    def self.compass?
      defined?(::Compass)
    end

    def self.rails?
      defined?(::Rails)
    end

    def self.register_compass_extension
      base = File.join(File.dirname(__FILE__), '..')
      styles = File.join(base, 'vendor', 'assets', 'stylesheets')
      templates = File.join(base, 'templates')
      ::Compass::Frameworks.register('bootstrap', path: base, stylesheets_directory: styles, templates_directory: templates)
    end
  end
end

RailsAdmin::Bootstrap.load!

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rails_admin-1.4.3 lib/rails_admin/bootstrap-sass.rb
rails_admin-1.4.2 lib/rails_admin/bootstrap-sass.rb
rails_admin-1.4.1 lib/rails_admin/bootstrap-sass.rb
rails_admin-1.4.0 lib/rails_admin/bootstrap-sass.rb
rails_admin-1.3.0 lib/rails_admin/bootstrap-sass.rb
rails_admin-1.2.0 lib/rails_admin/bootstrap-sass.rb
rails_admin-1.1.1 lib/rails_admin/bootstrap-sass.rb
rails_admin-1.1.0 lib/rails_admin/bootstrap-sass.rb
rails_admin-1.0.0 lib/rails_admin/bootstrap-sass.rb