Project

ingreedy

0.14
No release in over 3 years
Low commit activity in last 3 years
There's a lot of open issues
Natural language recipe ingredient parser that supports numeric amount, units, and ingredient
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0.7.0, ~> 0.7.0
>= 0
>= 0.9, ~> 0.9
>= 3.3.0, ~> 3.3.0

Runtime

>= 1.7.0, ~> 1.7.0
 Project Readme

Usage

result = Ingreedy.parse('1 lb. potatoes')
print result.amount
  #=> 1.0
print result.unit
  #=> :pound
print result.ingredient
  #=> "potatoes"

I18n and custom dictionaries

Ingreedy.dictionaries[:fr] = { 
  units: { dash: ['pincée'] }, 
  numbers: { 'une' => 1 }, 
  prepositions: ['de'] 
}

Ingreedy.locale = :fr # Also automatically follows I18n.locale if available

result = Ingreedy.parse('une pincée de sucre')
print result.amount
  #=> 1.0
print result.unit
  #=> :dash
print result.ingredient
  #=> "sucre"

Handling amounts

By default, Ingreedy will convert all amounts to a rational number:

result = Ingreedy.parse("1 1/2 cups flour")
print result.amount
  #=> 3/2

However, setting Ingreedy.preverse_amounts = true, will allow amounts to be detected and returned as originally input:

Ingreedy.preserve_amounts = true

result = Ingreedy.parse("1 1/2 cups flour")
print result.amount
  #=> 1 1/2

Live demo

Pieces of Flair

  • Gem Version
  • Build Status
  • Code Climate
  • Coverage Status

Development

Run the tests:

rspec spec