Sha256: 580a72ee039b9dec4d045aafcabd526263be3bb93078fe65762a3ab43dd31b99
Contents?: true
Size: 1.85 KB
Versions: 5
Compression:
Stored size: 1.85 KB
Contents
#!/usr/bin/env ruby require 'slide_hero' require 'thor' require 'fileutils' class PresentationGenerator < Thor include Thor::Actions desc "new NAME", "Create a new presentation" def new(name) @name = name template 'templates/new_presentation.tt', "#{name}/presentation.rb" ['/images', '/audio', '/video', '/code']. each do |media| empty_directory "#{name}/#{media}" end end desc "compile PRESENTATION_NAME (defaults to presentation.rb", "Compile presentation" def compile(name = 'presentation.rb', folder="presentation") directory 'vendor/reveal.js', folder move_slide_files(name, folder) end desc "move_slide_files NAME DEST_FOLDER", "Only move the user generated files" def move_slide_files(name, folder) ['/images', '/audio', '/video', '/code']. each do |media| FileUtils.cp_r(File.dirname(File.realdirpath(name)) + media, "#{folder}") end File.open("#{folder}/index.html", 'w+') do |f| f.puts eval(File.read(name), SlideHero.get_binding) end end desc "serve FILENAME", "starts a server running your presentation on port 9292" def serve(name = 'presentation.rb') compile(name, '.tmp') puts "Go checkout your awesome presentation at http://localhost:9292!" rackupPid = Process.spawn("rackup #{Gem.loaded_specs['slide_hero'].full_gem_path}/config.ru") last_update = Time.now loop do if File.mtime(name) > last_update puts "File change noted!" puts "Recompiling" move_slide_files(name, '.tmp') last_update = File.mtime(name) end sleep 1 end rescue Exception => e puts e Process.kill(9, rackupPid) rescue Errno::ESRCH remove_dir '.tmp' puts "GOING DOWN!" exit 0 end end PresentationGenerator.source_root(Gem.loaded_specs['slide_hero'].full_gem_path) PresentationGenerator.start ARGV
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
slide_hero-0.0.7 | bin/slidehero |
slide_hero-0.0.6 | bin/slidehero |
slide_hero-0.0.5 | bin/slidehero |
slide_hero-0.0.4 | bin/slidehero |
slide_hero-0.0.3 | bin/slidehero |