Module: Firehose::Assets::Sprockets

Defined in:
lib/firehose/assets.rb

Overview

Integrate Firehose ./lib/assets files into a sprocket-enabled environment.

Constant Summary collapse

JAVASCRIPT =

Entry-point Javascript for Sprockets project.

"firehose.js"

Class Method Summary collapse

Class Method Details

.auto_detectObject

Try to automatically configure Sprockets if it’s detected in the project.



40
41
42
43
44
# File 'lib/firehose/assets.rb', line 40

def self.auto_detect
  if defined? ::Sprockets and ::Sprockets.respond_to? :append_path
    Firehose::Assets::Sprockets.configure ::Sprockets
  end
end

.configure(env) ⇒ Object

Drop flash and javascript paths to Firehose assets into a sprockets environment.



16
17
18
19
# File 'lib/firehose/assets.rb', line 16

def self.configure(env)
  env.append_path Firehose::Assets.path('javascripts')
  env
end

.environmentObject

Return a new sprockets environment configured with Firehose.



28
29
30
# File 'lib/firehose/assets.rb', line 28

def self.environment
  configure ::Sprockets::Environment.new
end

.javascriptObject

The “main” javascript that folks should compile and use in their web applications.



23
24
25
# File 'lib/firehose/assets.rb', line 23

def self.javascript
  Firehose::Assets::Sprockets.environment[JAVASCRIPT].source
end

.manifest(directory) ⇒ Object

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.



35
36
37
# File 'lib/firehose/assets.rb', line 35

def self.manifest(directory)
  ::Sprockets::Manifest.new(environment, directory)
end

.manifest_pathsObject



46
47
48
49
50
# File 'lib/firehose/assets.rb', line 46

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