tee_reverser 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/tee_reverser.rb
CHANGED
@@ -1,43 +1,35 @@
|
|
1
1
|
require 'yummly'
|
2
2
|
require './tee_reverser/reverser.rb'
|
3
|
-
require './tee_reverser/
|
3
|
+
require './tee_reverser/recipe_list.rb'
|
4
4
|
require './tee_reverser/pantry.rb'
|
5
5
|
|
6
6
|
module TeeReverser
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
puts "
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
#tests
|
36
|
-
# query={"meal" => 1}
|
37
|
-
# meal = RecipeList.new(query)
|
38
|
-
|
39
|
-
decision = Reverser.new(goods.list, meal.recipehash)
|
40
|
-
decision.reverse
|
41
|
-
puts decision.tee.max_by{|k,v| v[-1]}
|
42
|
-
|
7
|
+
Yummly.configure do |config|
|
8
|
+
config.app_id = "bddcbcff"
|
9
|
+
config.app_key = "9245c33f2cc6d6bedb65715d3fb66c61"
|
10
|
+
end
|
11
|
+
puts "Please give me the filepath of your pantry list, in .txt format."
|
12
|
+
puts "Your list will ideally have any each ingredient you wish to itemize in its own line."
|
13
|
+
location = gets.chomp
|
14
|
+
#ensures only proper objects get loaded
|
15
|
+
until /.txt/.match(location.to_str) && File.exists?("#{location}") do
|
16
|
+
puts "Please give me a valid filepath and name. File must exist and be in *.txt format."
|
17
|
+
location = gets.chomp
|
18
|
+
end
|
19
|
+
goods = Pantry.new(location)
|
20
|
+
goods.parse
|
21
|
+
puts "What kind of dish would you like to make?"
|
22
|
+
wishlist = gets.chomp
|
23
|
+
puts " "
|
24
|
+
puts "-------------------C O N N E C T I N G---------------------"
|
25
|
+
puts " "
|
26
|
+
query = Yummly.search("#{wishlist}")
|
27
|
+
meal = RecipeList.new(query)
|
28
|
+
meal.listbuilder
|
29
|
+
puts " "
|
30
|
+
puts "---------------------T H I N K I N G-----------------------"
|
31
|
+
puts " "
|
32
|
+
decisions = Reverser.new(goods.list, meal.recipehash)
|
33
|
+
decisions.reverse
|
34
|
+
decisions.choose
|
43
35
|
end
|
data/lib/tee_reverser/pantry.rb
CHANGED
@@ -12,8 +12,8 @@ class RecipeList #funnels Yummly results into workable hash
|
|
12
12
|
recipes = result.collect {|recipe| recipe.name}
|
13
13
|
elements = result.collect {|recipe| recipe.ingredients}
|
14
14
|
for num in 0..recipes.size-1
|
15
|
-
recipehash[recipes[num]]=elements[num]
|
15
|
+
@recipehash[recipes[num]]=elements[num]
|
16
16
|
end
|
17
|
-
recipehash.each {|k,v| v<<0}
|
17
|
+
@recipehash.each {|k,v| v<<0}
|
18
18
|
end
|
19
19
|
end
|
@@ -9,17 +9,27 @@ class Reverser
|
|
9
9
|
@eat = Hash.new
|
10
10
|
end
|
11
11
|
|
12
|
-
def reverse
|
13
|
-
|
12
|
+
def reverse
|
13
|
+
@tee.each do |k,v|
|
14
14
|
templist = v.join(" ")
|
15
|
-
for num in 0
|
16
|
-
tee[k][-1]+=1 if /#{pantrylist[num]}/.match(templist)
|
15
|
+
for num in 0..@pantrylist.size-1
|
16
|
+
@tee[k][-1]+=1 if /#{@pantrylist[num]}/.match(templist)
|
17
17
|
end
|
18
|
-
puts eat.is_a? Hash
|
19
18
|
end
|
20
|
-
|
21
|
-
eat = tee
|
22
|
-
puts eat
|
19
|
+
@eat = @tee.sort_by{|k,v| v[-1]}
|
23
20
|
end
|
24
21
|
|
22
|
+
def choose
|
23
|
+
puts "Your best options are #{@eat[-1][0]}, and #{@eat[-2][0]}. You already have #{@eat[-1][-1][-1]}, and #{@eat[-2][-1][-1]} ingredients for each of those, respectively."
|
24
|
+
puts " "
|
25
|
+
ingredients1 = @eat[-1][-1]
|
26
|
+
ingredients1.pop
|
27
|
+
ingredients2 = @eat [-2][-1]
|
28
|
+
ingredients2.pop
|
29
|
+
puts "The ingredients for #{@eat[-1][0]} are: #{ingredients1.join(", ")}."
|
30
|
+
puts " "
|
31
|
+
puts "The ingredients for #{@eat[-2][0]} are: #{ingredients2.join(", ")}."
|
32
|
+
puts " "
|
33
|
+
puts "Bon appetit!"
|
34
|
+
end
|
25
35
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tee_reverser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-12-
|
12
|
+
date: 2013-12-09 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Determines optimal recipe given pantry contents. Powered by Yummly.
|
15
15
|
email: steven.b.xu@gmail.com
|
@@ -19,8 +19,9 @@ extra_rdoc_files: []
|
|
19
19
|
files:
|
20
20
|
- lib/tee_reverser.rb
|
21
21
|
- lib/tee_reverser/pantry.rb
|
22
|
-
- lib/tee_reverser/
|
22
|
+
- lib/tee_reverser/recipe_list.rb
|
23
23
|
- lib/tee_reverser/reverser.rb
|
24
|
+
- lib/tee_reverser/version.rb
|
24
25
|
homepage: http://rubygems.org/gems/tee_reverser
|
25
26
|
licenses:
|
26
27
|
- ! '?'
|
@@ -45,5 +46,5 @@ rubyforge_project:
|
|
45
46
|
rubygems_version: 1.8.24
|
46
47
|
signing_key:
|
47
48
|
specification_version: 3
|
48
|
-
summary: Basic functions
|
49
|
+
summary: Basic functions finished
|
49
50
|
test_files: []
|