world_top_movies 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/world_top_movies/cli.rb +3 -5
- data/lib/world_top_movies/models/user.rb +1 -1
- data/lib/world_top_movies/movie.rb +2 -2
- data/lib/world_top_movies/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a98ab67283e9439f81332e7e494672145b76f6020727839f621955a8cd224268
|
4
|
+
data.tar.gz: ebefb797221d253e1b41b6a56aa5a06404f04a035ea6a9bb9c5a0475c2fc5ad2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24165ffbe552db54d5ce71e37dd67de8e4aa5a0230e8d70d614375e4933cccbc54f6e9ac83f379a3cf05855fe4e0d3171aafc064f4b8363d6779e5078e5c8fd8
|
7
|
+
data.tar.gz: 7a333bf87e0cc93f1f85becf96b3a1a09db69875a14220c71ee698d1eddefd28a5877883ef4084182b76426d9f253d9a8945f4dfcca08486497944dc7964e26f
|
data/Gemfile.lock
CHANGED
data/lib/world_top_movies/cli.rb
CHANGED
@@ -110,7 +110,7 @@ class WorldTopMovies::CLI
|
|
110
110
|
sleep(0.5)
|
111
111
|
puts ""
|
112
112
|
movie_url = self.class.prompt.select(
|
113
|
-
"Select a movie: ", WorldTopMovies::Movie.all_titles_and_links_hash_by_genre(self.genre), enum: ")"
|
113
|
+
"Select a movie: ", WorldTopMovies::Movie.all_titles_and_links_hash_by_genre(self.genre), enum: ")",
|
114
114
|
)
|
115
115
|
self.movie_instance = WorldTopMovies::Movie.find_by_url(movie_url)
|
116
116
|
self.movie_instance.scrape_and_print_movie
|
@@ -153,7 +153,6 @@ class WorldTopMovies::CLI
|
|
153
153
|
def add_favourite_movie
|
154
154
|
# Finds or creates a new Favourite movie instance and adds it to the database
|
155
155
|
sleep(0.5)
|
156
|
-
# add_to_favourite = self.class.prompt.yes?("\nWould you like to add this movie to your favourites?")
|
157
156
|
if self.class.user.movies.none? { |m| m.url == self.movie_instance.url }
|
158
157
|
WorldTopMovies::DB::Movie.add_movies(user: self.class.user, movie_urls: self.movie_instance.url)
|
159
158
|
puts "\n#{self.movie_instance.title} has been added to your favourite movies!"
|
@@ -194,9 +193,8 @@ class WorldTopMovies::CLI
|
|
194
193
|
puts "\nOops, you haven't favourited any movies yet!!"
|
195
194
|
else
|
196
195
|
puts ""
|
197
|
-
|
198
196
|
movie_url = self.class.prompt.select(
|
199
|
-
"Select a movie: ", self.class.user.favourite_movie_titles, enum: ")"
|
197
|
+
"Select a movie: ", self.class.user.favourite_movie_titles, enum: ")",
|
200
198
|
)
|
201
199
|
WorldTopMovies::DB::Movie.all.find { |m| m.url == movie_url }.print_movie_details
|
202
200
|
end
|
@@ -264,7 +262,7 @@ class WorldTopMovies::CLI
|
|
264
262
|
else
|
265
263
|
puts ""
|
266
264
|
movie_url = self.class.prompt.select(
|
267
|
-
"Select a movie: ", self.class.user.movies_with_notes_titles, enum: ")"
|
265
|
+
"Select a movie: ", self.class.user.movies_with_notes_titles, enum: ")",
|
268
266
|
)
|
269
267
|
WorldTopMovies::DB::Movie.all.find { |m| m.url == movie_url }.print_movie_details
|
270
268
|
end
|
@@ -14,7 +14,7 @@ class WorldTopMovies::DB::User < ActiveRecord::Base
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def favourite_movie_titles
|
17
|
-
#
|
17
|
+
# Returns a hash with key=title, value=url of all fav movies
|
18
18
|
result = {}
|
19
19
|
self.movies.sort_by { |m| m.title }.each { |m| result[m.title] = m.url }
|
20
20
|
result
|
@@ -52,7 +52,7 @@ class WorldTopMovies::Movie
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def self.all_titles_and_links_hash
|
55
|
-
#
|
55
|
+
# Returns a hash with key=title, value=url of all movie instances
|
56
56
|
result = {}
|
57
57
|
self.all.each do |m|
|
58
58
|
result[m.title] = m.url
|
@@ -61,7 +61,7 @@ class WorldTopMovies::Movie
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def self.all_titles_and_links_hash_by_genre(genre)
|
64
|
-
#
|
64
|
+
# Returns a hash with key=title, value=url of all movie instances from given genre
|
65
65
|
result = {}
|
66
66
|
counter = 1
|
67
67
|
self.all_by_genre(genre).each do |m|
|