class Guinness::Application attr_accessor :settings, :builder def initialize(options = {}) @settings = { output_dir: '../' }.merge options app = self @builder = Rack::Builder.new do use Rack::CommonLogger use Rack::ShowStatus # Nice looking 404s and other messages use Rack::ShowExceptions # Nice looking errors run Guinness::Server.new app end end def drink Rack::Handler::Thin.run @builder, Port: 9393 end def build FileUtils.cd @settings[:root] do # collect all files that don't start with '_' files = Dir[File.join('**', '*')].reject { |f| f =~ /(^_|\/_)/ } files.each do |file| path = File.join @settings[:output_dir], file if Tilt[path] body = Guinness::View.new(file).render File.open(path.chomp(File.extname(path)), 'w') { |f| f.write body } elsif Dir.exists? file FileUtils.mkpath path else FileUtils.cp file, path end end end end end