Gem Configuration File


For my Ruby gem markdown_helper, I’m considering implementing some sort of configuration file.

Thoughts and questions:

  • Where to locate the file:

    • Ideally, in the user’s git directory, in part because the helper is already oriented to a git project.

    • Alternatively, in the user’s home directory.

    • Not in the gem directory, to avoid loss when updating the gem.

    • Other possibilities?

    • If not in the git directory, the file would need to have per-git-project sections.

  • When/how to create/update the file:

    • Should not create or update without user consent.

    • Begins with defaults; user can edit.

    • How to update (to add new values) without losing user edits.

  • Other considerations?


I’m thinking that nothing should be done without user action.


  • The configuration file:

    • File path is is /.markdown_helper/config.
    • The format is yaml. (Btw, anyone know the name of the format in /.git/config?)
    • One of its values, version is the markdown_helper version.
  • MarkdownHelper.initialize:

    • Issues a warning if the configuration file does not exist.
    • Issues a warning if the configuration file is not up-to-date (version current).
  • Command markdown_helper config --init``` creates (or overwrites) the configuration file.

  • Command markdown_helper config --update``` updates the configuration file:

    • Issues warning for unknown values.
    • Does not modify existing values (exception for updating version).
    • Adds new values.
  • The API has methods :config_init and :config_update, corresponding to the two commands above.