Module: Gumdrop::Support::Stitch

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

Overview

mixes in to generator

Instance Method Summary collapse

Instance Method Details

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

Stitch::Package.new options:

:identifier=>'app',   # variable name for the library
:paths=>['./app'],
:root=>'./app', 
:dependencies=>[],    # List of scripts to prepend to top of file (non moduled)


18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/gumdrop/support/stitch.rb', line 18

def stitch(source_file, opts={})
  require 'stitch-rb'
  content= site.resolve source_file
  path = content.nil? ? source_file : content.source_path
  stitch_opts= {} #{ root: content.source_path }
  stitch_opts.merge! opts
  stitch_opts[:paths] ||= []
  stitch_opts[:paths] << File.dirname(path)
  ::Stitch::Package.new(stitch_opts).compile
rescue LoadError
  raise StandardError, "Stitch can't be loaded. Please add it to your Gemfile."
end