Sha256: af91bbc071e337731af8485da003ce2fd16998362469735a87f2430f742b505a

Contents?: true

Size: 1.29 KB

Versions: 6

Compression:

Stored size: 1.29 KB

Contents

module Bootstrap
  class FrameworkNotFound < StandardError; end

  # Inspired by Kaminari
  def self.load!
    if compass? && asset_pipeline?
      register_compass_extension
      register_rails_engine
    elsif compass?
      # Only require compass extension if a standalone project
      require 'querobolsa-bootstrap-sass/compass_functions'
      register_compass_extension
    elsif asset_pipeline?
      require 'sass-rails' # See: https://github.com/thomas-mcdonald/bootstrap-sass/pull/4
      register_rails_engine
      require 'querobolsa-bootstrap-sass/rails_functions'
    else
      raise Bootstrap::FrameworkNotFound, "bootstrap-sass requires either Rails > 3.1 or Compass, neither of which are loaded"
    end
  end

  private
  def self.asset_pipeline?
    defined?(::Rails) && ::Rails.version >= '3.1.0'
  end

  def self.compass?
    defined?(::Compass)
  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('querobolsa-bootstrap', :stylesheets_directory => styles, :templates_directory => templates)
  end

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

Bootstrap.load!

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
querobolsa-bootstrap-sass-0.2.4 lib/querobolsa-bootstrap-sass.rb
querobolsa-bootstrap-sass-0.2.3 lib/querobolsa-bootstrap-sass.rb
querobolsa-bootstrap-sass-0.2.2 lib/querobolsa-bootstrap-sass.rb
querobolsa-bootstrap-sass-0.2.1 lib/querobolsa-bootstrap-sass.rb
querobolsa-bootstrap-sass-0.2 lib/querobolsa-bootstrap-sass.rb
querobolsa-bootstrap-sass-0.1.0 lib/querobolsa-bootstrap-sass.rb