2

I'm writing a Ruby gem that will need an initial configuration (username, etc...). Where should I save this config file for it to be:

  • portable (various Linux distros / OS X)
  • not requiring sudo
  • not inside the gem directory as the config should persist between gem versions

Thanks!

EDIT: As suggested by @NeilSlater in the comments, I want to precise that the gem will install some CLI tools (some will be run through a GUI) and will not be used by developers, hence the need to make it as easy as possible to configure.

ilovebigmacs
  • 983
  • 16
  • 28
  • Not an answer as such, but why not do what most gem authors do and make config a user/developer problem? Most gems that consume web APIs for instance will accept user credentials, and the expectation is that the developer will deal with configuration requirements using the storage and/or configuration modules of their choice. It's a normal pattern, and allows things such as supporting multiple accounts/configs or maybe encryption, that the gem author may not have considered. – Neil Slater Jun 09 '15 at 08:57
  • thanks @NeilSlater. The user will need to enter their config value. Just one time. Then, for a better UX, I want this to be in a black box (of course they have the opportunity to edit the config using the gem, but I don't want them to deal with its config location). – ilovebigmacs Jun 09 '15 at 09:01
  • Personally, I think this will be a lot of effort for you with no real benefit, assuming your end users are all developers who know how to store config themselves. Put that effort instead into documenting your config options nicely. That is better UX for developers, not a gem that behaves in an non-standard way to store its own config. – Neil Slater Jun 09 '15 at 09:11
  • A compromise might be to have some methods like `MyGem.write_config( file_name )` and `MyGem.read_config( file_name )` which stops the location being your problem and still gives a very quick "black box" solution without limiting user in any way. Clearly you would need those methods internally in any case. – Neil Slater Jun 09 '15 at 09:16
  • 1
    Users are not developers this is why I'm asking this question. I want to abstract the location of the config file for the user and make it portable :-) – ilovebigmacs Jun 09 '15 at 09:30
  • I suggest you add that information (users are not developers) into the question, and also the nature of the gem - I would assume it installs some local command-line service or similar then? – Neil Slater Jun 09 '15 at 09:32

0 Answers0