Class: HTML5UP::Helpers
- Inherits:
-
Object
- Object
- HTML5UP::Helpers
- Defined in:
- lib/html5up/helpers.rb
Class Method Summary collapse
- .download(template, filename) ⇒ Object
- .extract(src, dest, options = {}) ⇒ Object
- .templates ⇒ Object
Class Method Details
.download(template, filename) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/html5up/helpers.rb', line 27 def self.download(template, filename) easy = Curl::Easy.new easy.follow_location = true easy.url = "html5up.net/#{template}/download" File.open(filename, 'wb') do |f| spinner = TTY::Spinner.new("Downloading #{template}... ") easy.on_progress do |dl_total, dl_now, ul_total, ul_now| spinner.spin true end easy.on_body { |data| f << data; data.size } easy.perform puts " => '#{filename}'" end end |
.extract(src, dest, options = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/html5up/helpers.rb', line 8 def self.extract(src, dest, = {}) begin Archive::Zip.extract(src, dest) rescue Archive::Zip::UnzipError puts "Error: Website down or invalid template name." puts "Removing #{src}" FileUtils.rm(src) exit(false) end if [:save] FileUtils.mv(src, dest + "/" + src) else FileUtils.rm(src) end puts "Extracted to #{dest}" end |
.templates ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/html5up/helpers.rb', line 44 def self.templates %w( multiverse hyperspace future-imperfect solid-state identity lens fractal eventually spectral photon highlights landed strata read-only alpha directive aeriel twenty big-picture tessellate overflow prologue helios telephasic strongly-typed parallelism escape-velocity astral striped dopetrope miniport txt verti zerofour arcana halcyonic minimaxing ) end |