Sha256: 1a65e2462e05849827b369f935128858e15dbe55357a6bfb363bc3cc7c3de885

Contents?: true

Size: 1.38 KB

Versions: 7

Compression:

Stored size: 1.38 KB

Contents

require "materialize-sass/version"

module Materialize
  module Sass
    # give credit to bootstrap-sass
    class << self
      # Inspired by Kaminari
      def load!
        if rails?
          register_rails_engine
        elsif hanami?
          register_hanami
        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 assets_path
        @assets_path ||= File.join gem_path, 'assets'
      end

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

      def rails?
        defined?(::Rails)
      end

      def hanami?
        defined?(::Hanami)
      end

      private

      def configure_sass
        require 'sass'

        ::Sass.load_paths << stylesheets_path
      end

      def register_rails_engine
        require 'materialize-sass/engine'
      end

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

      def register_hanami
        Hanami::Assets.sources << assets_path
      end
    end
  end
end

Materialize::Sass.load!

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
materialize-sass-1.0.0.rc2 lib/materialize-sass.rb
materialize-sass-1.0.0.rc1 lib/materialize-sass.rb
materialize-sass-1.0.0.beta lib/materialize-sass.rb
materialize-sass-1.0.0.alpha4 lib/materialize-sass.rb
materialize-sass-1.0.0.alpha3 lib/materialize-sass.rb
materialize-sass-1.0.0.alpha2 lib/materialize-sass.rb
materialize-sass-1.0.0.alpha1 lib/materialize-sass.rb