Sha256: b6727856ecb59b1cf64da5b680c6a9c938ba8571f2a6621625b9dc366d20989e

Contents?: true

Size: 1.36 KB

Versions: 3

Compression:

Stored size: 1.36 KB

Contents

module PusherChameleon
  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 images_path
      File.join assets_path, 'images'
    end

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

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

    def rails?
      defined?(::Rails)
      autoload 'VERSION', 'pusher_chameleon/version'
    end

    private

    def configure_sass
      require 'sass'

      ::Sass.load_paths << stylesheets_path

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


    def register_rails_engine
      require 'pusher_chameleon/engine'
    end


    def register_sprockets
      Sprockets.append_path(stylesheets_path)
      Sprockets.append_path(javascripts_path)
      Sprockets.append_path(images_path)
    end
  end
end

PusherChameleon.load!

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pusher_chameleon-1.0.3 lib/pusher_chameleon.rb
pusher_chameleon-1.0.2 lib/pusher_chameleon.rb
pusher_chameleon-1.0.0 lib/pusher_chameleon.rb