randomeal 1.0.1
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 +7 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +14 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/randomeal +9 -0
- data/bin/setup +8 -0
- data/lib/randomeal.rb +6 -0
- data/lib/randomeal/cli.rb +83 -0
- data/lib/randomeal/food.rb +51 -0
- data/lib/randomeal/version.rb +3 -0
- data/randomeal.gemspec +38 -0
- data/spec.md +6 -0
- metadata +134 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 110a2ad675755b07929ff8fff93b2b0a77a0ca40
|
|
4
|
+
data.tar.gz: 84d1e8c7d2db918273b36817ce17425eeef71962
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 84ce556c27d62019efdcb3f9746bf31628a604f6005babbc6d02126d1029ffc828961e707a776d514215b78f11b32219b1b48b6293bc1a7558e95613ebf34c6b
|
|
7
|
+
data.tar.gz: 2e7d34f189a7cd91923932ce0886242d5e6fdfdb0169fb6c91a0e27b8d157bac63cab9fd1d12e9208de9e2a3a06bf2520728fb6be4a6fcecd7ba5732edb9d9a5
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 TODO: Write your name
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Randomeal
|
|
2
|
+
Randomeal is a randomizer app that will allow you to select a meal category from the SeriousEats.com website and return a random meal from that category.
|
|
3
|
+
|
|
4
|
+
## Usage
|
|
5
|
+
|
|
6
|
+
This is a CLI app and requires textual input.
|
|
7
|
+
|
|
8
|
+
## Contributing
|
|
9
|
+
|
|
10
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/goatcheese82/randomeal.
|
|
11
|
+
|
|
12
|
+
## License
|
|
13
|
+
|
|
14
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "randomeal"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start(__FILE__)
|
data/bin/randomeal
ADDED
data/bin/setup
ADDED
data/lib/randomeal.rb
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
class Randomeal::CLI
|
|
2
|
+
|
|
3
|
+
attr_accessor :selection
|
|
4
|
+
|
|
5
|
+
def call
|
|
6
|
+
puts "Thank you for using Randomeal! Your options are loading."
|
|
7
|
+
options
|
|
8
|
+
secondary_menu_options
|
|
9
|
+
secondary_menu
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def options
|
|
13
|
+
puts <<-MENU
|
|
14
|
+
|
|
15
|
+
"-*-*-*-*-*-*-*-*-*"
|
|
16
|
+
|
|
17
|
+
What would you like to eat?
|
|
18
|
+
|
|
19
|
+
1. Chicken
|
|
20
|
+
2. Burgers
|
|
21
|
+
3. Pasta
|
|
22
|
+
4. Salad
|
|
23
|
+
5. Dessert
|
|
24
|
+
MENU
|
|
25
|
+
menu
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def menu
|
|
29
|
+
|
|
30
|
+
input = gets.strip.downcase
|
|
31
|
+
puts "-*-*-*-*-*-*-*-*-*"
|
|
32
|
+
if input == "1" || input == "chicken"
|
|
33
|
+
@selection = Randomeal::Food.new("chicken")
|
|
34
|
+
elsif input == "2" || input == "burgers"
|
|
35
|
+
@selection = Randomeal::Food.new("burger")
|
|
36
|
+
elsif input == "3" || input == "pasta"
|
|
37
|
+
@selection = Randomeal::Food.new("pasta")
|
|
38
|
+
elsif input == "4" || input == "salad"
|
|
39
|
+
@selection = Randomeal::Food.new("salad")
|
|
40
|
+
elsif input == "5" || input == "dessert"
|
|
41
|
+
@selection = Randomeal::Food.new("dessert")
|
|
42
|
+
else puts "That selection is not valid, please select from the list or 'exit'"
|
|
43
|
+
options
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def secondary_menu_options
|
|
49
|
+
puts <<-SECONDARY
|
|
50
|
+
|
|
51
|
+
Your meal is #{@selection.title}
|
|
52
|
+
1. For ingredients
|
|
53
|
+
2. For directions
|
|
54
|
+
3. If you don't want to eat #{@selection.title}
|
|
55
|
+
|
|
56
|
+
Type 'exit' to quit.
|
|
57
|
+
SECONDARY
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def secondary_menu
|
|
62
|
+
|
|
63
|
+
input = nil
|
|
64
|
+
|
|
65
|
+
while input != "exit"
|
|
66
|
+
input = gets.strip.downcase
|
|
67
|
+
if input == "1"
|
|
68
|
+
puts @selection.ingredients
|
|
69
|
+
elsif input == "2"
|
|
70
|
+
puts @selection.directions
|
|
71
|
+
elsif input == "3"
|
|
72
|
+
self.options
|
|
73
|
+
else
|
|
74
|
+
puts "Please make a valid selection or 'exit"
|
|
75
|
+
end
|
|
76
|
+
puts ""
|
|
77
|
+
puts "-*-*-*-*-*-*-*-*-*"
|
|
78
|
+
secondary_menu_options
|
|
79
|
+
puts "-*-*-*-*-*-*-*-*-*"
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
class Randomeal::Food
|
|
2
|
+
|
|
3
|
+
attr_accessor :ingredients, :title, :directions, :url, :option
|
|
4
|
+
|
|
5
|
+
def initialize(option)
|
|
6
|
+
@option = option
|
|
7
|
+
self.scrape_url
|
|
8
|
+
@title = "#{self.scrape_title}"
|
|
9
|
+
@directions = []
|
|
10
|
+
@ingredients = []
|
|
11
|
+
self.scrape_directions
|
|
12
|
+
self.scrape_ingredients
|
|
13
|
+
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## scrapes each option to object
|
|
18
|
+
def scrape_url
|
|
19
|
+
recipe_url = Nokogiri::HTML(open("http://seriouseats.com/tags/recipes/#{@option}"))
|
|
20
|
+
|
|
21
|
+
recipe_links = []
|
|
22
|
+
links = recipe_url.css('.module__link')
|
|
23
|
+
links.each{|link| recipe_links << link['href']}
|
|
24
|
+
|
|
25
|
+
@url = recipe_links.sample
|
|
26
|
+
@url
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def scrape_ingredients
|
|
30
|
+
recipe = Nokogiri::HTML(open("#{@url}"))
|
|
31
|
+
|
|
32
|
+
ingredient = recipe.css('.recipe-ingredients')
|
|
33
|
+
ingredient.each{|i| @ingredients << i.text.strip}
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def scrape_title
|
|
37
|
+
recipe = Nokogiri::HTML(open("#{@url}"))
|
|
38
|
+
|
|
39
|
+
title = recipe.css('.recipe-title').text.strip
|
|
40
|
+
title
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def scrape_directions
|
|
44
|
+
recipe = Nokogiri::HTML(open("#{@url}"))
|
|
45
|
+
|
|
46
|
+
direction_list = recipe.css('.recipe-procedures-list.instructions')
|
|
47
|
+
direction_list.each{|step| @directions << step.text.strip}
|
|
48
|
+
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
end
|
data/randomeal.gemspec
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require "randomeal/version"
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "randomeal"
|
|
8
|
+
spec.version = Randomeal::VERSION
|
|
9
|
+
spec.authors = ["goatcheese82"]
|
|
10
|
+
spec.email = ["nonsquishy@gmail.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{This app will let users select a food category and receive a random recipe}
|
|
13
|
+
spec.description = %q{The recipes are extracted from seriouseats.com}
|
|
14
|
+
spec.homepage = "https://github.com/goatcheese82/randomeal"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
|
19
|
+
if spec.respond_to?(:metadata)
|
|
20
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
|
21
|
+
else
|
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
|
23
|
+
"public gem pushes."
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
|
28
|
+
end
|
|
29
|
+
spec.bindir = "bin"
|
|
30
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
31
|
+
spec.require_paths = ["lib"]
|
|
32
|
+
|
|
33
|
+
spec.add_development_dependency "bundler", "~> 1.15"
|
|
34
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
35
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
36
|
+
spec.add_development_dependency "pry"
|
|
37
|
+
spec.add_dependency "nokogiri"
|
|
38
|
+
end
|
data/spec.md
ADDED
metadata
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: randomeal
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- goatcheese82
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2017-11-25 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.15'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.15'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: pry
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: nokogiri
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :runtime
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
description: The recipes are extracted from seriouseats.com
|
|
84
|
+
email:
|
|
85
|
+
- nonsquishy@gmail.com
|
|
86
|
+
executables:
|
|
87
|
+
- console
|
|
88
|
+
- randomeal
|
|
89
|
+
- setup
|
|
90
|
+
extensions: []
|
|
91
|
+
extra_rdoc_files: []
|
|
92
|
+
files:
|
|
93
|
+
- ".gitignore"
|
|
94
|
+
- ".rspec"
|
|
95
|
+
- ".travis.yml"
|
|
96
|
+
- Gemfile
|
|
97
|
+
- LICENSE.txt
|
|
98
|
+
- README.md
|
|
99
|
+
- Rakefile
|
|
100
|
+
- bin/console
|
|
101
|
+
- bin/randomeal
|
|
102
|
+
- bin/setup
|
|
103
|
+
- lib/randomeal.rb
|
|
104
|
+
- lib/randomeal/cli.rb
|
|
105
|
+
- lib/randomeal/food.rb
|
|
106
|
+
- lib/randomeal/version.rb
|
|
107
|
+
- randomeal.gemspec
|
|
108
|
+
- spec.md
|
|
109
|
+
homepage: https://github.com/goatcheese82/randomeal
|
|
110
|
+
licenses:
|
|
111
|
+
- MIT
|
|
112
|
+
metadata:
|
|
113
|
+
allowed_push_host: https://rubygems.org
|
|
114
|
+
post_install_message:
|
|
115
|
+
rdoc_options: []
|
|
116
|
+
require_paths:
|
|
117
|
+
- lib
|
|
118
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
119
|
+
requirements:
|
|
120
|
+
- - ">="
|
|
121
|
+
- !ruby/object:Gem::Version
|
|
122
|
+
version: '0'
|
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
|
+
requirements:
|
|
125
|
+
- - ">="
|
|
126
|
+
- !ruby/object:Gem::Version
|
|
127
|
+
version: '0'
|
|
128
|
+
requirements: []
|
|
129
|
+
rubyforge_project:
|
|
130
|
+
rubygems_version: 2.4.8
|
|
131
|
+
signing_key:
|
|
132
|
+
specification_version: 4
|
|
133
|
+
summary: This app will let users select a food category and receive a random recipe
|
|
134
|
+
test_files: []
|