Sha256: 0e2ea7e82bb1991ad38c5b70b687cc05cc7557d164790125468c062217fa7583

Contents?: true

Size: 1.86 KB

Versions: 45

Compression:

Stored size: 1.86 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, 'stylesheets'
    end

    def fonts_path
      File.join assets_path, 'fonts'
    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, 'assets'
    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 '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

45 entries across 45 versions & 1 rubygems

Version Path
patternfly-sass-3.23.0 lib/patternfly-sass.rb
patternfly-sass-3.21.0 lib/patternfly-sass.rb
patternfly-sass-3.20.0 lib/patternfly-sass.rb
patternfly-sass-3.17.0 lib/patternfly-sass.rb
patternfly-sass-3.15.0 lib/patternfly-sass.rb
patternfly-sass-3.14.0 lib/patternfly-sass.rb
patternfly-sass-3.13.0 lib/patternfly-sass.rb
patternfly-sass-3.12.0 lib/patternfly-sass.rb
patternfly-sass-3.11.0 lib/patternfly-sass.rb
patternfly-sass-3.10.0 lib/patternfly-sass.rb
patternfly-sass-3.9.0 lib/patternfly-sass.rb
patternfly-sass-3.8.1 lib/patternfly-sass.rb
patternfly-sass-3.8.0 lib/patternfly-sass.rb
patternfly-sass-3.7.0 lib/patternfly-sass.rb
patternfly-sass-3.6.0 lib/patternfly-sass.rb
patternfly-sass-3.5.1 lib/patternfly-sass.rb
patternfly-sass-3.5.0 lib/patternfly-sass.rb
patternfly-sass-3.4.0 lib/patternfly-sass.rb
patternfly-sass-3.3.6 lib/patternfly-sass.rb
patternfly-sass-3.3.6.pre.alpha lib/patternfly-sass.rb