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

Link to this section Functions

Link to this function

create_or_update_note(note)

View Source
@spec create_or_update_note(Memorex.Domain.Note.t()) :: Ecto.Schema.t()
@spec default_opts() :: Keyword.t()
Link to this function

is_bidirectional_note?(line, opts)

View Source
@spec is_bidirectional_note?(String.t(), Keyword.t()) :: boolean()
Link to this function

is_note_line?(line, opts)

View Source
@spec is_note_line?(String.t(), Keyword.t()) :: boolean()
Link to this function

parse_file_contents(contents, opts)

View Source
@spec parse_file_contents(String.t(), Keyword.t()) :: :ok
@spec parse_line(String.t(), Keyword.t()) :: Memorex.Domain.Note.t()
Link to this function

read_dir(dirname, opts \\ [])

View Source
@spec read_dir(String.t(), Keyword.t()) :: :ok
Link to this function

read_image_note(filename, opts \\ default_opts())

View Source
@spec read_image_note(String.t(), Keyword.t()) :: nil | Ecto.Schema.t()
Link to this function

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.Noteis 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.

Link to this function

read_notes_file(filename, opts \\ default_opts())

View Source
@spec read_notes_file(String.t(), Keyword.t()) :: :ok
Link to this function

read_toml_deck_config(filename)

View Source
@spec read_toml_deck_config(String.t()) :: map()