Sha256: 74d0f239b088fed9882bbe9ad2bbb215127186de2bd5981f64dd4652406ca22a

Contents?: true

Size: 1.33 KB

Versions: 7

Compression:

Stored size: 1.33 KB

Contents

require 'helio/version'

module Helio
  class << self
    def load!
      register_compass_extension if compass?

      if rails?
        register_rails_engine
      elsif sprockets?
        register_sprockets
      end

      configure_sass
    end

    def gem_path
      @gem_path ||= File.expand_path '..', File.dirname(__FILE__)
    end

    def stylesheets_path
      File.join assets_path, 'stylesheets'
    end

    def assets_path
      @assets_path ||= File.join gem_path, 'assets'
    end

    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
      ::Sass::Script::Number.precision = [8, ::Sass::Script::Number.precision].max
    end

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

    def register_rails_engine
      require 'helio/engine'
    end

    def register_sprockets
      Sprockets.append_path(stylesheets_path)
    end
  end
end

Helio.load!

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
helio-0.1.12 lib/helio.rb
helio-0.1.11 lib/helio.rb
helio-0.1.10 lib/helio.rb
helio-0.1.9 lib/helio.rb
helio-0.1.8 lib/helio.rb
helio-0.1.7 lib/helio.rb
helio-0.1.6 lib/helio.rb