My idea was to grab the weekly updated list of the box's contents from OB's web site and pair those items with their handling and storage instructions, implemented as symbols of strings within the food context.
The real inspiration for this project was a function I was delighted to discover in newLISP's repertoire: geturl. Something so fundamental as getting the contents of a web page, and there's a function for it? Wow! (Please note the note of sarcasm.) With this function in hand, I set about the Great Organic Box Download the List, Generate the Output Project.
What follows are the 372 steps I followed to produce the coolest progra--
No, actually, it was trivial. I made a context to hold the foods (food) and their related storage and handling instructions, as well as a function (storage) to map food names (possibly with spaces) to the symbols I used for the keys. The fun part -- and this is where I used the geturl function -- takes place within the ob context and is called this-week. Let's peek in on the code and see what it is up to:
Code: Select all
(context 'ob)
(constant 'organic-box-url
{http://organicbox.org/organic%5Fbox/This_week.asp})
(define (ob:ob) ; default context function
(this-week))
(define (ob:list)
(regex
"Organic Box this week\\?\n(.*)\nThe\nOrganic Box P.O. Box"
(html:strip (get-url organic-box-url))
re:dot=nl)
(parse $1 "\n"))
(define (this-week)
(apply food:storage (ob:list)))
(context MAIN)
Now let's use it!
Code: Select all
> (ob:this-week) ;-) could also use (ob)
↓
Strawberries:
should be stored covered in the refrigerator, preferably with a towel
and then with plastic. Any berries that are soft should be eaten
immediately and not stored with other berries. Do not store in the
high humidity drawer since moisture accelerates spoilage. Also, do not
wash until ready to eat. Use within 2 - 3 days. Same for cranberries,
but they can be stored for a week.
↓
Danjou Pears:
will keep for a few weeks in the refrigerator if stored loosely.
Pears need to soften at room temperature prior to eating to ensure
ripening.
↓
Mango:
will keep for a few weeks in the refrigerator if stored loosely.
Pears need to soften at room temperature prior to eating to ensure
ripening.
↓
. . .
↓
Salad Mix:
like high humidity and cool temperatures. We recommend washing the
greens, drying them in a salad spinner and then storing them in a
tightly sealed plastic container with a cloth in the bottom to soak
moisture. You can also store them loosely in a plastic bag with a
cloth. Eat greens within five days, but if stored properly, they can
keep for a week, especially since the greens we ship you are so fresh.
↓
Broccoli:
should be stored in the crisper section of the refrigerator. They
should keep for up to a week, but preferably used within four days.
Soaking in water prior to cooking will help revive limp broccoli.
↓
Collards:
should be washed and drained thoroughly before packing in bags.
↑
> (ob:list)
("Strawberries" "Danjou Pears" "Mango" "Valencia Oranges" "Carrots with tops" "Russets" "Cherry Tomatoes" "Salad Mix" "Broccoli" "Collards")
> _
m i c h a e l