Pull merge.
[yaffs-website] / vendor / twbs / bootstrap-sass / lib / bootstrap-sass.rb
1 require 'bootstrap-sass/version'
2 module Bootstrap
3   class << self
4     # Inspired by Kaminari
5     def load!
6       register_compass_extension if compass?
7
8       if rails?
9         register_rails_engine
10       elsif lotus?
11         register_lotus
12       elsif sprockets?
13         register_sprockets
14       end
15
16       configure_sass
17     end
18
19     # Paths
20     def gem_path
21       @gem_path ||= File.expand_path '..', File.dirname(__FILE__)
22     end
23
24     def stylesheets_path
25       File.join assets_path, 'stylesheets'
26     end
27
28     def fonts_path
29       File.join assets_path, 'fonts'
30     end
31
32     def javascripts_path
33       File.join assets_path, 'javascripts'
34     end
35
36     def assets_path
37       @assets_path ||= File.join gem_path, 'assets'
38     end
39
40     # Environment detection helpers
41     def sprockets?
42       defined?(::Sprockets)
43     end
44
45     def compass?
46       defined?(::Compass::Frameworks)
47     end
48
49     def rails?
50       defined?(::Rails)
51     end
52
53     def lotus?
54       defined?(::Lotus)
55     end
56
57     private
58
59     def configure_sass
60       require 'sass'
61
62       ::Sass.load_paths << stylesheets_path
63
64       # bootstrap requires minimum precision of 8, see https://github.com/twbs/bootstrap-sass/issues/409
65       ::Sass::Script::Number.precision = [8, ::Sass::Script::Number.precision].max
66     end
67
68     def register_compass_extension
69       ::Compass::Frameworks.register(
70           'bootstrap',
71           :version               => Bootstrap::VERSION,
72           :path                  => gem_path,
73           :stylesheets_directory => stylesheets_path,
74           :templates_directory   => File.join(gem_path, 'templates')
75       )
76     end
77
78     def register_rails_engine
79       require 'bootstrap-sass/engine'
80     end
81
82     def register_lotus
83       Lotus::Assets.sources << assets_path
84     end
85
86     def register_sprockets
87       Sprockets.append_path(stylesheets_path)
88       Sprockets.append_path(fonts_path)
89       Sprockets.append_path(javascripts_path)
90     end
91   end
92 end
93
94 Bootstrap.load!