Sha256: 45660afd3d677a4f44acd900018bc435daff088f51ee75abd7a1e490241ea1ca
Contents?: true
Size: 950 Bytes
Versions: 7
Compression:
Stored size: 950 Bytes
Contents
require 'listen' module RevealCK module Commands # The idea of listening for file system changes and then # rebuilding slides. class ListenToRebuildSlides attr_reader :ui, :rebuild_method def initialize(ui, &block) @ui, @rebuild_method = ui, block end def run ::Listen.to('.', ignore: ignored_files_regex) do |mod, add, del| message_and_rebuild(mod, add, del) end.start end private def message_about_files(files, message) return if files.empty? file_names = files.join(', ') ui.message("#{message}: #{file_names}", :rebuild) end def ignored_files_regex /^slides\/.+$/ end def message_and_rebuild(mod, add, del) message_about_files(mod, 'Modified') message_about_files(add, 'Added') message_about_files(del, 'Deleted') rebuild_method.call end end end end
Version data entries
7 entries across 7 versions & 1 rubygems