Sha256: a5b9b25eb213f745dcabebaea2d0be92fa664dc07af6f3cad7dd3112efaa8cd0

Contents?: true

Size: 1.91 KB

Versions: 80

Compression:

Stored size: 1.91 KB

Contents

require 'patternfly-sass/version'
module Patternfly
  class << self
    # Inspired by Kaminari
    def load!
      register_compass_extension if compass?

      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, 'sass'
    end

    def fonts_path
      File.join assets_path, 'fonts'
    end

    def javascripts_path
      File.join assets_path, 'js'
    end

    def images_path
      File.join assets_path, 'img'
    end

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

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

    def compass?
      defined?(::Compass)
    end

    def rails?
      defined?(::Rails)
    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_compass_extension
      ::Compass::Frameworks.register(
          'patternfly',
          :version               => Patternfly::VERSION,
          :path                  => gem_path,
          :stylesheets_directory => stylesheets_path,
          :templates_directory   => File.join(gem_path, 'templates')
      )
    end

    def register_rails_engine
      require 'bootstrap-sass'
      require 'font-awesome-sass'

      require 'patternfly-sass/engine'
    end

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

Patternfly.load!

Version data entries

80 entries across 80 versions & 1 rubygems

Version Path
patternfly-sass-3.46.1 lib/patternfly-sass.rb
patternfly-sass-3.46.0 lib/patternfly-sass.rb
patternfly-sass-3.45.3 lib/patternfly-sass.rb
patternfly-sass-3.45.2 lib/patternfly-sass.rb
patternfly-sass-3.45.1 lib/patternfly-sass.rb
patternfly-sass-3.45.0 lib/patternfly-sass.rb
patternfly-sass-3.44.0 lib/patternfly-sass.rb
patternfly-sass-3.43.0 lib/patternfly-sass.rb
patternfly-sass-3.42.0 lib/patternfly-sass.rb
patternfly-sass-3.41.7 lib/patternfly-sass.rb
patternfly-sass-3.41.6 lib/patternfly-sass.rb
patternfly-sass-3.41.5 lib/patternfly-sass.rb
patternfly-sass-3.41.4 lib/patternfly-sass.rb
patternfly-sass-3.41.3 lib/patternfly-sass.rb
patternfly-sass-3.41.2 lib/patternfly-sass.rb
patternfly-sass-3.41.1 lib/patternfly-sass.rb
patternfly-sass-3.39.0 lib/patternfly-sass.rb
patternfly-sass-3.38.2 lib/patternfly-sass.rb
patternfly-sass-3.38.1 lib/patternfly-sass.rb
patternfly-sass-3.38.0 lib/patternfly-sass.rb