Module: DragonRuby::Rack::Bundle
- Defined in:
- lib/dragonruby/rack/bundle.rb
Overview
Puts a published HTML5 export where the app can serve it.
This is the step that used to be three shell lines, one of which was
rm -rf against a path typed by hand. Replacing the directory rather than
unpacking over it is not optional — a file deleted between two versions
would otherwise stay behind and be served forever. So the delete has to
happen, and the only useful thing to do about it is to refuse to delete
anything that is not already a bundle.
Defined Under Namespace
Classes: Error
Constant Summary collapse
- MARKER =
What every DragonRuby HTML5 export has in it, and what a directory must therefore look like before this is willing to erase it.
"index.html"
Class Method Summary collapse
-
.install(zip, into, force: false) ⇒ Object
Unpacks
zipintointo, replacing whatever bundle is there.
Class Method Details
.install(zip, into, force: false) ⇒ Object
Unpacks zip into into, replacing whatever bundle is there.
Refuses when into exists but holds no index.html: that is either the
wrong path or something that is not a bundle, and both are worth an
error rather than a deletion. Pass force: true to say you meant it.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/dragonruby/rack/bundle.rb', line 26 def install(zip, into, force: false) zip = File.(zip.to_s) into = File.(into.to_s) raise Error, "no such zip: #{zip}" unless File.file?(zip) guard_destination(into, force: force) FileUtils.rm_rf(into) FileUtils.mkdir_p(into) unzip(zip, into) verify(into) into end |