Class: CodeSync::TempAsset

Inherits:
Sprockets::BundledAsset
  • Object
show all
Defined in:
lib/code_sync/temp_asset.rb

Class Method Summary collapse

Class Method Details

.create_from(content, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/code_sync/temp_asset.rb', line 5

def self.create_from content, options={}
  environment, filename, extension = options.values_at(:env, :filename, :extension)

  filename    = filename || "compiled"

  tempfile        = Tempfile.new([filename, extension])

  tempfile.write(content) && tempfile.rewind

  pathname        = Pathname.new(tempfile.path)
  logical_path    = File.basename(pathname)

  new(environment, logical_path, pathname)
end