Module: RailsAdmin::Bootstrap

Defined in:
lib/rails_admin/bootstrap-sass.rb

Defined Under Namespace

Classes: FrameworkNotFound

Class Method Summary collapse

Class Method Details

.asset_pipeline?Boolean

Returns:

  • (Boolean)

28
29
30
# File 'lib/rails_admin/bootstrap-sass.rb', line 28

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

.compass?Boolean

Returns:

  • (Boolean)

32
33
34
# File 'lib/rails_admin/bootstrap-sass.rb', line 32

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

.load!Object

Inspired by Kaminari


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rails_admin/bootstrap-sass.rb', line 6

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 'sassc-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

  if defined?(::Sass) && ::Sass.respond_to?(:load_paths)
    stylesheets = File.expand_path(File.join('..', 'vendor', 'assets', 'stylesheets'))
    fonts = File.expand_path(File.join('..', 'vendor', 'assets', 'fonts'))
    ::Sass.load_paths << stylesheets
    ::Sass.load_paths << fonts
  end
end

.rails?Boolean

Returns:

  • (Boolean)

36
37
38
# File 'lib/rails_admin/bootstrap-sass.rb', line 36

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

.register_compass_extensionObject


40
41
42
43
44
45
# File 'lib/rails_admin/bootstrap-sass.rb', line 40

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