module BetterStyles

Constants

VERSION

Public Class Methods

assets_path() click to toggle source
# File lib/better_styles.rb, line 31
def assets_path
  @assets_path ||= File.join gem_path, 'assets'
end
fonts_path() click to toggle source
# File lib/better_styles.rb, line 27
def fonts_path
  File.join assets_path, 'fonts'
end
gem_path() click to toggle source

Paths

# File lib/better_styles.rb, line 15
def gem_path
  @gem_path ||= File.expand_path '..', File.dirname(__FILE__)
end
javascripts_path() click to toggle source
# File lib/better_styles.rb, line 23
def javascripts_path
  File.join assets_path, 'javascripts'
end
load!() click to toggle source

Inspired by Kaminari

# File lib/better_styles.rb, line 5
def load!
  if rails?
    register_rails_engine
  elsif sprockets?
    register_sprockets
  end
  configure_sass
end
rails?() click to toggle source
# File lib/better_styles.rb, line 40
def rails?
  defined?(::Rails)
end
sprockets?() click to toggle source

Environment detection helpers

# File lib/better_styles.rb, line 36
def sprockets?
  defined?(::Sprockets)
end
stylesheets_path() click to toggle source
# File lib/better_styles.rb, line 19
def stylesheets_path
  File.join assets_path, 'stylesheets'
end

Private Class Methods

configure_sass() click to toggle source
# File lib/better_styles.rb, line 46
def configure_sass
  require 'sass'
  ::Sass.load_paths << stylesheets_path
end
register_rails_engine() click to toggle source
# File lib/better_styles.rb, line 51
def register_rails_engine
  require 'better_styles/engine'
end
register_sprockets() click to toggle source
# File lib/better_styles.rb, line 55
def register_sprockets
  Sprockets.append_path(stylesheets_path)
  Sprockets.append_path(javascripts_path)
  Sprockets.append_path(fonts_path)
end