On 13 August 2014 19:10, Constantine Vetoshev <gepar...@gmail.com> wrote:
> The JVM does not make using environment variables easy or convenient. The > environ <https://github.com/weavejester/environ> library took a step in > the right direction by abstracting away the distinction between environment > variables and Java properties into a Clojure map data structure. However, I > still found it awkward to use in multi-person projects where each > programmer wants to set up different environment variable values at runtime. > You can do this with Environ. Leiningen checks for a profiles.clj in your project directory, as well as then one in $HOME/.lein. If you add profiles.clj to your .gitignore file, you can use it for local overrides during development and testing. The advantage of using Leiningen is that you can override the environment for separate profiles. For instance, you could use one database for development, and another for running your tests: {:dev {:env {:database-url "..."}} :test {:env {:database-url "..."}}} In this case, if you run "lein test", it would automatically use the database-url in the test profile, instead of the dev profile. I also wanted an easy way to modify the environment in a dynamic scope. > I considered this for Environ, but the with-redefs function made it unnecessary for tests, and it seemed more semantically correct to delegate this functionality to another var. That way the environment is always constant, but the configuration is possible to change. For example: (def ^:dynamic config {:database (env :database-url)}) This also makes sense for environments like Heroku, where the DATABASE_URL environment variable isn't directly compatible with JDBC: (def ^:dynamic config {:database (make-jdbc-url (env :database-url))}) - James -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.