daily_recipe 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/bin/daily_recipe +1 -1
- data/daily_recipe-0.1.0.gem +0 -0
- data/lib/daily_recipe/Recipe.rb +1 -8
- data/lib/daily_recipe/cli.rb +7 -5
- data/lib/daily_recipe/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 186bcd1c8dd1f14c6125ec04fcdd9f558d39a883
|
4
|
+
data.tar.gz: 8698f93d2d6c5892a0c57ce1cf245f6cf3e5b9c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dad02a1f617c5a5f2531d010340a7b4327e0ab2a7f9dacb8889b1d491f99887bae17dbccdeb8d1993fe541baa106e9c73b054ed45a95851ac3f92c9b43ca33c6
|
7
|
+
data.tar.gz: dc788ec81364c5b9aad91ee5d966d99fd3eb0827edf14f5ae0d0f07ff885648347d872300e5c7a1dd702c22561d04484c8a7880291b7466a74802ad3c89d4c1b
|
data/README.md
CHANGED
@@ -21,7 +21,7 @@ Or install it yourself as:
|
|
21
21
|
|
22
22
|
To use this gem, install using 'gem install daily_recipe'.
|
23
23
|
To run, simply type 'daily_recipe' once the gem has been installed.
|
24
|
-
A list of recipes will be loaded. Select an option to get ingredients and
|
24
|
+
A list of recipes will be loaded. Select an option to get ingredients and cooking instructions.
|
25
25
|
|
26
26
|
## Development
|
27
27
|
|
data/bin/daily_recipe
CHANGED
Binary file
|
data/lib/daily_recipe/Recipe.rb
CHANGED
@@ -7,16 +7,10 @@ class DailyRecipe::Recipe
|
|
7
7
|
self.scrape_food_network
|
8
8
|
end
|
9
9
|
|
10
|
-
|
11
|
-
# def self.scrape_recipes
|
12
|
-
# self.scrape_food_network
|
13
|
-
# end
|
14
|
-
|
15
10
|
def self.scrape_food_network
|
16
11
|
recipes = []
|
17
12
|
doc = Nokogiri::HTML(open("http://www.foodnetwork.com/recipes/photos/recipe-of-the-day-what-to-cook-now.html"))
|
18
13
|
doc.search(".feed li").each do |x|
|
19
|
-
#binding.pry
|
20
14
|
recipe = self.new
|
21
15
|
recipe.name = x.search("h6 a").text
|
22
16
|
recipe.cook_time = x.search("dd").text
|
@@ -35,10 +29,9 @@ class DailyRecipe::Recipe
|
|
35
29
|
part1 = recipe_json.text.gsub("gigya._.apiAdapters.web.callback(","")
|
36
30
|
part2 = part1.gsub("});","}")
|
37
31
|
parsed = JSON.parse(part2, symbolize_names: true)
|
38
|
-
#binding.pry
|
39
32
|
rating = parsed[:streamInfo][:avgRatings][:_overall]
|
40
33
|
rating
|
41
|
-
end
|
34
|
+
end #Parses JSON to get access to the gigya API info in order to scrape the ratings information.
|
42
35
|
|
43
36
|
def self.scrape_full_recipe(the_recipe)
|
44
37
|
|
data/lib/daily_recipe/cli.rb
CHANGED
@@ -11,11 +11,13 @@ class DailyRecipe::CLI
|
|
11
11
|
def list_recipes
|
12
12
|
#will get recipes
|
13
13
|
@recipes = DailyRecipe::Recipe.today
|
14
|
-
|
14
|
+
rows = [] # terminal-table formatting
|
15
|
+
rows << ["Number", "Recipe Name", "Rating", "Cooking Time"]
|
15
16
|
@recipes.each.with_index(1) do |recipe, i| #There is a Recipe class with a #today method for today's recipes
|
16
|
-
|
17
|
-
puts "#{i}. #{recipe.name} - #{recipe.rating} - #{recipe.cook_time}"
|
17
|
+
rows << [i, recipe.name, "#{recipe.rating} / 5", recipe.cook_time]
|
18
18
|
end
|
19
|
+
table = Terminal::Table.new :rows => rows #AWESOME!
|
20
|
+
puts table
|
19
21
|
end
|
20
22
|
|
21
23
|
def menu
|
@@ -27,7 +29,7 @@ class DailyRecipe::CLI
|
|
27
29
|
puts "Type exit to exit"
|
28
30
|
input = gets.strip.downcase
|
29
31
|
|
30
|
-
if input.to_i > 0 and input.to_i <= @recipes.count
|
32
|
+
if input.to_i > 0 and input.to_i <= @recipes.count
|
31
33
|
the_recipe = @recipes[input.to_i-1]
|
32
34
|
puts "#{the_recipe.name} - #{the_recipe.rating} - #{the_recipe.cook_time}"
|
33
35
|
DailyRecipe::Recipe.scrape_full_recipe(the_recipe)
|
@@ -43,6 +45,6 @@ class DailyRecipe::CLI
|
|
43
45
|
end
|
44
46
|
|
45
47
|
def goodbye
|
46
|
-
puts "Please
|
48
|
+
puts "Please visit again for more amazing recipes!"
|
47
49
|
end
|
48
50
|
end
|
data/lib/daily_recipe/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: daily_recipe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ian DeVivi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -99,6 +99,7 @@ files:
|
|
99
99
|
- bin/console
|
100
100
|
- bin/daily_recipe
|
101
101
|
- bin/setup
|
102
|
+
- daily_recipe-0.1.0.gem
|
102
103
|
- daily_recipe.gemspec
|
103
104
|
- lib/daily_recipe.rb
|
104
105
|
- lib/daily_recipe/Recipe.rb
|
@@ -124,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
125
|
version: '0'
|
125
126
|
requirements: []
|
126
127
|
rubyforge_project:
|
127
|
-
rubygems_version: 2.
|
128
|
+
rubygems_version: 2.6.6
|
128
129
|
signing_key:
|
129
130
|
specification_version: 4
|
130
131
|
summary: Daily Recipes List
|