Sha256: bb5848db02eebdc68e32cfd0fc83b6afd2781584c22ffdff4c33d252070d6d36

Contents?: true

Size: 1.77 KB

Versions: 11

Compression:

Stored size: 1.77 KB

Contents

require 'conversation_forms/version'
module ConversationForms
  class << self
    # Inspired by Kaminari through bootstrap-sass
    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 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/conversation_forms/issues/409
        ::Sass::Script::Number.precision = [8, ::Sass::Script::Number.precision].max
      end

      def register_compass_extension
        ::Compass::Frameworks.register(
            'conversation_forms',
            :version               => ConversationForms::VERSION,
            :path                  => gem_path,
            :stylesheets_directory => stylesheets_path,
            :templates_directory   => File.join(gem_path, 'templates')
        )
      end

      def register_rails_engine
        require 'conversation_forms/engine'
      end

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

ConversationForms.load!

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
conversation_forms-2.0.2 lib/conversation_forms.rb
conversation_forms-2.0.1 lib/conversation_forms.rb
conversation_forms-2.0.0 lib/conversation_forms.rb
conversation_forms-1.0.1 lib/conversation_forms.rb
conversation_forms-1.0.0 lib/conversation_forms.rb
conversation_forms-0.7.3 lib/conversation_forms.rb
conversation_forms-0.7.2 lib/conversation_forms.rb
conversation_forms-0.7.1 lib/conversation_forms.rb
conversation_forms-0.7.0 lib/conversation_forms.rb
conversation_forms-0.6.0 lib/conversation_forms.rb
conversation_forms-0.5.0 lib/conversation_forms.rb