coming_soon 0.2.6 → 0.2.7

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: d4609b528968b24fdb6e01b8332ffdfb995e7bc0
4
- data.tar.gz: 19bda5075a202ea7b60257bc35dbfaea4b8ca8cc
3
+ metadata.gz: 242f7827f948dbbd75f534ceaa60c661d1741731
4
+ data.tar.gz: 1387044856785ff15f6fa45a9f201bf3e8137f04
5
5
  SHA512:
6
- metadata.gz: 495b933ecd34601133b71938ea5ea4c6bce399c9e14e9b942535a4cf68324cb7d981963e4bbf8d4515aaa0f4e1c977be069cafea70fddd21369766bca1d21a0d
7
- data.tar.gz: 1236e4ad31516bc8ebc18c6a0d44df87531a3ce02840fc07142bf21b078e6c914ea6f24185952a0acd6e92da889f0de4a3f3f147a138ad463bb7d4ab49951e58
6
+ metadata.gz: 70ffb04bb8bfde73301e0f570f4254068bc67ac589e97088b549da333fb6196098339da2356869118b1127f5a9982e8fbf317b0b8181200518be70d4f720a38b
7
+ data.tar.gz: bdefe6ba38cf756f2e81260c9a4d5761f1c1f24a60b0b776cec30e614aecb8a8dae352239ec07bffa23535daa4be6f602c454d261530ee87f36f1ceb3c448d27
@@ -1,6 +1,7 @@
1
1
  class ComingSoon::CLI
2
2
 
3
3
  def call
4
+
4
5
  puts ''
5
6
  puts ' **************************'
6
7
  puts ' * Movies Coming Soon *'
@@ -9,9 +10,10 @@ class ComingSoon::CLI
9
10
  puts ' **************************'
10
11
  puts ''
11
12
 
12
- ComingSoon::Scraper.scrape_movies
13
+ ComingSoon::Scraper.new.scrape_movies
13
14
  get_and_list_movies
14
15
  menu_selection
16
+
15
17
  end
16
18
 
17
19
  def get_and_list_movies
@@ -19,9 +21,11 @@ class ComingSoon::CLI
19
21
  ComingSoon::Movie.movies.each.with_index(1) do |movie, i| # set the first index to 1 and use the index number for the movie number
20
22
  puts "#{i}. #{movie.name} - #{movie.start_date}"
21
23
  end
24
+
22
25
  end
23
26
 
24
27
  def list_saved_movies
28
+
25
29
  puts ''
26
30
  puts ' **************************'
27
31
  puts ' * Movies Coming Soon *'
@@ -31,9 +35,11 @@ class ComingSoon::CLI
31
35
  ComingSoon::Movie.movies.each.with_index(1) do |movie, i| # set the first index to 1 and use the index number for the movie number
32
36
  puts "#{i}. #{movie.name} - #{movie.start_date}"
33
37
  end
38
+
34
39
  end
35
40
 
36
41
  def menu_selection
42
+
37
43
  input = ''
38
44
 
39
45
  while input != 'exit'
@@ -53,10 +59,12 @@ class ComingSoon::CLI
53
59
  puts 'Invalid selection!'
54
60
  menu_selection
55
61
  end
56
- end
62
+ end
63
+
57
64
  end
58
65
 
59
66
  def goodbye
67
+
60
68
  puts ''
61
69
  puts ' ***************************'
62
70
  puts ' * Thank you and goodbye *'
@@ -66,6 +74,7 @@ class ComingSoon::CLI
66
74
  puts ''
67
75
 
68
76
  exit
77
+
69
78
  end
70
79
 
71
80
  end
@@ -1,15 +1,20 @@
1
1
 
2
2
  class ComingSoon::Movie
3
+
3
4
  attr_accessor :name, :start_date, :url, :synopsis
4
5
 
5
6
  @@movies = []
6
7
 
7
8
  def initialize
9
+
8
10
  @@movies << self
11
+
9
12
  end
10
13
 
11
14
  def self.movies
15
+
12
16
  @@movies
17
+
13
18
  end
14
19
 
15
20
  end
@@ -1,6 +1,6 @@
1
1
  class ComingSoon::Scraper
2
2
 
3
- def self.scrape_movies
3
+ def scrape_movies
4
4
 
5
5
  doc = Nokogiri::HTML(open("http://www.fandango.com/moviescomingsoon"))
6
6
  # name: doc.css("li.visual-item a.visual-title").text.strip
@@ -17,38 +17,48 @@ class ComingSoon::Scraper
17
17
  soon.start_date = movie.css("span").text
18
18
  soon.url = movie.css("a").attribute("href").value
19
19
 
20
- self.scrape_synopsis(soon)
20
+ scrape_details(soon)
21
21
 
22
22
  count+=1
23
- if count > 19 # Displays only 20 movies
23
+ if count > 19 # Scrapes only 20 movies
24
24
  break
25
25
  end
26
26
  end
27
27
 
28
28
  end
29
29
 
30
- def self.scrape_synopsis(soon)
31
-
30
+ def scrape_details(soon)
31
+
32
32
  redirect_failed = false
33
33
 
34
34
  begin
35
- @doc_synop1 = Nokogiri::HTML(open(soon.url)) # Uses the HTTP 'movieoverview' url
35
+ doc_synop1 = Nokogiri::HTML(open(soon.url)) # Uses the HTTP 'movieoverview' url
36
36
  rescue
37
- redirect_failed = true # An HTTP to HTTPS redirect failed
37
+ redirect_failed = true # A HTTP to HTTPS redirect failed
38
38
  end
39
-
40
- if !@doc_synop1.css("a.movie-synopsis-link").any? && !redirect_failed &&
41
- @doc_synop1.css("span#SynopsisTextLabel").any?
42
- # If not a redirect failure and a READ FULL SYNOPSIS link is not
43
- # present and any text is available, use the text for the synopsis
44
- soon.synopsis = @doc_synop1.css("span#SynopsisTextLabel").text
39
+
40
+ if !redirect_failed
41
+ if !doc_synop1.css("a.movie-synopsis-link").any? &&
42
+ doc_synop1.css("span#SynopsisTextLabel").any?
43
+ # If a READ FULL SYNOPSIS link is not present and any
44
+ # text is available, use that text for the synopsis
45
+ soon.synopsis = doc_synop1.css("span#SynopsisTextLabel").text
46
+ else
47
+ scrape_plotsummary(soon)
48
+ end
45
49
  else
46
- # Scrape the synopsis using the HTTP 'plotsummary' url
47
- # This is also executed after an HTTP to HTTPS redirect failed
48
- synop_url = soon.url.sub(/movieoverview/, 'plotsummary')
49
- doc_synop2 = Nokogiri::HTML(open(synop_url))
50
- soon.synopsis = doc_synop2.css("p.subpage-descriptive-content").text
50
+ scrape_plotsummary(soon)
51
51
  end
52
52
 
53
53
  end
54
- end
54
+
55
+ def scrape_plotsummary(soon)
56
+ # Scrape the synopsis using the HTTP 'plotsummary' url
57
+ # This is also executed after an HTTP to HTTPS redirect failed
58
+ synop_url = soon.url.sub(/movieoverview/, 'plotsummary')
59
+ doc_synop2 = Nokogiri::HTML(open(synop_url))
60
+ soon.synopsis = doc_synop2.css("p.subpage-descriptive-content").text
61
+
62
+ end
63
+
64
+ end
@@ -1,4 +1,4 @@
1
1
 
2
2
  module ComingSoon
3
- VERSION = "0.2.6"
3
+ VERSION = "0.2.7"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coming_soon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Terry Blue