4 ms·
>In ruby you could just globally install the gem and require it right into your script. I've been using Elixir for one-off scripts lately and this is something
by networked 10y ago
>In ruby you could just globally install the gem and require it right into your script.
I've been using Elixir for one-off scripts lately and this is something I miss. In my book, it is a clear advantage that Ruby and other scripting languages have over Elixir. In the case of HTTP(S) my solution has been
{data, 0} = System.cmd("curl", ["-sf", url])
but as soon as you need a JSON library it is time to create a project. (The "-f" flag ensures you get a non-zero exit status from cURL if the HTTP status code isn't 2XX.)
I do not particularly like the usual global package installation model, though, because it means that you can only have a single version of a package available for your scripts to require. The best package management model for standalone scripts that I have seen is Groovy's [1]: a script can include a special directive that downloads a specific version of a package just for that script. Any versions can be stored in the global (per-user) package cache so that you don't have to redownload them every time a script runs, but your import statements always give you strictly the version you asked for. This is the model I'd adopt for Elixir.
[1] http://docs.groovy-lang.org/latest/html/documentation/grape.html http://docs.groovy-lang.org/latest/html/documentation/grape....
- deleted 9y ago[deleted]
- deleted 9y ago[deleted]