From c9f5e9d0650f31952fca04a09d4e20f4e80e58cf Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Fri, 5 Aug 2016 19:00:52 -0300 Subject: [PATCH] Fix rails usage --- lib/vital.rb | 12 +++++++++++- lib/vital/engine.rb | 10 ++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 lib/vital/engine.rb diff --git a/lib/vital.rb b/lib/vital.rb index 9097222..18d63cb 100644 --- a/lib/vital.rb +++ b/lib/vital.rb @@ -6,7 +6,9 @@ class << self def load! register_compass_extension if compass? - if sprockets? + if rails? + register_rails_engine + elsif sprockets? register_sprockets end @@ -23,6 +25,10 @@ def sass_path end # Environment detection helpers + def rails? + defined?(::Rails) + end + def sprockets? defined?(::Sprockets) end @@ -41,6 +47,10 @@ def configure_sass def register_sprockets Sprockets.append_path(sass_path) end + + def register_rails_engine + require 'vital/engine' + end end end diff --git a/lib/vital/engine.rb b/lib/vital/engine.rb new file mode 100644 index 0000000..227eb66 --- /dev/null +++ b/lib/vital/engine.rb @@ -0,0 +1,10 @@ +module Vital + class Engine < ::Rails::Engine + isolate_namespace Vital + + initializer 'vital.assets' do |app| + app.config.assets.paths << "#{Vital.gem_path}/fonts" + app.config.assets.precompile += %w( icons.* ) + end + end +end