Module: Gumdrop::Support::Sprockets

Defined in:
lib/gumdrop/support/sprockets.rb

Overview

mixes in to generator

Instance Method Summary collapse

Instance Method Details

#sprockets(source_file, opts = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/gumdrop/support/sprockets.rb', line 6

def sprockets(source_file, opts={})
  require 'sprockets'
  source_path = source_file || opt[:main] || opt[:from]
  env = ::Sprockets::Environment.new site.root
  env.append_path File.expand_path(File.join site.source_path, File.dirname(source_path))
  env.append_path site.source_path
  # env.append_path File.dirname(source_path)
  [opts[:paths]].flatten.each do |path|
    env.append_path(path) unless path.nil?
  end
  content= env[ source_path ].to_s
rescue LoadError
  raise StandardError, "Sprockets can't be loaded. Please add it to your Gemfile."
end