Module: Bootstrap

Defined in:
lib/bootstrap.rb,
lib/bootstrap/engine.rb,
lib/bootstrap/version.rb

Defined Under Namespace

Modules: Rails

Constant Summary collapse

VERSION =
'5.2.0'
BOOTSTRAP_SHA =
'edf9c40956d19e6ab3f9151bfe0dfac6be06fa21'

Class Method Summary collapse

Class Method Details

.assets_pathObject


41
42
43
# File 'lib/bootstrap.rb', line 41

def assets_path
  @assets_path ||= File.join gem_path, 'assets'
end

.gem_pathObject

Paths


29
30
31
# File 'lib/bootstrap.rb', line 29

def gem_path
  @gem_path ||= File.expand_path '..', File.dirname(__FILE__)
end

.hanami?Boolean

Returns:

  • (Boolean)

54
55
56
# File 'lib/bootstrap.rb', line 54

def hanami?
  defined?(::Hanami)
end

.javascripts_pathObject


37
38
39
# File 'lib/bootstrap.rb', line 37

def javascripts_path
  File.join assets_path, 'javascripts'
end

.load!Object

Inspired by Kaminari


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

def load!
  if rails?
    register_rails_engine
  elsif hanami?
    register_hanami
  elsif sprockets?
    register_sprockets
  elsif defined?(::Sass) && ::Sass.respond_to?(:load_paths)
    # The deprecated `sass` gem:
    ::Sass.load_paths << stylesheets_path
  end

  if defined?(::Sass::Script::Value::Number)
    # Set precision to 6 as per:
    # https://github.com/twbs/bootstrap/blob/da717b03e6e72d7a61c007acb9223b9626ae5ee5/package.json#L28
    ::Sass::Script::Value::Number.precision = [6, ::Sass::Script::Value::Number.precision].max
  end
end

.rails?Boolean

Returns:

  • (Boolean)

50
51
52
# File 'lib/bootstrap.rb', line 50

def rails?
  defined?(::Rails)
end

.sprockets?Boolean

Environment detection helpers

Returns:

  • (Boolean)

46
47
48
# File 'lib/bootstrap.rb', line 46

def sprockets?
  defined?(::Sprockets)
end

.stylesheets_pathObject


33
34
35
# File 'lib/bootstrap.rb', line 33

def stylesheets_path
  File.join assets_path, 'stylesheets'
end