Method: FuzzyNotes::Notes#cat

Defined in:
lib/fuzzy_notes/notes.rb

#catObject

dump all matching notes to stdout



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/fuzzy_notes/notes.rb', line 42

def cat
  unless encrypted_notes.empty?
    print_notes(:encrypted => true)
    decrypted_notes = @cipher.decrypt_files(encrypted_notes)
  end

  matching_notes.each do |note_path|
    contents = \
      if FuzzyNotes::Cipher.encrypted?(note_path)
        decrypted_notes.shift
      elsif FuzzyNotes::EvernoteSync.evernote?(note_path)
        FuzzyNotes::EvernoteSync.sanitize_evernote(note_path)
      elsif FuzzyNotes::ImageViewer.image?(note_path)
        FuzzyNotes::ImageViewer.display(@viewer, note_path)
      else
        FuzzyNotes::TextViewer.read(note_path)
      end

    if contents
      log.info "=== #{note_path} ===\n\n"
      puts "#{contents}\n"
    end
  end
end