Sha256: a3b7b54c63e4e3fdaa2a31c9abb5d411d3d457eaa7075d7acfd2450055b0ae2d

Contents?: true

Size: 1.24 KB

Versions: 7

Compression:

Stored size: 1.24 KB

Contents

module Bootstrap
  class FrameworkNotFound < StandardError; end

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

    if rails?
      require 'sass-rails'
      register_rails_engine
    end

    if !(rails? || compass?)
      raise Bootstrap::FrameworkNotFound, "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

  private
  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

  def self.register_rails_engine
    require 'bootstrap-sass/engine'
  end
end

Bootstrap.load!

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
bootstrap-sass-3.0.0.0.rc2 lib/bootstrap-sass.rb
bootstrap-sass-3.0.0.0.rc lib/bootstrap-sass.rb
bootstrap-sass-2.3.2.2 lib/bootstrap-sass.rb
bootstrap-sass-2.3.2.1 lib/bootstrap-sass.rb
bootstrap-sass-2.3.2.0 lib/bootstrap-sass.rb
bootstrap-sass-2.3.1.3 lib/bootstrap-sass.rb
bootstrap-sass-2.3.1.2 lib/bootstrap-sass.rb