Sha256: 8a234e791e88b6b3a3f9da74f8284e65ec671f0ab4ce15c2d4044d9ee990c5f0
Contents?: true
Size: 1.26 KB
Versions: 2
Compression:
Stored size: 1.26 KB
Contents
module Pieces class Listener attr_reader :path attr_reader :build_method attr_reader :force_polling def initialize(config = {}) @path = config[:path] || Dir.pwd @build_method = config[:build_method] || :build @force_polling = config[:force_polling] || false build_pieces end def listen Listen.to("#{path}/config/", "#{path}/app/views", force_polling: force_polling) do rebuild_pieces end.tap(&:start) end private def build_pieces Pieces::Builder.new(path: path).send(build_method) rescue => e output_backtrace(e) exit(1) end def rebuild_pieces print "\n[pieces]: Rebuilding #{File.basename(path)}... " Pieces::Builder.new(path: path).send(build_method) puts 'done.' rescue => e puts 'an error occurred.' puts '' output_backtrace(e) end def output_backtrace(exception) puts "[pieces]: Exception occured: #{exception.message}" puts '[pieces]:' if defined?(::Rails) trace = ::Rails.backtrace_cleaner.clean(exception.backtrace) puts trace.map { |line| "[pieces]: #{line}" } else puts exception.backtrace.map { |line| "[pieces]: #{line}" } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pieces-0.4.4 | lib/pieces/listener.rb |
pieces-0.4.3 | lib/pieces/listener.rb |