1 | require 'bootstrap-sass/version'
|
2 | module Bootstrap
|
3 | class << self
|
4 |
|
5 | def load!
|
6 | register_compass_extension if compass?
|
7 | register_rails_engine if rails?
|
8 | configure_sass
|
9 | end
|
10 |
|
11 |
|
12 | def gem_path
|
13 | @gem_path ||= File.expand_path '..', File.dirname(__FILE__)
|
14 | end
|
15 |
|
16 | def stylesheets_path
|
17 | File.join assets_path, 'stylesheets'
|
18 | end
|
19 |
|
20 | def fonts_path
|
21 | File.join assets_path, 'fonts'
|
22 | end
|
23 |
|
24 | def javascripts_path
|
25 | File.join assets_path, 'javascripts'
|
26 | end
|
27 |
|
28 | def assets_path
|
29 | @assets_path ||= File.join gem_path, 'assets'
|
30 | end
|
31 |
|
32 |
|
33 | def asset_pipeline?
|
34 | defined?(::Sprockets)
|
35 | end
|
36 |
|
37 | def compass?
|
38 | defined?(::Compass)
|
39 | end
|
40 |
|
41 | def rails?
|
42 | defined?(::Rails)
|
43 | end
|
44 |
|
45 | private
|
46 |
|
47 | def configure_sass
|
48 | require 'sass'
|
49 |
|
50 | ::Sass.load_paths << stylesheets_path
|
51 |
|
52 |
|
53 | ::Sass::Script::Number.precision = [10, ::Sass::Script::Number.precision].max
|
54 | end
|
55 |
|
56 | def register_compass_extension
|
57 | ::Compass::Frameworks.register(
|
58 | 'bootstrap',
|
59 | :version => Bootstrap::VERSION,
|
60 | :path => gem_path,
|
61 | :stylesheets_directory => stylesheets_path,
|
62 | :templates_directory => File.join(gem_path, 'templates')
|
63 | )
|
64 | end
|
65 |
|
66 | def register_rails_engine
|
67 | require 'bootstrap-sass/engine'
|
68 | end
|
69 | end
|
70 | end
|
71 |
|
72 | Bootstrap.load!
|