module NoteAble

Public Class Methods

find_all_and_print() click to toggle source
# File lib/noteable.rb, line 8
def self.find_all_and_print
        View.render_page { render_notes group_by_file(parse_files) }
end
open(id) click to toggle source
# File lib/noteable.rb, line 12
def self.open id
        exec "subl #{parse_files.find { |note| note.filepath.id == id.to_i }.filepath.filepath}"
end

Private Class Methods

build_note(note) click to toggle source
# File lib/noteable.rb, line 33
def self.build_note note
      Note.new note: note[:note], line: note[:line], filepath: FilePath.new(note[:filepath])
end
filter_empty_notes(notes = []) click to toggle source
# File lib/noteable.rb, line 25
def self.filter_empty_notes notes = []
  notes.reject! { |file_notes| file_notes.length == 0 }.flatten
end
group_by_file(notes) click to toggle source
# File lib/noteable.rb, line 29
def self.group_by_file notes
  notes.group_by { |note| note.filepath }
end
help(args) click to toggle source
# File lib/noteable.rb, line 41
def self.help args
  View.help
end
parse_files(notes = []) click to toggle source
# File lib/noteable.rb, line 18
def self.parse_files notes = []
  Dir['**/*'].each do |file|
    notes << (Parser.parse file).map! { |note| build_note note } unless Pathname.new(file).directory?
  end
  filter_empty_notes notes
end
render_notes(notes) click to toggle source
# File lib/noteable.rb, line 49
def self.render_notes notes
  notes.each do |filepath, notes|
    View.render_file filepath.to_s
    notes.each { |note| View.render_note note.to_s }
  end
end
tag(tag) click to toggle source
# File lib/noteable.rb, line 45
def self.tag tag
  $pattern = /(.*)(##"#{tag}"##)(.+)(##"#{tag}"##.*)/ if /^[a-zA-Z]+$/ =~ tag
end
version(args) click to toggle source
# File lib/noteable.rb, line 37
def self.version args
  View.version
end