top-recipes 0.1.0 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e5198ccbc905e56e9ba06ca3bbbc9b6545ff1929
4
- data.tar.gz: f09a7d0bbc1a15973addd86a8356ded62cf56727
3
+ metadata.gz: 6f0b8f39323ee924f4274ccf9162a32764bb134f
4
+ data.tar.gz: 7c7581af55c3861f544a5b2c07f6e16038d2bef0
5
5
  SHA512:
6
- metadata.gz: dcae9743c4cf564bf6b00adf4fdbac88e8165480b42c5d6f734159864a6df5bbc2643c11a4442d34c2eeb8db9a23765df05660f9fcd9eef769357ff73205c7ae
7
- data.tar.gz: ca8fc1e51e79631e6f20185c14a2c2b2921dad5f7b0f91995d571fdfb4373232da8031e8a37f63467230f6b17f30842b98dc1b3f211061628c0e2b58180ca11a
6
+ metadata.gz: 2bec8aab8b682f66b90b17e64758a310f809f38d4f71573e1c04ff2e01b01f083af257e6923d61b7f1927dea0dd2f3d6efbc30370b0c383151adee3684c6c2fa
7
+ data.tar.gz: 9b512a942d355a58821982bd6d0ab48444c144a1a1bfef87cdc86c9496be9e7f460de6768dc9b16fec28c5c078a614cf5b7ce5d0c333d63efe8df325cb0e435f
data/README.md CHANGED
@@ -7,7 +7,7 @@ This gem is a CLI to browse through the latest recipes on food2fork with some hu
7
7
  Add this line to your application's Gemfile:
8
8
 
9
9
  ```ruby
10
- gem 'top_recipes'
10
+ gem 'top-recipes'
11
11
  ```
12
12
 
13
13
  And then execute:
@@ -16,7 +16,7 @@ And then execute:
16
16
 
17
17
  Or install it yourself as:
18
18
 
19
- $ gem install top_recipes
19
+ $ gem install top-recipes
20
20
 
21
21
  ## Usage
22
22
 
@@ -27,6 +27,7 @@ Run the gem, and ask her to list you recipes with the 'list recipes' command. An
27
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
28
 
29
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
+ https://rubygems.org/gems/top-recipes
30
31
 
31
32
  ## Contributing
32
33
 
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
data/lib/errors.rb ADDED
@@ -0,0 +1,3 @@
1
+ class InvalidType < StandardError
2
+
3
+ end
@@ -12,7 +12,7 @@ class TopRecipes::CLI
12
12
 
13
13
  def self.greeting
14
14
  self.line_break
15
- puts "Hello! Please ask me to show you some of my latest recipes by typing 'list recipes'. You can also ask me to tell you a joke by typing 'joke'. You can also type 'exit' or 'bye' when you need to go."
15
+ puts "Hello! Please ask me to show you some of my latest recipes by typing 'list recipes'. You can also ask me to tell you a joke by typing 'joke'. Type 'exit' or 'bye' when you need to go."
16
16
 
17
17
  @input = gets.strip
18
18
 
@@ -30,7 +30,7 @@ class TopRecipes::CLI
30
30
  self.list_recipes_greeting
31
31
 
32
32
  else
33
- puts "Our app is having technical difficulties and we have no recipes :( Maybe you would like to here a 'joke' instead?"
33
+ puts "Our app is having technical difficulties and we have no recipes :( Maybe you would like to hear a 'joke' instead?"
34
34
  @input = gets.strip
35
35
 
36
36
  self.possible_commands
@@ -61,10 +61,17 @@ class TopRecipes::CLI
61
61
  puts "---------- Ingredients: ----------"
62
62
  self.list_ingredients(recipe)
63
63
  self.line_break
64
- puts "To find the direction go #{recipe.author}'s site at:"
65
- puts "#{recipe.directions}"
64
+ puts "Directions are at the #{recipe.author}'s site:"
65
+ puts "#{recipe.directions}. Type 'open' to open the link, or any of our other helpful commands: #{self.commands_available}"
66
66
 
67
- self.again_or_close
67
+ @input = gets.strip
68
+
69
+ if @input.downcase.strip == "open"
70
+ system("open #{recipe.directions}")
71
+ self.again_or_close
72
+ else
73
+ self.possible_commands
74
+ end
68
75
  end
69
76
 
70
77
  def self.line_break
@@ -74,13 +81,17 @@ class TopRecipes::CLI
74
81
  puts ""
75
82
  end
76
83
 
84
+ def self.commands_available
85
+ "'list recipes', 'joke', or 'exit'"
86
+ end
87
+
77
88
  def self.list_ingredients(recipe)
78
89
  recipe.ingredients.each.with_index(1) {|i, k| puts "#{k}. #{i}"}
79
90
  end
80
91
 
81
92
 
82
93
  def self.possible_commands
83
- case @input.downcase
94
+ case @input.downcase.strip
84
95
  when "list recipes"
85
96
  self.list_recipes
86
97
  when "joke"
@@ -96,7 +107,7 @@ class TopRecipes::CLI
96
107
 
97
108
  def self.no_match
98
109
  self.line_break
99
- puts "Sorry! I do not understand what '#{@input}' is! Try one of these commands: 'list recipes', 'joke', 'exit'"
110
+ puts "Sorry! I do not understand what '#{@input}' is! Try one of these commands: #{self.commands_available}"
100
111
 
101
112
  @input = gets.strip
102
113
 
@@ -17,7 +17,7 @@ class TopRecipes::Scraper
17
17
  end
18
18
 
19
19
  def self.scrape_additional_info(recipe)
20
- raise error if !(recipe.is_a?(TopRecipes::Recipe))
20
+ raise InvalidType, "#{recipe} is a #{recipe.class}. Expected #{recipe} to be a Recipe class" if !(recipe.is_a?(TopRecipes::Recipe))
21
21
  site = self.scrape_recipes_page(recipe.url)
22
22
 
23
23
  recipe.ingredients = site.css("div.span5 ul").text.strip.split("\n\t\t\t\t\n\t\t\t\t ")
@@ -1,3 +1,3 @@
1
1
  module TopRecipes
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: top-recipes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - mxdavis
@@ -78,9 +78,11 @@ files:
78
78
  - Gemfile
79
79
  - README.md
80
80
  - Rakefile
81
+ - SPEC.MD
81
82
  - bin/console
82
83
  - bin/setup
83
84
  - bin/top-recipes
85
+ - lib/errors.rb
84
86
  - lib/top_recipes.rb
85
87
  - lib/top_recipes/cli.rb
86
88
  - lib/top_recipes/jokes.rb