Module: AssetBox

Defined in:
lib/asset_box.rb,
lib/asset_box/version.rb,
lib/asset_box/rails/engine.rb,
lib/asset_box/rails/helpers.rb,
lib/asset_box/rails/railtie.rb

Defined Under Namespace

Modules: Rails Classes: Error

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.assets_pathObject



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

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

.compass?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/asset_box.rb', line 30

def compass?
  defined?(::Compass::Frameworks)
end

.fonts_pathObject



42
43
44
# File 'lib/asset_box.rb', line 42

def fonts_path
  File.join(assets_path, 'fonts')
end

.gem_pathObject



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

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

.hanami?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/asset_box.rb', line 58

def hanami?
  defined?(::Hanami)
end

.images_pathObject



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

def images_path
  File.join(assets_path, 'images')
end

.load!Object



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

def load!
  register_compass_extension if compass?

  if rails?
    register_rails_engine
  elsif hanami?
    register_hanami
  elsif sprockets?
    register_sprockets
  elsif defined?(::Sass) && ::Sass.respond_to?(:load_paths)
    ::Sass.load_paths << stylesheets_path
  end

  if defined?(::Sass::Script::Value::Number)
    # bootstrap requires minimum precision of 8, see https://github.com/twbs/bootstrap-sass/issues/409
    ::Sass::Script::Value::Number.precision = [8, ::Sass::Script::Value::Number.precision].max
  end
end

.rails?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/asset_box.rb', line 34

def rails?
  defined?(::Rails)
end

.sprockets?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/asset_box.rb', line 26

def sprockets?
  defined?(::Sprockets)
end

.stylesheets_pathObject



38
39
40
# File 'lib/asset_box.rb', line 38

def stylesheets_path
  File.join(assets_path, 'stylesheets')
end