Module: DubbletrackRemote::Reader
- Defined in:
- lib/dubbletrack_remote/reader/dbf.rb,
lib/dubbletrack_remote/reader/tsv.rb,
lib/dubbletrack_remote/reader/base.rb
Defined Under Namespace
Class Method Summary collapse
- .new(file_path, **options) ⇒ Object
- .watch(playlist_path, pattern: Regexp.new(".+"), &block) ⇒ Object
Class Method Details
.new(file_path, **options) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/dubbletrack_remote/reader/base.rb', line 4 def self.new(file_path, **) if File.extname(file_path) == ".DBF" DubbletrackRemote::Reader::DBF.new(file_path, **) elsif File.extname(file_path) == ".TSV" DubbletrackRemote::Reader::TSV.new(file_path, **) end end |
.watch(playlist_path, pattern: Regexp.new(".+"), &block) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/dubbletrack_remote/reader/base.rb', line 12 def self.watch(playlist_path, pattern: Regexp.new(".+"), &block) listener = Listen.to(playlist_path, force_polling: true, wait_for_delay: 4) do |modified, added| [modified, added].flatten.compact.uniq.each do |file| if pattern.match(file) block.call(file) end end rescue => e puts "errored while listening for changes, will continue listening" puts e end listener.start end |