lib/gumdrop/support/stitch.rb in gumdrop-0.8.0 vs lib/gumdrop/support/stitch.rb in gumdrop-1.0.0

- old
+ new

@@ -7,29 +7,40 @@ end module Gumdrop::Support module Stitch # mixes in to generator - include BasePackager - - def stitch(name, opts) - if has_stitch - content= Stitch::Package.new(opts).compile - page name do - compress_output(content, opts) - end - keep_src(name, content, opts) - prune_src(name, opts) - else - throw "Stitch can't be loaded. Please add it to your Gemfile." - end + + # 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) + 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 end + Gumdrop::Generator::DSL.send :include, Stitch + end -if defined?(Stitch) + +# +# These cause weird side effects, need to pull them out into a js-app +# specific template! +# +if false # defined?(Stitch) class Stitch::Source # Patch for gumdrop style filenames def name name = path.relative_path_from(root) \ No newline at end of file