Sha256: 31a747192b99cedc8f0bb0c7a098d930b3d97da2865f531dc434a552eb81178c

Contents?: true

Size: 1.19 KB

Versions: 14

Compression:

Stored size: 1.19 KB

Contents

require 'better_styles/version'
module BetterStyles
  class << self
    # Inspired by Kaminari
    def load!
      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, 'stylesheets'
    end

    def javascripts_path
      File.join assets_path, 'javascripts'
    end
    
    def fonts_path
      File.join assets_path, 'fonts'
    end

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

    # Environment detection helpers
    def sprockets?
      defined?(::Sprockets)
    end

    def rails?
      defined?(::Rails)
    end

    private
    
      def configure_sass
        require 'sass'
        ::Sass.load_paths << stylesheets_path
      end
    
      def register_rails_engine
        require 'better_styles/engine'
      end
    
      def register_sprockets
        Sprockets.append_path(stylesheets_path)
        Sprockets.append_path(javascripts_path)
        Sprockets.append_path(fonts_path)
      end
    
  end
end

BetterStyles.load!

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
better_styles-0.0.0.338 lib/better_styles.rb
better_styles-0.0.0.337 lib/better_styles.rb
better_styles-0.0.0.336 lib/better_styles.rb
better_styles-0.0.0.335 lib/better_styles.rb
better_styles-0.0.0.334 lib/better_styles.rb
better_styles-0.0.0.333 lib/better_styles.rb
better_styles-0.0.0.332 lib/better_styles.rb
better_styles-0.0.0.331 lib/better_styles.rb
better_styles-0.0.0.33 lib/better_styles.rb
better_styles-0.0.5 lib/better_styles.rb
better_styles-0.0.4 lib/better_styles.rb
better_styles-0.0.3 lib/better_styles.rb
better_styles-0.0.2 lib/better_styles.rb
better_styles-0.0.1 lib/better_styles.rb