todays_top_desserts 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a7a622167bd9b5451488b4e33d4c72a668f27bfd8370fe06723eef908aeabbba
4
- data.tar.gz: 79493fffc756620934ab0adbba32aeccebafbde52832f8184b275a71eb89192d
3
+ metadata.gz: de4d5dc8ca8ef73db1dbfaa03105ad4af9a2032df1bc695ba27592afaaa02b3b
4
+ data.tar.gz: 825a1198fa00c2de7879347f5e8b0f52e1c0a385239baa03592f470dad30f8cf
5
5
  SHA512:
6
- metadata.gz: 18512ccfeb3d2e0026e0ae91e277a603979cb3755f8d4b8df3e03dc254a745762a78a1a45cf2e97ee92d0d7ebe8567062374b5685ac6aef32802578246e6c6d9
7
- data.tar.gz: 20d92d9452681b5dba405230ed3e9d47261dc79ab7e4848b661089e2e85750c7060a0099448b9b46ee0d714fbf3fe253bb64493626f5a725192bd0dcb9931e23
6
+ metadata.gz: e5ee37d4635638bfa23681c5cd7c86d66e60bf1ce2dfa7a30a6803d7a99f7263cabb3d7852adb04258b3560c1a970f871e1f866f88fd478191f7c9eddfcde097
7
+ data.tar.gz: c772e7a58e753b2a8950b48fcff138c83014f2d1d7d200db4ff8f719df84e4da822c7c08a10b3defb9afbf0700fabf45445b99ad5c81793efd2f3a1651bc3cbd
@@ -42,28 +42,8 @@ class TodaysTopDesserts::CLI
42
42
  puts "Please enter either the number of the recipe you'd like to view, 'list' to see the list of recipes again, or 'exit' to close the program:"
43
43
  input = gets.strip.downcase
44
44
  if input.to_i > 0 && input.to_i < 11
45
- the_recipe = @recipes[input.to_i-1]
46
- puts ""
47
- puts "#{the_recipe.name}".colorize(:cyan).bold
48
- puts "by #{the_recipe.author}" if the_recipe.author != ""
49
- puts ""
50
- puts "#{the_recipe.description}".italic if the_recipe.description != ""
51
- puts ""
52
- puts "Ready in: ".colorize(:light_black) + "#{the_recipe.ready_time}" if the_recipe.ready_time != ""
53
- puts "Prep time: ".colorize(:light_black) + "#{the_recipe.prep_time}" if the_recipe.prep_time != ""
54
- puts "Cook time: ".colorize(:light_black) + "#{the_recipe.cook_time}" if the_recipe.cook_time != ""
55
- puts "Serving size: ".colorize(:light_black) + "#{the_recipe.serving_size}" if the_recipe.serving_size != ""
56
- puts "Calorie count: ".colorize(:light_black) + "#{the_recipe.calorie_count}" if the_recipe.calorie_count != ""
57
- puts ""
58
- puts "INGREDIENTS:".colorize(:light_red).underline
59
- the_recipe.ingredients.each do |ingredient|
60
- puts "#{ingredient}"
61
- end
62
- puts ""
63
- puts "INSTRUCTIONS:".colorize(:light_red).underline
64
- the_recipe.instructions.each.with_index(1) do |instruction, i|
65
- puts "#{i}.".colorize(:light_black) + " #{instruction}"
66
- end
45
+ @the_recipe = @recipes[input.to_i-1]
46
+ puts_recipe
67
47
  elsif input == "list"
68
48
  list_desserts
69
49
  elsif input == "exit"
@@ -74,6 +54,30 @@ class TodaysTopDesserts::CLI
74
54
  end
75
55
  end
76
56
 
