Re: [racket-users] Re: Racket dotenv file loading

2017-08-28 Thread Philip McGrath
Submodules declared with `module+` are spliced together:
http://docs.racket-lang.org/reference/module.html?q=module%2B#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._module%2B%29%29

So it is a (loose) convention to write
(module+ test
  (require rackunit))
at the top of the file, with the other `require` statements, and then put
tests in further `module+` declarations further down, after (but close to)
the definitions of the things they are testing.

-Philip

On Mon, Aug 28, 2017 at 1:38 PM, 'Royall Spence' via Racket Users <
racket-users@googlegroups.com> wrote:

> Thanks for the feedback. I should be able to apply all of these in the
> next day or two.
>
> Regarding the test module and rackunit, the raco package template
> actually puts two test modules into main.rkt, with rackunit in one of
> them. This smells like a mistake, right? I'm going to try to find the
> relevant section in the Racket source and see if a PR is appropriate.
>
> On Mon, Aug 28, 2017, at 12:41 AM, Jack Firth wrote:
> > On Sunday, August 27, 2017 at 7:57:52 PM UTC-7, Royall Spence wrote:
> > > And it's ready to consume:
> > > https://pkgd.racket-lang.org/pkgn/package/dotenv
> > >
> > > This is the first Lisp-family code I've published, so that's exciting.
> > > Any feedback the list has to offer regarding style, approach, or
> > > packaging would be welcome.
> >
> > Looks great! I'll keep this in mind next time I'm working with env
> > configs. Here are
> > some comments:
> >
> > - Using `for` expressions would make recursion unnecessary, and it
> > cooperates well with in-lines.
> > - Racket style generally prefers lists, first, and rest to raw pairs and
> > the c*r functions.
> > - You can put your test submodules anywhere, they don't have to be in
> > main.rkt. So in dotenv/private/tests.rkt you don't need to define and
> > export a suite, you can just use (module+ test ...). Running raco test -p
> >  will run all test submodules found anywhere in the
> > package.
> > - It looks like the generated scribble files got included in your repo. I
> > typically add html, js, and css files to my .gitignore to avoid that.
> > - If you move your (require rackunit) expressions into your test
> > submodules, rackunit will be a build dependency instead of a runtime
> > dependency.
> > - Using @defproc[] in your scribble docs will make the exports of dotenv
> > searchable.
> > - Contracts and contract-out make it easy to add argument checking to
> > functions, I recommend using them.
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Racket Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to racket-users+unsubscr...@googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: Racket dotenv file loading

2017-08-28 Thread 'Royall Spence' via Racket Users
Thanks for the feedback. I should be able to apply all of these in the
next day or two.

Regarding the test module and rackunit, the raco package template
actually puts two test modules into main.rkt, with rackunit in one of
them. This smells like a mistake, right? I'm going to try to find the
relevant section in the Racket source and see if a PR is appropriate.

On Mon, Aug 28, 2017, at 12:41 AM, Jack Firth wrote:
> On Sunday, August 27, 2017 at 7:57:52 PM UTC-7, Royall Spence wrote:
> > And it's ready to consume:
> > https://pkgd.racket-lang.org/pkgn/package/dotenv
> > 
> > This is the first Lisp-family code I've published, so that's exciting.
> > Any feedback the list has to offer regarding style, approach, or
> > packaging would be welcome.
> 
> Looks great! I'll keep this in mind next time I'm working with env
> configs. Here are
> some comments:
> 
> - Using `for` expressions would make recursion unnecessary, and it
> cooperates well with in-lines.
> - Racket style generally prefers lists, first, and rest to raw pairs and
> the c*r functions.
> - You can put your test submodules anywhere, they don't have to be in
> main.rkt. So in dotenv/private/tests.rkt you don't need to define and
> export a suite, you can just use (module+ test ...). Running raco test -p
>  will run all test submodules found anywhere in the
> package.
> - It looks like the generated scribble files got included in your repo. I
> typically add html, js, and css files to my .gitignore to avoid that.
> - If you move your (require rackunit) expressions into your test
> submodules, rackunit will be a build dependency instead of a runtime
> dependency.
> - Using @defproc[] in your scribble docs will make the exports of dotenv
> searchable.
> - Contracts and contract-out make it easy to add argument checking to
> functions, I recommend using them.
> 
> -- 
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: Racket dotenv file loading

2017-08-27 Thread Jack Firth
On Sunday, August 27, 2017 at 7:57:52 PM UTC-7, Royall Spence wrote:
> And it's ready to consume:
> https://pkgd.racket-lang.org/pkgn/package/dotenv
> 
> This is the first Lisp-family code I've published, so that's exciting.
> Any feedback the list has to offer regarding style, approach, or
> packaging would be welcome.

Looks great! I'll keep this in mind next time I'm working with env configs. 
Here are
some comments:

- Using `for` expressions would make recursion unnecessary, and it cooperates 
well with in-lines.
- Racket style generally prefers lists, first, and rest to raw pairs and the 
c*r functions.
- You can put your test submodules anywhere, they don't have to be in main.rkt. 
So in dotenv/private/tests.rkt you don't need to define and export a suite, you 
can just use (module+ test ...). Running raco test -p  will 
run all test submodules found anywhere in the package.
- It looks like the generated scribble files got included in your repo. I 
typically add html, js, and css files to my .gitignore to avoid that.
- If you move your (require rackunit) expressions into your test submodules, 
rackunit will be a build dependency instead of a runtime dependency.
- Using @defproc[] in your scribble docs will make the exports of dotenv 
searchable.
- Contracts and contract-out make it easy to add argument checking to 
functions, I recommend using them.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: Racket dotenv file loading

