Sha256: cbd7bede29b4f58420b76b445a08371404b59e34bd33782b5081e9a149d7de1d

Contents?: true

Size: 1.35 KB

Versions: 4

Compression:

Stored size: 1.35 KB

Contents

require 'tabler/rubygem/version'
require 'popper_js'

module Tabler
  module Rubygem
    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 'tabler/rubygem/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

Tabler::Rubygem.load!

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tabler-rubygem-0.1.4 lib/tabler/rubygem.rb
tabler-rubygem-0.1.3 lib/tabler/rubygem.rb
tabler-rubygem-0.1.2 lib/tabler/rubygem.rb
tabler-rubygem-0.1.1 lib/tabler/rubygem.rb