budget-bytes-cli 0.2.0 → 0.2.5
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.
- checksums.yaml +4 -4
- data/lib/budget_bytes_cli/cli.rb +13 -9
- data/lib/budget_bytes_cli/recipe.rb +33 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12a8bab68c36e2b65a58f41cd043d44be8ece494
|
4
|
+
data.tar.gz: 9b8f70703bd4b0cfa7f168e2afce4fbf03904695
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1b2ca52479cfa64582d3f93ef8eca61398380cc21f600db69199ab5107477824849cef206fd59a8521c2f2afecb93d99f251af82bec433ec5b91e73d8960347
|
7
|
+
data.tar.gz: 1a975893f5afb10fe1ac6cedf19d104f5d77130c96fc72e4dafb2023d755d5d2556873240b98d4eb2598f9c8c033414a8ce434ade925e7bf1f367799dcf29db2
|
data/lib/budget_bytes_cli/cli.rb
CHANGED
@@ -73,15 +73,19 @@ class BudgetBytesCli::CLI
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def display_recipe(recipe_chosen)
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
76
|
+
if recipe_chosen.ingredients == "" || recipe_chosen.instructions == ""
|
77
|
+
puts "Error! Could not scrape recipe from page selected!"
|
78
|
+
else
|
79
|
+
puts recipe_chosen.name
|
80
|
+
puts "\nIngredients\n"
|
81
|
+
puts recipe_chosen.ingredients
|
82
|
+
puts ""
|
83
|
+
page_width = IO.console.winsize[1]
|
84
|
+
puts reformat_wrapped(recipe_chosen.instructions, page_width || 80)
|
85
|
+
puts ""
|
86
|
+
if yes_no_input("Do you want to open this recipe in your browser?") == 'Y'
|
87
|
+
Launchy.open(recipe_chosen.url)
|
88
|
+
end
|
85
89
|
end
|
86
90
|
end
|
87
91
|
|
@@ -13,12 +13,42 @@ class BudgetBytesCli::Recipe
|
|
13
13
|
ingredient_units = page.css('.wprm-recipe-ingredient-unit').map {|i| i.text}
|
14
14
|
ingredient_names = page.css('.wprm-recipe-ingredient-name').map {|i| i.text}
|
15
15
|
|
16
|
-
ingredient_array =
|
17
|
-
|
16
|
+
ingredient_array = []
|
17
|
+
|
18
|
+
ingredient_amounts.each_with_index do |ele, idx|
|
19
|
+
ingredient_array << [ele, ingredient_units[idx], ingredient_names[idx]].join(' ').strip
|
20
|
+
end
|
21
|
+
|
22
|
+
#scraping for old site before css switched so that the code above scrapes ingredients
|
23
|
+
old_ingredients_table = page.css("tr")
|
24
|
+
|
25
|
+
#get rid of first, last rows in table (header and total cost)
|
26
|
+
old_ingredients_table.shift
|
27
|
+
old_ingredients_table.pop
|
28
|
+
|
29
|
+
old_ingredients_table.each do |old_ingredient|
|
30
|
+
old_ingredient_text = old_ingredient.text.split("\n")
|
31
|
+
|
32
|
+
#get rid of first blank item, last cost item
|
33
|
+
old_ingredient_text.shift
|
34
|
+
old_ingredient_text.pop
|
35
|
+
|
36
|
+
ingredient_array << old_ingredient_text.join(" ")
|
18
37
|
end
|
38
|
+
|
39
|
+
recipe_steps = []
|
40
|
+
|
41
|
+
#scraping for old site before css switched to have recipe instructions in own class
|
42
|
+
page.css("p").map {|i| i.text}.each do |p|
|
43
|
+
if p.split(" ")[0] == "STEP"
|
44
|
+
recipe_steps << p.split(" ").slice(2, p.length - 2).join(" ")
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
page.css(".wprm-recipe-instruction-text").each {|i| recipe_steps << i.text}
|
19
49
|
|
20
50
|
@ingredients = ingredient_array.join("\n")
|
21
|
-
@instructions =
|
51
|
+
@instructions = recipe_steps.join("\n")
|
22
52
|
end
|
23
53
|
|
24
54
|
def ingredients
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: budget-bytes-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Larry Weinstein
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|