This repository was archived by the owner on Feb 5, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 237
/
Copy pathpatternfly-sass.rb
92 lines (72 loc) · 1.93 KB
/
patternfly-sass.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
require 'patternfly-sass/version'
module Patternfly
class << self
# Inspired by Kaminari
def load!
register_compass_extension if compass?
if rails?
register_rails_engine
elsif sprockets?
register_sprockets
end
configure_sass
end
# Paths
def gem_path
@gem_path ||= File.expand_path '..', File.dirname(__FILE__)
end
def stylesheets_path
File.join assets_path, 'sass'
end
def fonts_path
File.join assets_path, 'fonts'
end
def javascripts_path
File.join assets_path, 'js'
end
def images_path
File.join assets_path, 'img'
end
def assets_path
@assets_path ||= File.join gem_path, 'dist'
end
# Environment detection helpers
def sprockets?
defined?(::Sprockets)
end
def compass?
defined?(::Compass)
end
def rails?
defined?(::Rails)
end
private
def configure_sass
require 'sassc'
::SassC.load_paths << stylesheets_path
# bootstrap requires minimum precision of 8, see https://github.com/twbs/bootstrap-sass/issues/409
::SassC::Script::Value::Number.precision = [8, ::SassC::Script::Value::Number.precision].max
end
def register_compass_extension
::Compass::Frameworks.register(
'patternfly',
:version => Patternfly::VERSION,
:path => gem_path,
:stylesheets_directory => stylesheets_path,
:templates_directory => File.join(gem_path, 'templates')
)
end
def register_rails_engine
require 'bootstrap-sass'
require 'font-awesome-sass'
require 'patternfly-sass/engine'
end
def register_sprockets
Sprockets.append_path(stylesheets_path)
Sprockets.append_path(fonts_path)
Sprockets.append_path(javascripts_path)
Sprockets.append_path(images_path)
end
end
end
Patternfly.load!