View Source Memorex.Parser (Memorex v0.2.2)
Parses Memorex Markdown Memorex.Domain.Deck
files. The Memorex.Parser
is invoked from the mix task
memorex.read_notes
. This mix task invokes read_note_dirs/1
which is the main entry point to
Memorex.Parser
; the rest of the funtions are implementation details (which are public simply so they can be
tested in isolation).
Link to this section Summary
Functions
Reads in notes from directories, and in the process creates cards. Takes an array of directory names;
e.g., ["/note_dir1", "/note_dir2"]
, etc.
Link to this section Functions
@spec create_or_update_note(Memorex.Domain.Note.t()) :: Ecto.Schema.t()
@spec default_opts() :: Keyword.t()
@spec parse_line(String.t(), Keyword.t()) :: Memorex.Domain.Note.t()
@spec read_image_note(String.t(), Keyword.t()) :: nil | Ecto.Schema.t()
read_note_dirs(note_dirs \\ Application.get_env(:memorex, Memorex.Note)[:note_dirs])
View Source@spec read_note_dirs([String.t()] | nil) :: {non_neg_integer(), nil | [any()]}
Reads in notes from directories, and in the process creates cards. Takes an array of directory names;
e.g., ["/note_dir1", "/note_dir2"]
, etc.
The existing notes in the database are marked with a flag prior to reading (flag :in_latest_parse?
on
Memorex.Domain.Note
is set to false), and as the notes are read, existing notes have this flag toggled to true. New
notes also have this flag set to true
. At the end, notes in the database which have not had their flag set to true
are expunged. These are notes which have either been deleted in the local filesystem content, or else their content
has been modified (so they have been read in again as a new note; i.e., their drilling info is lost in the process).
Note that this is the primary (and only) external API function to Memorex.Parser
; the other functions are public
solely for purposes of testing.