whats-on-netflix 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0b74c2519e25a0d7d6e5bf89c787016625c33544
4
- data.tar.gz: 5ce3182c8e61f37b56364d11b8f9cdf8d63f7e5a
3
+ metadata.gz: ade207f9921963bbc2c2f21e7300c23a67ed317c
4
+ data.tar.gz: 914812a8de7b4e84407b4e79851b4e0196d2889b
5
5
  SHA512:
6
- metadata.gz: cb1ff9ee2494195c0e30fa029c9ce944f1d16ae69bc9bf956c851a557416029ec149bea1b4aa69daeb637ed7291f67985137d87a75993fd5029ca99c1f9e12e5
7
- data.tar.gz: f88e574686147a35c66fc578d0821d99d1e524d307183211dda28298b6b780ecef98b4daf21047cacf02164bccd314bbfb1689e10ed410af652855d27cac0163
6
+ metadata.gz: b66c881ddaebd4be9f8a29a3a1798c435786ed076936fea9cedd3c7e945bfff1c87ebfaebbc12604b84156e9287da57f76da5d092d7b45675d42d40ea9a6bb70
7
+ data.tar.gz: 79631c54ac424a4e6239853e63ac40ec4efb04e301c36325d9991d5e81e9c358368f06a95f24ca1b3e35b7b26127399bf79aa03cdf59752e3b351c3f9d523dd7
data/README.md CHANGED
@@ -14,13 +14,13 @@ Run `whats-on-netflix` to get started. Then run `coming-soon` or `leaving-soon`
14
14
 
15
15
  ## Development
16
16
 
17
- 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.
17
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
18
18
 
19
19
  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).
20
20
 
21
21
  ## Contributing
22
22
 
