recipe_book 0.1.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 +7 -0
- data/.gitignore +9 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE.md +21 -0
- data/README.md +35 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/recipe-book +6 -0
- data/bin/setup +8 -0
- data/lib/recipe_book/cli.rb +73 -0
- data/lib/recipe_book/recipe.rb +47 -0
- data/lib/recipe_book/version.rb +3 -0
- data/lib/recipe_book.rb +8 -0
- data/recipe_book-0.1.0.gem +0 -0
- data/recipe_book-0.1.1.gem +0 -0
- data/recipe_book.gemspec +23 -0
- metadata +118 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: be6858be1678b6d11abe9ccad566b9096d1f60e4
|
4
|
+
data.tar.gz: 75b0fd2716293e3c643ab03d59e4083780175a27
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cd52a96a186ab8e4fee409f29c1998da3500a7448db4fa1a127b54d921764bd6832af91ede6f444ea860e9dd0158b66f893d923bb6a91cc5a2990da083b8d031
|
7
|
+
data.tar.gz: e04fe17ff234d82c0919b711657dc3692ffe63f10f7cdf1854f2ae6f6646b163a43bad58a171f9775f12d61ea170f68c7a49eeb42309770b395a3b4cee046aa1
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at andrewstone8@gmail.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Andrew Stone
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# RecipeBook
|
2
|
+
|
3
|
+
This gem can be used as a quick guide to making some of the most popular alcoholic drinks.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'recipe_book'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install recipe_book
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Run: `recipe-book` after installing the gem.
|
24
|
+
|
25
|
+
## Development
|
26
|
+
|
27
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
28
|
+
|
29
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
30
|
+
|
31
|
+
## Contributing
|
32
|
+
|
33
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/recipe_book. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
34
|
+
|
35
|
+
# a-recipe-book-cli-gem
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "recipe_book"
|
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
|
data/bin/recipe-book
ADDED
data/bin/setup
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# CLI Controller
|
2
|
+
|
3
|
+
class RecipeBook::CLI
|
4
|
+
|
5
|
+
def call
|
6
|
+
welcome
|
7
|
+
start
|
8
|
+
end
|
9
|
+
|
10
|
+
def welcome
|
11
|
+
puts "----------- Classic Mixed Drink Recipe Book -----------"
|
12
|
+
puts ''
|
13
|
+
end
|
14
|
+
|
15
|
+
def list_recipes
|
16
|
+
puts "--------------------- Drink List ---------------------"
|
17
|
+
puts ''
|
18
|
+
RecipeBook::Recipe.all.each.with_index(1) do |r, i|
|
19
|
+
puts "#{i}. #{r.name}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def start
|
24
|
+
puts ''
|
25
|
+
list_recipes
|
26
|
+
|
27
|
+
input = nil
|
28
|
+
while input != "exit"
|
29
|
+
puts ''
|
30
|
+
puts ''
|
31
|
+
puts "What are you in the mood for?"
|
32
|
+
puts ''
|
33
|
+
puts "Enter the number of the drink recipe you want to see."
|
34
|
+
puts ''
|
35
|
+
input = gets.strip.to_i
|
36
|
+
|
37
|
+
recipe = RecipeBook::Recipe.find(input.to_i)
|
38
|
+
|
39
|
+
show_recipe(recipe)
|
40
|
+
puts ''
|
41
|
+
puts "Want to see a different recipe? Enter 'yes' or 'no'."
|
42
|
+
puts ''
|
43
|
+
input = gets.strip.downcase
|
44
|
+
case input
|
45
|
+
when "yes"
|
46
|
+
start
|
47
|
+
when 'no'
|
48
|
+
puts ''
|
49
|
+
puts "Cheers!"
|
50
|
+
puts ''
|
51
|
+
exit
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end # => end of start method
|
55
|
+
|
56
|
+
def show_recipe(recipe)
|
57
|
+
puts ''
|
58
|
+
puts "--------------------- #{recipe.name.upcase} ---------------------"
|
59
|
+
puts ""
|
60
|
+
puts "#{recipe.description}"
|
61
|
+
puts ""
|
62
|
+
puts " Ingredients"
|
63
|
+
puts "---------------"
|
64
|
+
puts "#{recipe.ingredients}"
|
65
|
+
puts ""
|
66
|
+
puts " Instructions"
|
67
|
+
puts "---------------"
|
68
|
+
puts "#{recipe.instructions}"
|
69
|
+
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
end # => end class
|
@@ -0,0 +1,47 @@
|
|
1
|
+
class RecipeBook::Recipe
|
2
|
+
|
3
|
+
attr_accessor :name, :url, :description, :ingredients, :instructions
|
4
|
+
|
5
|
+
def initialize(name = nil, url = nil)
|
6
|
+
@name = name
|
7
|
+
@url = url
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.all
|
11
|
+
@@all ||= scrape_recipes
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
def self.find(id)
|
16
|
+
self.all[id-1]
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.scrape_recipes
|
20
|
+
#go to url with list of drinks
|
21
|
+
#pulls names of drinks from page
|
22
|
+
#pulls url of drink page
|
23
|
+
#creates a new instance of Recipe with name and url arguments
|
24
|
+
|
25
|
+
doc = Nokogiri::HTML(open("http://food.ndtv.com/lists/be-your-own-bartender-10-best-cocktail-recipes-751639"))
|
26
|
+
names = doc.search("span p strong a").collect {|n| n.text.strip}
|
27
|
+
url = doc.search("span p strong a").collect {|url| url.attr("href")}
|
28
|
+
arr = names.zip(url)
|
29
|
+
arr.collect {|n|new(n[0],n[1])}
|
30
|
+
end
|
31
|
+
|
32
|
+
def description
|
33
|
+
doc = Nokogiri::HTML(open(self.url))
|
34
|
+
self.description = doc.search(".summaryrecipe").text
|
35
|
+
end
|
36
|
+
|
37
|
+
def ingredients
|
38
|
+
doc = Nokogiri::HTML(open(self.url))
|
39
|
+
self.ingredients = doc.search(".ingredient").text
|
40
|
+
end
|
41
|
+
|
42
|
+
def instructions
|
43
|
+
doc = Nokogiri::HTML(open(self.url))
|
44
|
+
self.instructions = doc.search(".instructions").text
|
45
|
+
end
|
46
|
+
|
47
|
+
end # => end recipe class
|
data/lib/recipe_book.rb
ADDED
Binary file
|
Binary file
|
data/recipe_book.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'recipe_book/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "recipe_book"
|
8
|
+
spec.version = RecipeBook::VERSION
|
9
|
+
spec.authors = ["andrewstone8"]
|
10
|
+
spec.email = ["andrewstone8@gmail.com"]
|
11
|
+
spec.summary = "This is a classic mixed drink recipe book."
|
12
|
+
spec.homepage = "https://github.com/andrewstone8/a-recipe-book-cli-gem/"
|
13
|
+
|
14
|
+
spec.files = `git ls-files`.split($\)
|
15
|
+
spec.executables = ["recipe-book"]
|
16
|
+
spec.require_paths = ["lib", "lib/recipe_book"]
|
17
|
+
spec.license = "MIT"
|
18
|
+
|
19
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
20
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
21
|
+
spec.add_development_dependency "pry"
|
22
|
+
spec.add_development_dependency "nokogiri", ">= 0"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: recipe_book
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.5
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- andrewstone8
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-06-24 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.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
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: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: nokogiri
|
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
|
+
description:
|
70
|
+
email:
|
71
|
+
- andrewstone8@gmail.com
|
72
|
+
executables:
|
73
|
+
- recipe-book
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- CODE_OF_CONDUCT.md
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.md
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/console
|
84
|
+
- bin/recipe-book
|
85
|
+
- bin/setup
|
86
|
+
- lib/recipe_book.rb
|
87
|
+
- lib/recipe_book/cli.rb
|
88
|
+
- lib/recipe_book/recipe.rb
|
89
|
+
- lib/recipe_book/version.rb
|
90
|
+
- recipe_book-0.1.0.gem
|
91
|
+
- recipe_book-0.1.1.gem
|
92
|
+
- recipe_book.gemspec
|
93
|
+
homepage: https://github.com/andrewstone8/a-recipe-book-cli-gem/
|
94
|
+
licenses:
|
95
|
+
- MIT
|
96
|
+
metadata: {}
|
97
|
+
post_install_message:
|
98
|
+
rdoc_options: []
|
99
|
+
require_paths:
|
100
|
+
- lib
|
101
|
+
- lib/recipe_book
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
requirements: []
|
113
|
+
rubyforge_project:
|
114
|
+
rubygems_version: 2.4.5.1
|
115
|
+
signing_key:
|
116
|
+
specification_version: 4
|
117
|
+
summary: This is a classic mixed drink recipe book.
|
118
|
+
test_files: []
|