57
+ def puts_recipe
58
+ puts ""
59
+ puts "#{@the_recipe.name}".colorize(:cyan).bold
60
+ puts "by #{@the_recipe.author}" if @the_recipe.author != ""
61
+ puts ""
62
+ puts "#{@the_recipe.description}".italic if @the_recipe.description != ""
63
+ puts ""
64
+ puts "Ready in: ".colorize(:light_black) + "#{@the_recipe.ready_time}" if @the_recipe.ready_time != ""
65
+ puts "Prep time: ".colorize(:light_black) + "#{@the_recipe.prep_time}" if @the_recipe.prep_time != ""
66
+ puts "Cook time: ".colorize(:light_black) + "#{@the_recipe.cook_time}" if @the_recipe.cook_time != ""
67
+ puts "Serving size: ".colorize(:light_black) + "#{@the_recipe.serving_size}" if @the_recipe.serving_size != ""
68
+ puts "Calorie count: ".colorize(:light_black) + "#{@the_recipe.calorie_count}" if @the_recipe.calorie_count != ""
69
+ puts ""
70
+ puts "INGREDIENTS:".colorize(:light_red).underline
71
+ @the_recipe.ingredients.each do |ingredient|
72
+ puts "#{ingredient}"
73
+ end
74
+ puts ""
75
+ puts "INSTRUCTIONS:".colorize(:light_red).underline
76
+ @the_recipe.instructions.each.with_index(1) do |instruction, i|
77
+ puts "#{i}.".colorize(:light_black) + " #{instruction}"
78
+ end
79
+ end
80
+
77
81
  def goodbye
78
82
  puts ""
79
83
  puts "Hope you bake something delicious today! See you later!"
@@ -12,7 +12,7 @@ class TodaysTopDesserts::Recipe
12
12
  def self.create_from_collection(recipes_array)
13
13
  #creates new recipes from an array of hashes that include recipe attributes
14
14
  recipes_array.each do |hash|
15
- recipe = TodaysTopDesserts::Recipe.new(hash)
15
+ TodaysTopDesserts::Recipe.new(hash)
16
16
  end
17
17
  end
18
18
 
@@ -4,17 +4,12 @@ class TodaysTopDesserts::Scraper
4
4
  #returns an array of recipes with a name and url.
5
5
  page = Nokogiri::HTML(open("https://www.allrecipes.com/recipes/79/desserts/"))
6
6
 
7
- desserts = []
8
-
9
- page.css("article.list-recipes")[0].css("li")[0..9].each do |dessert|
10
- desserts << {
11
- :name => dessert.css("img").attr("title").text,
7
+ page.css("article.list-recipes")[0].css("li")[0..9].collect do |dessert|
8
+ {:name => dessert.css("img").attr("title").text,
12
9
  :url => dessert.css("a").attr("href").value
13
10
  }
14
11
  end
15
12
 
16
- desserts
17
-
18
13
  end
19
14
 
20
15
  def self.scrape_recipe(recipe_url)
@@ -31,15 +26,9 @@ class TodaysTopDesserts::Scraper
31
26
  recipe[:ready_time] = page.css("time[itemprop='totalTime']").text.strip
32
27
  recipe[:calorie_count] = page.css(".calorie-count").text.strip
33
28
 
34
- recipe[:ingredients] = []
35
- page.css("span[itemprop='ingredients']").each do |ingredient|
36
- recipe[:ingredients] << ingredient.text.strip
37
- end
29
+ recipe[:ingredients] = page.css("span[itemprop='ingredients']").collect {|ingredient| ingredient.text.strip}
38
30
 
39
- recipe[:instructions] = []
40
- page.css("ol[itemprop='recipeInstructions'] span.recipe-directions__list--item").each do |instruction|
41
- recipe[:instructions] << instruction.text.strip
42
- end
31
+ recipe[:instructions] = page.css("ol[itemprop='recipeInstructions'] span.recipe-directions__list--item").collect {|instruction| instruction.text.strip}
43
32
 
44
33
  recipe
45
34
 
@@ -1,3 +1,3 @@
1
1
  module TodaysTopDesserts
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: todays_top_desserts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - krystlebarnes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-03 00:00:00.000000000 Z
11
+ date: 2018-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler