Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combine ingredients in shopping lists #71

Merged
merged 8 commits into from
Sep 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,25 @@ HeRM's: a Haskell-based Recipe Manager (yes, food recipes) for the command line.
- Import and export recipe files
- Generate shopping lists
- Keep track of recipes with tags
- Set default unit systems, serving sizes, language, and recipe file path in ``config.hs``

#### What's new
- Bonjour! Herm's now has language support for Français (French), English, and Pirate. Set your language preferences in ``config.hs``!
- These are but the first languages that Herm's is now capable of supporting. We need your help to translate it into others! Currently in progress: Português (Portuguese), Español (Spanish)
- Herm's now conforms to the [XDG Base Directory Specification](http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html). In short, `config.hs` and `recipes.herms` are now stored in `~/.config/herms` and `~/.local/share/herms` respectively on most Linux systems.
- Set default unit systems, serving sizes, language, and recipe (see
[the section on configuration](#configuring-herms-and-managing-recipe-files))

#### What's new:
- *Breaking change*: Units now have a different internal representation.
Recipes written for old versions of Herm's will have to be converted (see
[#71](https://github.com/JackKiefer/herms/pull/71) to see how the example
recipes were changed). More breaking changes are expected as Herm's begins to
use YAML as its representation format (see
[#37](https://github.com/JackKiefer/herms/issues/37)).
- Herm's now conforms to the [XDG Base Directory
Specification](http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html).
In short, `config.hs` and `recipes.herms` are now stored in `~/.config/herms`
and `~/.local/share/herms` respectively on most Linux systems.
- Bonjour! Herm's now has language support for Français (French), English, and
Pirate. Set your language preferences in ``config.hs``! These are but the
first languages that Herm's is now capable of supporting. We need your help to
translate it into others! Currently in progress: Português (Portuguese),
Español (Spanish)

### Contributing

Expand Down
File renamed without changes.
5 changes: 2 additions & 3 deletions app/herms.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{-# LANGUAGE ViewPatterns #-}


module Main where

import System.IO
Expand Down Expand Up @@ -85,7 +84,7 @@ doEdit recp origRecp = do
ingrList = adjustIngredients (servingSize recp % 1) $ ingredients recp
toStr f = unlines (map f ingrList)
amounts = toStr (showFrac . quantity)
units = toStr unit
units = toStr (show . unit)
ingrs = toStr ingredientName
dirs = unlines (directions recp)
attrs = toStr attribute
Expand Down Expand Up @@ -290,7 +289,7 @@ shop targets serv = do
Nothing -> []
Just recp -> adjustIngredients (getFactor recp) $ ingredients recp)
targets
liftIO $ forM_ (sort ingrts) $ \ingr ->
liftIO $ forM_ (sort . combineIngredients $ ingrts) $ \ingr ->
putStrLn $ showIngredient 1 ingr

printDataDir :: HermsReader IO ()
Expand Down
8 changes: 4 additions & 4 deletions data/recipes.herms
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Recipe {recipeName = "Undergrad Pad Thai", description = "Actually tasty and super cheap ramen that tastes a bit like Pad Thai but not really.", servingSize = 1, ingredients = [Ingredient {quantity = 1 % 1, unit = "package", ingredientName = "oriental-flavor instant ramen", attribute = ""},Ingredient {quantity = 1 % 1, unit = "cups", ingredientName = "frozen stir-fry vegetables", attribute = ""},Ingredient {quantity = 1 % 1, unit = "Tbsp", ingredientName = "peanut butter", attribute = "chunky or creamy"},Ingredient {quantity = 0 % 1, unit = "", ingredientName = "Your favorite hot sauce", attribute = "(optional)"}], directions = ["Place the dry noodles in a bowl. Add frozen veggies.","Add enough water to cover the noodles without overflowing your bowl. It's okay if the veggies aren't covered.","Microwave for approximately 5 minutes. You ideally want the water to boil a bit.","Drain about 3/4 of the water from the bowl.","Add peanut butter, about 3/5 of the flavor packet, and hot sauce.","Stir until the peanut butter has become one with the ramen. Enjoy!"], tags = ["vegan"]}
Recipe {recipeName = "Black Bean and Butternut Squash Tacos", description = "Delicious, authentic tacos with a savoriness complemented by the light sweetness of the squash.", servingSize = 1, ingredients = [Ingredient {quantity = 1 % 1, unit = "cup", ingredientName = "butternut squash", attribute = "cubed"},Ingredient {quantity = 1 % 2, unit = "cups", ingredientName = "black beans", attribute = ""},Ingredient {quantity = 1 % 2, unit = "tsp", ingredientName = "cumin, cayenne, and paprika", attribute = ""},Ingredient {quantity = 1 % 6, unit = "", ingredientName = "avocado", attribute = "cubed or sliced"},Ingredient {quantity = 1 % 1, unit = "Tbsp", ingredientName = "hatch valley salsa", attribute = ""},Ingredient {quantity = 0 % 1, unit = "", ingredientName = "lime juice", attribute = "to garnish"}], directions = ["Place butternut squash in a microwave-safe bowl and heat on high until tender","Transfer squash to a small, un-oiled pan or skillet. Add salsa.","Add beans and season with spices. Heat over medium heat and toss with a spoon until the mixture is evenly heated.","Fill corn tortillas with squash and bean mixture. Add avocado.","Garnish with lime juice and additional salsa if desired"], tags = ["vegan","mexican","easy"]}
Recipe {recipeName = "Peasant Bread", description = "Crazy simple bread that will feed you and your family for generations. Makes one loaf. Use any size mug.", servingSize = 1, ingredients = [Ingredient {quantity = 5 % 2, unit = "mugs", ingredientName = "flour", attribute = ""},Ingredient {quantity = 1 % 1, unit = "mug", ingredientName = "water", attribute = "warm"},Ingredient {quantity = 2 % 1, unit = "tsp", ingredientName = "yeast", attribute = ""},Ingredient {quantity = 0 % 1, unit = "", ingredientName = "salt", attribute = ""}], directions = ["Slowly fill your mug with salt until you can no longer see the bottom of the mug.","Mix this amount of salt with flour, one mug warm water, and yeast in a large bowl.","You're using your hands, right?","Once the dough has become homogenous, allow it to sit and rise for about one hour","Lightly pat, spin, and roll the dough.","Stretch it out on a hard surface and fold it back on itsself. Repeat until the dough toughens.","Smooth it to roundness. Let rise for one more hour.","Cut an X in the top with a knife to let the spirits out. Bake for 45 minutes at 400 F.","Have your mind blown by amazing bread"], tags = ["easy","frugal"]}
Recipe {recipeName = "Amazing Queso Tacos", description = "Simple, quick tacos right from Pap\225's kitchen. So delicious you'll think about them at night. Make a few to snack on, or pair with rice and beans for a proper meal.", servingSize = 1, ingredients = [Ingredient {quantity = 2 % 1, unit = "oz", ingredientName = "queso fresco", attribute = ""},Ingredient {quantity = 3 % 1, unit = "", ingredientName = "corn tortillas", attribute = ""},Ingredient {quantity = 0 % 1, unit = "", ingredientName = "Crystal Louisiana hot sauce", attribute = ""}], directions = ["Bring a well-oiled pan or skillet to medium heat. Add corn tortillas 1-3 at a time depending on pan size.","Allow tortillas to cook until warm to the touch. Add 1-2 slices of queso fresco per tortilla.","Fold the tortillas in half and allow to cook until the cheese is melted.","Remove from heat and serve with as much hot sauce as one can handle"], tags = ["mexican","quick","easy"]}
Recipe {recipeName = "Undergrad Pad Thai", description = "Actually tasty and super cheap ramen that tastes a bit like Pad Thai but not really.", servingSize = 1, ingredients = [Ingredient {quantity = 1 % 1, unit = Other "package", ingredientName = "oriental-flavor instant ramen", attribute = ""},Ingredient {quantity = 1 % 1, unit = Cup, ingredientName = "frozen stir-fry vegetables", attribute = ""},Ingredient {quantity = 1 % 1, unit = Tbsp, ingredientName = "peanut butter", attribute = "chunky or creamy"},Ingredient {quantity = 0 % 1, unit = Other "", ingredientName = "Your favorite hot sauce", attribute = "(optional)"}], directions = ["Place the dry noodles in a bowl. Add frozen veggies.","Add enough water to cover the noodles without overflowing your bowl. It's okay if the veggies aren't covered.","Microwave for approximately 5 minutes. You ideally want the water to boil a bit.","Drain about 3/4 of the water from the bowl.","Add peanut butter, about 3/5 of the flavor packet, and hot sauce.","Stir until the peanut butter has become one with the ramen. Enjoy!"], tags = ["vegan"]}
Recipe {recipeName = "Black Bean and Butternut Squash Tacos", description = "Delicious, authentic tacos with a savoriness complemented by the light sweetness of the squash.", servingSize = 1, ingredients = [Ingredient {quantity = 1 % 1, unit = Cup, ingredientName = "butternut squash", attribute = "cubed"},Ingredient {quantity = 1 % 2, unit = Cup, ingredientName = "black beans", attribute = ""},Ingredient {quantity = 1 % 2, unit = Tsp, ingredientName = "cumin, cayenne, and paprika", attribute = ""},Ingredient {quantity = 1 % 6, unit = Other "", ingredientName = "avocado", attribute = "cubed or sliced"},Ingredient {quantity = 1 % 1, unit = Tbsp, ingredientName = "hatch valley salsa", attribute = ""},Ingredient {quantity = 0 % 1, unit = Other "", ingredientName = "lime juice", attribute = "to garnish"}], directions = ["Place butternut squash in a microwave-safe bowl and heat on high until tender","Transfer squash to a small, un-oiled pan or skillet. Add salsa.","Add beans and season with spices. Heat over medium heat and toss with a spoon until the mixture is evenly heated.","Fill corn tortillas with squash and bean mixture. Add avocado.","Garnish with lime juice and additional salsa if desired"], tags = ["vegan","mexican","easy"]}
Recipe {recipeName = "Peasant Bread", description = "Crazy simple bread that will feed you and your family for generations. Makes one loaf. Use any size mug.", servingSize = 1, ingredients = [Ingredient {quantity = 5 % 2, unit = Other "mugs", ingredientName = "flour", attribute = ""},Ingredient {quantity = 1 % 1, unit = Other "mug", ingredientName = "water", attribute = "warm"},Ingredient {quantity = 2 % 1, unit = Tsp, ingredientName = "yeast", attribute = ""},Ingredient {quantity = 0 % 1, unit = Other "", ingredientName = "salt", attribute = ""}], directions = ["Slowly fill your mug with salt until you can no longer see the bottom of the mug.","Mix this amount of salt with flour, one mug warm water, and yeast in a large bowl.","You're using your hands, right?","Once the dough has become homogenous, allow it to sit and rise for about one hour","Lightly pat, spin, and roll the dough.","Stretch it out on a hard surface and fold it back on itsself. Repeat until the dough toughens.","Smooth it to roundness. Let rise for one more hour.","Cut an X in the top with a knife to let the spirits out. Bake for 45 minutes at 400 F.","Have your mind blown by amazing bread"], tags = ["easy","frugal"]}
Recipe {recipeName = "Amazing Queso Tacos", description = "Simple, quick tacos right from Pap\225's kitchen. So delicious you'll think about them at night. Make a few to snack on, or pair with rice and beans for a proper meal.", servingSize = 1, ingredients = [Ingredient {quantity = 2 % 1, unit = Oz, ingredientName = "queso fresco", attribute = ""},Ingredient {quantity = 3 % 1, unit = Other "", ingredientName = "corn tortillas", attribute = ""},Ingredient {quantity = 0 % 1, unit = Other "", ingredientName = "Crystal Louisiana hot sauce", attribute = ""}], directions = ["Bring a well-oiled pan or skillet to medium heat. Add corn tortillas 1-3 at a time depending on pan size.","Allow tortillas to cook until warm to the touch. Add 1-2 slices of queso fresco per tortilla.","Fold the tortillas in half and allow to cook until the cheese is melted.","Remove from heat and serve with as much hot sauce as one can handle"], tags = ["mexican","quick","easy"]}
35 changes: 12 additions & 23 deletions herms.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ data-dir: data
library
hs-source-dirs: src
exposed-modules: Utils
, AddCLI
, RichText
, ReadConfig
, Types
Expand All @@ -79,20 +78,17 @@ library
-- Other library packages from which modules are imported.
build-depends: ansi-terminal >= 0.7.0 && <= 0.8.1
, base >=4.8 && <5
, brick >= 0.19 && <= 0.39
, directory >= 0.0
, filepath >= 1.4 && < 1.5
, microlens >=0.4 && <0.5
, microlens-th >=0.4 && <0.5
, mtl >= 2.2.1 && < 2.3
, optparse-applicative >=0.14 && <0.15
, semigroups >= 0.18.3 && < 0.19
, split >=0.2 && <0.3
, vty >=5.15 && <= 5.23

executable herms
hs-source-dirs: app
main-is: herms.hs
other-modules: AddCLI
default-language: Haskell2010
ghc-options: -W -Wcompat
-Wunrecognised-warning-flags
Expand All @@ -117,9 +113,12 @@ executable herms
test-suite herms-test
type: exitcode-stdio-1.0
main-is: Main.hs
other-modules: UnitConversions.Tests
, ReadConfig.Tests
, Paths_herms
other-modules: UnitConversions.Tests
, ReadConfig.Tests
, Instances
, Types.Tests
, Utils.Tests
, Paths_herms
hs-source-dirs: test
default-language: Haskell2010
ghc-options: -W -Wcompat
Expand All @@ -128,22 +127,12 @@ test-suite herms-test
other-extensions: OverloadedStrings, TemplateHaskell, RankNTypes
build-depends: herms
, base -any
, tasty >= 1.1
, tasty-hunit >= 0.10
, tasty-quickcheck >= 0.8
, generic-random -any
, tasty -any
, tasty-hunit -any
, tasty-quickcheck -any
, HUnit -any

test-suite doctests
type: exitcode-stdio-1.0
hs-source-dirs: test
main-is: Doctest.hs
other-modules: Paths_herms
default-language: Haskell2010
ghc-options: -W -Wcompat
-Wunrecognised-warning-flags
-threaded
build-depends: base
, doctest >= 0.8
, QuickCheck -any

source-repository head
type: git
Expand Down
Loading