2017-08-27 Thread 'Royall Spence' via Racket Users
And it's ready to consume:
https://pkgd.racket-lang.org/pkgn/package/dotenv

This is the first Lisp-family code I've published, so that's exciting.
Any feedback the list has to offer regarding style, approach, or
packaging would be welcome.

On Sun, Aug 27, 2017, at 10:09 PM, 'Royall Spence' via Racket Users
wrote:
> Thanks, Jack. It sounds like a great Rackety solution and easy way to
> get into trying my own languages. I've already started work, though, and
> the 40 lines of code I've written looks like it'll do the job once I
> shake out the bugs.
> 
> On Sun, Aug 27, 2017, at 05:49 PM, Jack Firth wrote:
> > On Sunday, August 27, 2017 at 11:01:17 AM UTC-7, Royall Spence wrote:
> > > I'm starting work on a Racket library for loading .env files to override 
> > > environment variables. This is a common way of doing things for people 
> > > who want to run multiple web applications on a single server without 
> > > their environment variables competing for namespace. The classic example 
> > > is this Ruby library: https://github.com/bkeepers/dotenv
> > > 
> > > Just checking to make sure I haven't overlooked an already existing 
> > > library that provides this behavior. Should I keep going?
> > 
> > There is the Envy library for parsing environment variables, but there
> > doesn't seem to be anything for loading .env files. Personally, I think
> > this would be a great place to make a #lang that worked something like
> > this:
> > 
> > #lang dotenv
> > my-library-num-workers = 5
> > my-library-tmpdir = "/tmp/my_library"
> > 
> > ... and then if you `require` it, it sets the current environment. Or
> > maybe it gives you a function to execute a thunk with the new
> > environment. The advantage to using a #lang here instead of a file is
> > your dotenv file is you no longer need to do any parsing or file IO at
> > runtime and your env file is just a normal code module imported like any
> > other. Plus you could write a syntax highlighter to make it easy to edit
> > the env files in DrRacket.
> > 
> > -- 
> > You received this message because you are subscribed to the Google Groups
> > "Racket Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to racket-users+unsubscr...@googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.
> 
> -- 
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: Racket dotenv file loading

2017-08-27 Thread 'Royall Spence' via Racket Users
Thanks, Jack. It sounds like a great Rackety solution and easy way to
get into trying my own languages. I've already started work, though, and
the 40 lines of code I've written looks like it'll do the job once I
shake out the bugs.

On Sun, Aug 27, 2017, at 05:49 PM, Jack Firth wrote:
> On Sunday, August 27, 2017 at 11:01:17 AM UTC-7, Royall Spence wrote:
> > I'm starting work on a Racket library for loading .env files to override 
> > environment variables. This is a common way of doing things for people who 
> > want to run multiple web applications on a single server without their 
> > environment variables competing for namespace. The classic example is this 
> > Ruby library: https://github.com/bkeepers/dotenv
> > 
> > Just checking to make sure I haven't overlooked an already existing library 
> > that provides this behavior. Should I keep going?
> 
> There is the Envy library for parsing environment variables, but there
> doesn't seem to be anything for loading .env files. Personally, I think
> this would be a great place to make a #lang that worked something like
> this:
> 
> #lang dotenv
> my-library-num-workers = 5
> my-library-tmpdir = "/tmp/my_library"
> 
> ... and then if you `require` it, it sets the current environment. Or
> maybe it gives you a function to execute a thunk with the new
> environment. The advantage to using a #lang here instead of a file is
> your dotenv file is you no longer need to do any parsing or file IO at
> runtime and your env file is just a normal code module imported like any
> other. Plus you could write a syntax highlighter to make it easy to edit
> the env files in DrRacket.
> 
> -- 
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Re: Racket dotenv file loading

2017-08-27 Thread Jack Firth
On Sunday, August 27, 2017 at 11:01:17 AM UTC-7, Royall Spence wrote:
> I'm starting work on a Racket library for loading .env files to override 
> environment variables. This is a common way of doing things for people who 
> want to run multiple web applications on a single server without their 
> environment variables competing for namespace. The classic example is this 
> Ruby library: https://github.com/bkeepers/dotenv
> 
> Just checking to make sure I haven't overlooked an already existing library 
> that provides this behavior. Should I keep going?

There is the Envy library for parsing environment variables, but there doesn't 
seem to be anything for loading .env files. Personally, I think this would be a 
great place to make a #lang that worked something like this:

#lang dotenv
my-library-num-workers = 5
my-library-tmpdir = "/tmp/my_library"

... and then if you `require` it, it sets the current environment. Or maybe it 
gives you a function to execute a thunk with the new environment. The advantage 
to using a #lang here instead of a file is your dotenv file is you no longer 
need to do any parsing or file IO at runtime and your env file is just a normal 
code module imported like any other. Plus you could write a syntax highlighter 
to make it easy to edit the env files in DrRacket.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.