librelist archives

« back to archive

Re: [leiningen] Accessing the profile from within the repl

Re: [leiningen] Accessing the profile from within the repl

From:
Phil Hagelberg
Date:
2013-01-29 @ 18:33
Brian Marick writes:
> As far as I can tell, there's no way for the Midje repl tools to get
> hold of what the user expects the :test-paths to be. Would it be
> reasonable to make the project map available in the repl somehow?
> Maybe a `leiningen` namespace that's populated with Leiningen data
> (and maybe useful leiningen tools)?
>
> More generally, is it reasonable to move in a direction where users
> would expect to be able to do interactively many of the things that
> they can do from the command line? (Especially for small, repetitive
> tasks like red-green-refactor.)

A big part of Leiningen's design so far is that project code should
typically be unaware that it's running in Leiningen; the better we can
avoid lein-specific functionality in the codebase, the more likely
things will just work when you deploy an uberjar. This is why so far we
have avoided exposing the project map at runtime.

This has been discussed previously:

    https://github.com/technomancy/leiningen/issues/798

We may move away from this strategy at some point in the future, but in
the mean time you can bring in the project map using a plugin like configleaf:

    https://github.com/davidsantiago/configleaf

-Phil

Re: [leiningen] Accessing the profile from within the repl

From:
Justin Balthrop
Date:
2013-01-29 @ 18:40
I use the following simple middleware to inject part of the project map 
into my project:

(ns my-project.middleware)

(defn inject-config [project]
  (let [form `(do (require '~'my-project.config)
                  (my-project.config/set-profiles! '~(:active-profiles 
(meta project))))]
    (update-in project [:injections]
               (fnil conj []) form)))

In this case, I'm only storing the :active-profiles key from project's 
meta, but you could use a similar strategy to make any part of the project
map available to your project.


On Jan 29, 2013, at 10:33 AM, Phil Hagelberg <phil@hagelb.org> wrote:

> 
> Brian Marick writes:
>> As far as I can tell, there's no way for the Midje repl tools to get
>> hold of what the user expects the :test-paths to be. Would it be
>> reasonable to make the project map available in the repl somehow?
>> Maybe a `leiningen` namespace that's populated with Leiningen data
>> (and maybe useful leiningen tools)?
>> 
>> More generally, is it reasonable to move in a direction where users
>> would expect to be able to do interactively many of the things that
>> they can do from the command line? (Especially for small, repetitive
>> tasks like red-green-refactor.)
> 
> A big part of Leiningen's design so far is that project code should
> typically be unaware that it's running in Leiningen; the better we can
> avoid lein-specific functionality in the codebase, the more likely
> things will just work when you deploy an uberjar. This is why so far we
> have avoided exposing the project map at runtime.
> 
> This has been discussed previously:
> 
>    https://github.com/technomancy/leiningen/issues/798
> 
> We may move away from this strategy at some point in the future, but in
> the mean time you can bring in the project map using a plugin like configleaf:
> 
>    https://github.com/davidsantiago/configleaf
> 
> -Phil