23
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/new_on_netflix. 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.
23
+ Bug reports and pull requests are welcome on GitHub at [https://github.com/radditude/whats-on-netflix-cli-gem](https://github.com/radditude/whats-on-netflix-cli-gem). 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.
24
24
 
25
25
 
26
26
  ## License
@@ -3,7 +3,7 @@
3
3
  module WhatsOnNetflix
4
4
  class CLI
5
5
  attr_accessor:input
6
-
6
+
7
7
  def initialize
8
8
  WhatsOnNetflix::ComingSoon.add_movies
9
9
  WhatsOnNetflix::LeavingSoon.add_movies
@@ -13,50 +13,60 @@ module WhatsOnNetflix
13
13
  puts "Welcome to What's On Netflix!"
14
14
  puts "============================="
15
15
  end
16
-
16
+
17
17
  def start
18
18
  while !exit?
19
19
  list_available_commands
20
-
20
+
21
21
  if @input == "coming-soon"
22
22
  WhatsOnNetflix::ComingSoon.list
23
23
  list_options
24
-
24
+
25
25
  while !exit? && !back?
26
26
  if valid_number?(WhatsOnNetflix::ComingSoon.all)
27
+ begin
27
28
  WhatsOnNetflix::ComingSoon.item(@input)
29
+ rescue
30
+ puts ""
31
+ puts "Sorry, we couldn't get info for this title!"
32
+ end
28
33
  item_options
29
- else
34
+ else
30
35
  unknown_command
31
36
  end
32
37
  end
33
-
38
+
34
39
  elsif @input == "leaving-soon"
35
40
  WhatsOnNetflix::LeavingSoon.list
36
41
  list_options
37
-
42
+
38
43
  while !exit? && !back?
39
44
  if valid_number?(WhatsOnNetflix::LeavingSoon.all)
45
+ begin
40
46
  WhatsOnNetflix::LeavingSoon.item(@input)
47
+ rescue
48
+ puts ""
49
+ puts "Sorry, we couldn't get info for this title!"
50
+ end
41
51
  item_options
42
- else
52
+ else
43
53
  unknown_command
44
54
  end
45
55
  end
46
-
56
+
47
57
  elsif !exit?
48
58
  unknown_command
49
59
  end
50
60
  end
51
61
  exit
52
62
  end
53
-
63
+
54
64
  ### CLI dialogue
55
-
65
+
56
66
  def exit
57
67
  puts "See you later!"
58
68
  end
59
-
69
+
60
70
  def item_options
61
71
  puts ""
62
72
  puts "---"
@@ -66,7 +76,7 @@ module WhatsOnNetflix
66
76
  puts "exit: exit"
67
77
  @input = gets.strip
68
78
  end
69
-
79
+
70
80
  def list_available_commands
71
81
  puts ""
72
82
  puts "---"
@@ -77,7 +87,7 @@ module WhatsOnNetflix
77
87
  puts ""
78
88
  @input = gets.strip
79
89
  end
80
-
90
+
81
91
  def list_options
82
92
  puts ""
83
93
  puts "---"
@@ -87,29 +97,29 @@ module WhatsOnNetflix
87
97
  puts "exit: exit"
88
98
  @input = gets.strip
89
99
  end
90
-
100
+
91
101
  def unknown_command
92
102
  puts ""
93
103
  puts "I'm sorry, I don't recognize that command."
94
104
  puts ""
95
105
  @input = gets.strip
96
106
  end
97
-
107
+
98
108
  ### CLI logic
99
-
109
+
100
110
  def exit?
101
111
  @input == "exit"
102
112
  end
103
-
113
+
104
114
  def back?
105
115
  @input == "back"
106
116
  end
107
-
117
+
108
118
  def valid_number?(array)
109
119
  @input.to_i > 0 && @input.to_i < (array.length + 1)
110
120
  end
111
-
121
+
112
122
  end
113
123
  end
114
124
 
115
- require_relative '../config/environment'
125
+ require_relative '../config/environment'
@@ -2,17 +2,17 @@ require 'pry'
2
2
 
3
3
  module WhatsOnNetflix
4
4
  class ComingSoon < List
5
-
5
+
6
6
  @@all = []
7
-
7
+
8
8
  def self.all
9
9
  @@all
10
10
  end
11
-
11
+
12
12
  def self.list_url
13
- "http://www.whats-on-netflix.com/coming-soon/#{self.current_month}-#{self.current_year}-new-netflix-releases/"
13
+ "https://www.whats-on-netflix.com/coming-soon/#{self.current_month}-#{self.current_year}-new-netflix-releases/"
14
14
  end
15
-
15
+
16
16
  def self.list
17
17
  puts "= = = = ="
18
18
  puts "Coming Soon on Netflix"
@@ -20,4 +20,4 @@ module WhatsOnNetflix
20
20
  self.print_list
21
21
  end
22
22
  end
23
- end
23
+ end
@@ -1,15 +1,15 @@
1
1
  module WhatsOnNetflix
2
2
  class LeavingSoon < List
3
3
  @@all = []
4
-
4
+
5
5
  def self.all
6
6
  @@all
7
7
  end
8
-
8
+
9
9
  def self.list_url
10
- "http://www.whats-on-netflix.com/leaving-soon/titles-leaving-netflix-in-#{self.current_month}-#{self.current_year}/"
10
+ "https://www.whats-on-netflix.com/leaving-soon/titles-leaving-netflix-in-#{self.current_month}-#{self.current_year}/"
11
11
  end
12
-
12
+
13
13
  def self.list
14
14
  puts "= = = = ="
15
15
  puts "Leaving Soon from Netflix"
@@ -17,4 +17,4 @@ module WhatsOnNetflix
17
17
  self.print_list
18
18
  end
19
19
  end
20
- end
20
+ end
@@ -4,61 +4,61 @@ require 'pry'
4
4
 
5
5
  module WhatsOnNetflix
6
6
  class Scraper
7
-
7
+
8
8
  def self.get_html(url)
9
9
  Nokogiri::HTML(open(url))
10
10
  end
11
-
11
+
12
12
  def self.scrape_title_list(url)
13
13
  html = self.get_html(url)
14
-
14
+
15
15
  titles = []
16
-
16
+
17
17
  html.css("h4 + ul li").each do |title|
18
18
  titles << title.text
19
19
  end
20
-
20
+
21
21
  titles
22
22
  end
23
-
23
+
24
24
 
25
25
 
26
26
  def self.scrape_imdb_info(name)
27
27
 
28
28
  search_page = Nokogiri::HTML(open("http://www.imdb.com/find?s=tt&q=" + URI.escape(name)))
29
-
30
- movie_page = Nokogiri::HTML(open("http://www.imdb.com" + "#{search_page.css("td a").attribute("href").value}"))
31
29
 
30
+ movie_page = Nokogiri::HTML(open("http://www.imdb.com" + "#{search_page.css("td a").attribute("href").value}"))
31
+
32
32
  info = {}
33
-
33
+
34
34
  info[:plot] = movie_page.css("div.summary_text").text.strip
35
35
  info[:genre] = ""
36
36
  info[:stars] = ""
37
37
  info[:year] = ""
38
-
38
+
39
39
  # getting info[:genre] into a readable format
40
-
40
+
41
41
  movie_page.css('span[itemprop="genre"]').each do |genre|
42
42
  info[:genre].concat("| #{genre.text} |")
43
43
  end
44
-
44
+
45
45
  # getting info[:stars] into a readable format
46
-
46
+
47
47
  movie_page.css('span[itemprop="actors"]').each do |actor|
48
48
  info[:stars].concat("#{actor.text.strip} ")
49
49
  end
50
-
50
+
51
51
  # getting info[:year] - TV show and movie pages are formatted a little differently
52
-
52
+
53
53
  if movie_page.css('a[title="See more release dates"]').text.include?("TV Series")
54
54
  info[:year] = movie_page.css('a[title="See more release dates"]').text
55
55
  else
56
56
  info[:year] = movie_page.css('span#titleYear').text.strip.gsub("(", "").gsub(")", "")
57
57
  end
58
-
58
+
59
59
  info
60
60
  end
61
-
62
-
61
+
62
+
63
63
  end
64
64
  end
@@ -1,3 +1,3 @@
1
1
  module WhatsOnNetflix
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
data/spec.md CHANGED
@@ -1,6 +1,15 @@
1
1
  # Specifications for the CLI Assessment
2
2
 
3
3
  Specs:
4
- - [ ] Have a CLI for interfacing with the application
5
- - [ ] Pull data from an external source
6
- - [ ] Implement both list and detail views
4
+
5
+ - [x] Have a CLI for interfacing with the application
6
+
7
+ *The CLI class asks for input and presents a list of movies. The user is asked to choose one. Based on that input, the application presents further information on the selection. Invalid input is rejected, and the user can enter 'exit' at any time to quit.*
8
+
9
+ - [x] Pull data from an external source
10
+
11
+ *When the CLI class is initialized, the Scraper class pulls a list of movie titles from [whats-on-netflix.com](http://www.whats-on-netflix.com). When the user selects a particular movie, the Scraper class searches [IMDB](http://www.imdb.com/) for the movie's title, then gets the year, genre, starring cast, and plot summary from the movie's IMDB page.*
12
+
13
+ - [x] Implement both list and detail views
14
+
15
+ *After starting the application, users choose which list they'd like to see: Coming Soon, the titles being added to Netflix this month; or Leaving Soon, the titles leaving Netflix this month. Then they enter the number of a particular title to see details like plot, genre, and starring cast.*
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: whats-on-netflix
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clare Horton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-28 00:00:00.000000000 Z
11
+ date: 2017-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -146,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
146
  version: '0'
147
147
  requirements: []
148
148
  rubyforge_project:
149
- rubygems_version: 2.5.1
149
+ rubygems_version: 2.6.12
150
150
  signing_key:
151
151
  specification_version: 4
152
152
  summary: See what's being added and removed from Netflix this month