Re: fs and with-tempdir

2011-05-31 Thread David Jagoe
Hey Miki,

On 31 May 2011 17:52, Miki  wrote:
> Just uploaded fs 0.8.0 to clojars with your changes. Thanks!

I'm glad to contribute something and I'll be glad to remove some code
from my project!

> (I've changed the assert in your code to :pre checks)

Ah yes that sounds better.


Cheers,
David

-- 
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


Re: fs and with-tempdir

2011-05-31 Thread Miki
Just uploaded fs 0.8.0 to clojars with your changes. Thanks!
(I've changed the assert in your code to :pre checks)

-- 
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

Re: fs and with-tempdir

2011-05-29 Thread David Jagoe
On 29 May 2011 16:40, Miki  wrote:
>
>> Cool, I'll clean up the code and submit it along with tests and docs.
>> While Im about it i may as well write the equivalent macro for tempfile.

I've submitted a bit bucket pull request with the changes. Never used
bit bucket before so not sure what the process is for you but let me
know if you'd just like me to attach a patch to the ticket instead.
I've written a single macro that can be used for both temporary files
and directories like this:

(fs/with-temp [f (fs/tempfile)]
  (do-stuff f))

(fs/with-temp [d (fs/tempdir)]
  (do-stuff d))

There are probably a couple of corner cases that I haven't dealt with
properly (e.g. I haven't checked that the result of evaluating the
second form in the binding vector can be deleted using fs/deltree.
That could cause some problems. Let me know what you think.


Cheers,
David

-- 
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


Re: fs and with-tempdir

2011-05-29 Thread Miki


> Cool, I'll clean up the code and submit it along with tests and docs. While 
> Im about it i may as well write the equivalent macro for tempfile.
>
Thanks! 

-- 
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

Re: fs and with-tempdir

2011-05-27 Thread David Jagoe
Cool, I'll clean up the code and submit it along with tests and docs. While
Im about it i may as well write the equivalent macro for tempfile.

Cheers
David

On 27 May 2011 5:52 PM, "Miki"  wrote:

I've opened https://bitbucket.org/tebeka/fs/issue/5/with-tempdir-macro and
will try to get to it soon.
If you'd like to submit a patch (with test and documentation) ... ;)

-- 
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 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

Re: fs and with-tempdir

2011-05-27 Thread Miki
I've opened https://bitbucket.org/tebeka/fs/issue/5/with-tempdir-macro and 
will try to get to it soon.
If you'd like to submit a patch (with test and documentation) ... ;)

-- 
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

fs and with-tempdir

2011-05-27 Thread David Jagoe
G'day all,

Thanks Miki for fs, also coming from a Python background I am enjoying
the familiarity!

The thing that I most often use tempdir for is unit testing where I
want to clean up immediately in a finally block.

(defmacro with-tempdir
  "bindings => [name path]

   Evaluates body in a try expression with the name bound to the path
   supplied. A finally clause calls (fs/deltree on name).

   E.g.

   (with-open [d (fs/tempdir)]
 (println d))

  "
  [bindings & body]
  (assert
   (and
(vector? bindings)
(= 2 (count bindings))
(symbol? (bindings 0
  `(let ~bindings
 (try
   ~@body
   (finally (deltree ~(bindings 0))

Wondering whether this already exists or could be candidate for
inclusion in fs. It can use a bit of cleaning up and its not the kind
of thing that I like to maintain in my codebase.


Cheers,
David

-- 
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