Sha256: b3e78fa3076bbaa4d76d96e97d938ec9c62d6190f5a92c92d5cef7e748ca2a9f

Contents?: true

Size: 1.75 KB

Versions: 3

Compression:

Stored size: 1.75 KB

Contents

require 'sprockets'

module Firehose
  # Deal with bundling Sprocket assets into environments (like Rails or Sprockets)
  module Assets
    def self.path(*segs)
      File.join File.expand_path('../../assets', __FILE__), segs
    end

    # Integrate Firehose ./lib/assets files into a sprocket-enabled environment.
    module Sprockets
      # Entry-point Javascript for Sprockets project.
      JAVASCRIPT = "firehose.js"

      # Drop flash and javascript paths to Firehose assets into a sprockets environment.
      def self.configure(env)
        env.append_path Firehose::Assets.path('javascripts')
        env
      end

      # The "main" javascript that folks should compile and use in their
      # web applications.
      def self.javascript
        Firehose::Assets::Sprockets.environment[JAVASCRIPT].source
      end

      # Return a new sprockets environment configured with Firehose.
      def self.environment
        configure ::Sprockets::Environment.new
      end

      # Quick and dirty way for folks to compile the Firehose assets to a path
      # from the CLI and use. These are usualy non-ruby (or non-sprockets) folks
      # who want to run the firehose process and use the JS in a web app.
      def self.manifest(directory)
        ::Sprockets::Manifest.new(environment, directory)
      end

      # Try to automatically configure Sprockets if its detected in the project.
      def self.auto_detect
        if defined? ::Sprockets and ::Sprockets.respond_to? :append_path
          Firehose::Assets::Sprockets.configure ::Sprockets
        end
      end

      def self.manifest_paths
        paths = []
        paths << File.basename(Firehose::Assets.path('/javascripts/firehose/firehose.js.coffee'), '.coffee')
        paths
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
firehose-1.2.13 lib/firehose/assets.rb
firehose-1.2.12 lib/firehose/assets.rb
firehose-1.2.11 lib/firehose/assets.rb