Sha256: 61371d6adc4d5dbe6e6f4a82f01c801ec8fd0741219a7c8b773a5ea06182bbf3

Contents?: true

Size: 1.96 KB

Versions: 33

Compression:

Stored size: 1.96 KB

Contents

require "bootstrap/bookingsync/version"
module Bootstrap
  module BookingSync
    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 assets_path
        @assets_path ||= File.join gem_path, 'assets'
      end

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

      def compass?
        defined?(::Compass::Frameworks)
      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(
            'bootstrap-bookinsync',
            :version               => Bootstrap::BookingSync::VERSION,
            :path                  => gem_path,
            :stylesheets_directory => stylesheets_path,
            :templates_directory   => File.join(gem_path, 'templates')
        )
      end

      def register_rails_engine
        require 'bootstrap/bookingsync/engine'
      end

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

Bootstrap::BookingSync.load!

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
bootstrap-bookingsync-sass-2.0.0 lib/bootstrap-bookingsync-sass.rb
bootstrap-bookingsync-sass-1.0.5 lib/bootstrap-bookingsync-sass.rb
bootstrap-bookingsync-sass-1.0.4 lib/bootstrap-bookingsync-sass.rb
bootstrap-bookingsync-sass-1.0.3 lib/bootstrap-bookingsync-sass.rb
bootstrap-bookingsync-sass-1.0.2 lib/bootstrap-bookingsync-sass.rb
bootstrap-bookingsync-sass-1.0.1 lib/bootstrap-bookingsync-sass.rb
bootstrap-bookingsync-sass-1.0.0 lib/bootstrap-bookingsync-sass.rb
bootstrap-bookingsync-sass-1.0.0.beta12 lib/bootstrap-bookingsync-sass.rb
bootstrap-bookingsync-sass-1.0.0.beta11 lib/bootstrap-bookingsync-sass.rb
bootstrap-bookingsync-sass-1.0.0.beta10 lib/bootstrap-bookingsync-sass.rb
bootstrap-bookingsync-sass-1.0.0.beta9 lib/bootstrap-bookingsync-sass.rb
bootstrap-bookingsync-sass-1.0.0.beta8 lib/bootstrap-bookingsync-sass.rb
bootstrap-bookingsync-sass-1.0.0.beta7 lib/bootstrap-bookingsync-sass.rb
bootstrap-bookingsync-sass-1.0.0.beta6 lib/bootstrap-bookingsync-sass.rb
bootstrap-bookingsync-sass-1.0.0.beta5 lib/bootstrap-bookingsync-sass.rb
bootstrap-bookingsync-sass-1.0.0.beta4 lib/bootstrap-bookingsync-sass.rb
bootstrap-bookingsync-sass-1.0.0.beta3 lib/bootstrap-bookingsync-sass.rb
bootstrap-bookingsync-sass-1.0.0.beta2 lib/bootstrap-bookingsync-sass.rb
bootstrap-bookingsync-sass-1.0.0.beta1 lib/bootstrap-bookingsync-sass.rb
bootstrap-bookingsync-sass-0.0.19 lib/bootstrap-bookingsync-sass.rb