daily_recipes 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 012b88e548f0a1bf91882f54a5c68c25af31115c
4
+ data.tar.gz: 0a3f5cc4e29e823a0a16b4228bd3951cb3c70e81
5
+ SHA512:
6
+ metadata.gz: f14e688b401b5d7d7cbb5e5dd313beeb5885037ee86f8faa3c48a7012c9674d156df3a8281dfb393d3c057deb08bb929cfbaa1ac50de87e81280cceba2d47446
7
+ data.tar.gz: 63b1ebb32bbe7bb7ebc0d8b29dd171639e50810b2dd6a7fc2165ce616c870f8fcbaf817d21f664fa646c9560e17e6fdeb6b22c0050056501a198852d816c5625
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in daily-recipes.gemspec
4
+ gemspec
@@ -0,0 +1,39 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ daily-recipes (0.1.0)
5
+ nokogiri
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ diff-lcs (1.3)
11
+ mini_portile2 (2.1.0)
12
+ nokogiri (1.7.2)
13
+ mini_portile2 (~> 2.1.0)
14
+ rake (10.5.0)
15
+ rspec (3.6.0)
16
+ rspec-core (~> 3.6.0)
17
+ rspec-expectations (~> 3.6.0)
18
+ rspec-mocks (~> 3.6.0)
19
+ rspec-core (3.6.0)
20
+ rspec-support (~> 3.6.0)
21
+ rspec-expectations (3.6.0)
22
+ diff-lcs (>= 1.2.0, < 2.0)
23
+ rspec-support (~> 3.6.0)
24
+ rspec-mocks (3.6.0)
25
+ diff-lcs (>= 1.2.0, < 2.0)
26
+ rspec-support (~> 3.6.0)
27
+ rspec-support (3.6.0)
28
+
29
+ PLATFORMS
30
+ ruby
31
+
32
+ DEPENDENCIES
33
+ bundler (~> 1.14)
34
+ daily-recipes!
35
+ rake (~> 10.0)
36
+ rspec (~> 3.0)
37
+
38
+ BUNDLED WITH
39
+ 1.15.0
@@ -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.
@@ -0,0 +1,37 @@
1
+ How to build a CLI Gem
2
+
3
+ 1. Plan your gem, imagine your interface-
4
+ 2. Start with the project structure - Google
5
+ 3. Start with the entry point - the file run
6
+ 4. Force that to build the CLI interface
7
+ 5. Stub out the interface
8
+ 6. Start making things real
9
+ 7. Discover objects
10
+ 8. Program
11
+
12
+ A command line interface for a daily recipe starting with Tamouse's blog
13
+
14
+ Show today's recipe.
15
+ Meal name - small description
16
+
17
+ Select 'recipe card' or 'exit'
18
+ recipe card
19
+
20
+ Full recipe card:
21
+ Title of Meal(scrape)
22
+ Ingredients
23
+ (scrape all list items)
24
+ Directions
25
+ (scrape all list items)
26
+
27
+ exit
28
+
29
+ say goodbye
30
+
31
+
32
+ Hello, I don't have a working mic but this is a 30 minute session of coding with me, Amanda.
33
+
34
+ I have built an app to scrape a recipe site to create a daily recipe and deliver a recipe card if wanted. I will be working on the second level of scraping so a recipe card can be created.
35
+
36
+
37
+ Time to call it a night. Thanks for watching. Sorry I couldn't narrate. Have a good one!
@@ -0,0 +1,41 @@
1
+ # Daily Recipes CLI App
2
+
3
+ ## Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem 'daily-recipes'
9
+ ```
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install daily-recipes
18
+
19
+ ## Usage
20
+
21
+ To run after installation:
22
+
23
+ $ daily-recipes
24
+
25
+ At open the title of a recipe will be delivered as the recipe of the day. If you would like the full recipe for the meal type "recipe", or if you are not interested in the meal you may end the program with "exit".
26
+
27
+
28
+ ## Development
29
+
30
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
31
+
32
+ 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).
33
+
34
+ ## Contributing
35
+
36
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ageorge0160/daily-recipes-cli-app.
37
+
38
+
39
+ ## License
40
+
41
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "daily/recipes"
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__)
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+
4
+ require './lib/daily_recipes'
5
+
6
+ DailyRecipe.new.call
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'daily_recipes/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "daily_recipes"
8
+ spec.version = DailyRecipes::VERSION
9
+ spec.authors = ["Amanda George"]
10
+ spec.email = ["ageorge0160@gmail.com"]
11
+
12
+ spec.summary = "A gem used to deliver one recipe for a daily meal"
13
+ spec.description = "A randomly selected recipe from pinchofyum.com delivered with the option to see the recipe for a new meal each day."
14
+ spec.homepage = "https://github.com/ageorge0160/daily-recipes-cli-app"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.14"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rspec", "~> 3.0"
27
+ spec.add_dependency "nokogiri", "~> 1.7"
28
+
29
+
30
+ end
@@ -0,0 +1,7 @@
1
+ require 'pry'
2
+ require 'nokogiri'
3
+ require 'open-uri'
4
+
5
+ require_relative "./daily_recipes/version"
6
+ require_relative "./daily_recipes/recipe"
7
+ require_relative "./daily_recipes/cli"
@@ -0,0 +1,43 @@
1
+ class DailyRecipes
2
+
3
+ def call
4
+ todays_meal
5
+ list_daily_meal
6
+ show_recipe_card
7
+ end
8
+
9
+ def todays_meal
10
+ @todays_meal = Recipe.today
11
+ end
12
+
13
+ def list_daily_meal
14
+ puts "-------------- Meal of the day: --------------"
15
+ puts "#{@todays_meal.name}"
16
+ puts "----------------------------------------------"
17
+ puts ""
18
+ end
19
+
20
+ def show_recipe_card
21
+ input = nil
22
+ while input != "exit"
23
+ puts "Select 'recipe' or 'exit'"
24
+ input = gets.strip.downcase
25
+
26
+ case input
27
+ when "recipe"
28
+ @todays_meal.get_recipe
29
+ puts "----------------------------------------------"
30
+ puts "Ingredients:"
31
+ @todays_meal.ingredients.each {|ingredient| puts "-#{ingredient}"}
32
+ puts ""
33
+ puts "Directions:"
34
+ @todays_meal.directions.each_with_index {|step, index| puts "#{index + 1}. #{step}\n\n"}
35
+ puts "----------------------------------------------"
36
+ when "exit"
37
+ puts "Goodbye"
38
+ else
39
+ puts "Please try again"
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,35 @@
1
+ class Recipe
2
+
3
+ attr_accessor :name, :url, :ingredients, :directions
4
+
5
+ @@recipes = []
6
+
7
+ def initialize(name = nil, url = nil)
8
+ @name = name
9
+ @url = url
10
+ @ingredients = []
11
+ @directions = []
12
+ end
13
+
14
+ def self.create
15
+ doc = Nokogiri::HTML(open("http://pinchofyum.com/recipes"))
16
+ doc.css("article.post-summary").each do |tile|
17
+ recipe = self.new
18
+ recipe.name = tile.css(".caption").text.strip
19
+ recipe.url = tile.css(".block-link").attribute("href").value
20
+ @@recipes << recipe
21
+ end
22
+ end
23
+
24
+ def self.today
25
+ self.create
26
+ @@recipes.sample
27
+ end
28
+
29
+ def get_recipe
30
+ doc2 = Nokogiri::HTML(open(self.url))
31
+
32
+ doc2.css("div.tasty-recipes-ingredients ul li").each {|item| @ingredients << item.text}
33
+ doc2.css("div.tasty-recipes-instructions ol li").each {|step| @directions << step.text}
34
+ end
35
+ end
@@ -0,0 +1,3 @@
1
+ module DailyRecipes
2
+ VERSION = "0.1.0"
3
+ end
data/spec.md ADDED
@@ -0,0 +1,6 @@
1
+ # Specifications for the CLI Assessment
2
+
3
+ Specs:
4
+ - [X] Have a CLI for interfacing with the application
5
+ - [X] Pull data from an external source
6
+ - [X] Implement both list and detail views
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: daily_recipes
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Amanda George
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-05-28 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.14'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.14'
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: nokogiri
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.7'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.7'
69
+ description: A randomly selected recipe from pinchofyum.com delivered with the option
70
+ to see the recipe for a new meal each day.
71
+ email:
72
+ - ageorge0160@gmail.com
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - Gemfile
78
+ - Gemfile.lock
79
+ - LICENSE.txt
80
+ - NOTES.md
81
+ - README.md
82
+ - Rakefile
83
+ - bin/console
84
+ - bin/daily_recipes
85
+ - bin/setup
86
+ - daily_recipes.gemspec
87
+ - lib/daily_recipes.rb
88
+ - lib/daily_recipes/cli.rb
89
+ - lib/daily_recipes/recipe.rb
90
+ - lib/daily_recipes/version.rb
91
+ - spec.md
92
+ homepage: https://github.com/ageorge0160/daily-recipes-cli-app
93
+ licenses:
94
+ - MIT
95
+ metadata: {}
96
+ post_install_message:
97
+ rdoc_options: []
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubyforge_project:
112
+ rubygems_version: 2.4.8
113
+ signing_key:
114
+ specification_version: 4
115
+ summary: A gem used to deliver one recipe for a daily meal
116
+ test_files: []