lib/pieces/server.rb in pieces-0.3.2 vs lib/pieces/server.rb in pieces-0.3.3

- old
+ new

@@ -3,48 +3,35 @@ module Pieces class Server < Rack::Server attr_reader :path - def initialize(options) - @path = options[:path] + def initialize(options = {}) + @path = options[:path] || Dir.pwd super end def start - build_pieces - listener.start + Pieces::Listener.new(path: path).listen super end - private - def app files = files_to_serve(path) build_path = "#{path}/build" - Rack::Builder.new do + Rack::Builder.app do use Rack::Reloader use Rack::Static, urls: files, root: build_path, index: 'index.html' run Proc.new { |env| [404, {}, ['Not found']] } - end.to_app - end - - def build_pieces - Pieces::Builder.build(path: path) - end - - def listener - Listen.to("#{path}/config/", "#{path}/app/views/") do - print "Rebuilding #{path}... " - build_pieces - puts 'done.' end end + + private def files_to_serve(path) Dir["#{path}/build/**/*"].map { |file| file.sub("#{path}/build", '') } end end