games_release_dates 0.2.0 → 0.3.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.
- checksums.yaml +4 -4
- data/bin/console +1 -0
- data/games_release_dates-0.2.0.gem +0 -0
- data/lib/games_release_dates.rb +1 -0
- data/lib/games_release_dates/cli.rb +32 -95
- data/lib/games_release_dates/scraper.rb +5 -8
- data/lib/games_release_dates/version.rb +1 -1
- data/lib/games_release_dates/video_games.rb +31 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29091c950c22c53d1dd0d56535968a918905b529
|
4
|
+
data.tar.gz: 29beb379a1eff21ee4d930ff6e69628ac39c8663
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da88c51ebea58018786dd8e6d7859752fd0e05b5ae0bacdad7a313ef23cdc4a721f47b3d66004b5c3e4af6bedfa664f3868d281e7310e0ba45717db2490fb70a
|
7
|
+
data.tar.gz: eed0daa6c076afffee4a0e37d458bd58e80927fad861485d18a5c6134e6ed3cbdcc2019388bca9ca69e2b8666a840e3fd54b96c8464a10e94023f6d40619a2aa
|
data/bin/console
CHANGED
Binary file
|
data/lib/games_release_dates.rb
CHANGED
@@ -1,116 +1,53 @@
|
|
1
1
|
class GamesReleaseDates::CLI
|
2
2
|
def call
|
3
|
-
@release_list = GamesReleaseDates::Scraper.new.make_list
|
4
3
|
puts "************VIDEOGAME RELEASE DATES************"
|
5
4
|
menu
|
6
5
|
end
|
7
6
|
|
8
7
|
def menu
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
consoles = ["PC", "XBOX", "PS4"]
|
9
|
+
months = ["JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE","JULY","AUGUST","SEPTEMBER","OCTOBER","NOVEMBER","DECEMBER"]
|
12
10
|
puts <<~eos
|
13
11
|
Please enter the system you would like to see releases for:
|
14
12
|
PC || XBOX || PS4 || EXIT
|
15
13
|
---------------------------------------------------
|
16
14
|
eos
|
17
|
-
|
18
|
-
|
19
|
-
if system_input != "EXIT" && systems.any? {|sys| sys == system_input}
|
20
|
-
months(system_input)
|
21
|
-
elsif system_input == "EXIT"
|
22
|
-
puts "Thank you! Please have a nice day!"
|
23
|
-
else
|
24
|
-
menu
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def months(system)
|
29
|
-
months = ["JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE","JULY","AUGUST","SEPTEMBER","OCTOBER","NOVEMBER","DECEMBER"]
|
30
|
-
month_input = nil
|
31
|
-
|
32
|
-
puts <<~eos
|
33
|
-
Please enter the month you would like to see releases for:
|
34
|
-
January May September
|
35
|
-
February June October
|
36
|
-
March July November
|
37
|
-
April August December
|
38
|
-
-----------------------------------------------------------
|
39
|
-
eos
|
40
|
-
month_input = gets.strip.upcase
|
41
|
-
|
42
|
-
if months.any? {|mon| mon == month_input}
|
43
|
-
list_releases(month_input,system)
|
44
|
-
else
|
45
|
-
months(system)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def list_releases(month, system)
|
50
|
-
@release_dates = []
|
51
|
-
overview_input = nil
|
52
|
-
|
53
|
-
puts <<~eos
|
54
|
-
*** #{month} - #{system} ***
|
55
|
-
-----------------------------------------------------------
|
56
|
-
eos
|
57
|
-
@release_list.each do |games|
|
58
|
-
@release_dates << games if games.include?("#{system}") && games.include?("– #{month}")
|
59
|
-
end
|
60
|
-
|
61
|
-
@release_dates.each_with_index do |game, index|
|
62
|
-
puts "#{index+1}. #{game}"
|
63
|
-
end
|
64
|
-
|
65
|
-
puts "Would you like to learn more? (Y/N)"
|
66
|
-
learn_input = gets.strip
|
67
|
-
if learn_input == "Y" || learn_input == "y"
|
68
|
-
learn_more(system)
|
69
|
-
elsif learn_input == "N" || learn_input == "n"
|
70
|
-
puts "Would you like to search for another month? (Y/N)"
|
71
|
-
another_month_input = gets.strip
|
72
|
-
if another_month_input == "Y" || another_month_input == "y"
|
73
|
-
months(system)
|
74
|
-
else
|
75
|
-
puts "Thank you! Have a nice day!"
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
def learn_more(system)
|
81
|
-
puts <<~eos
|
82
|
-
-----------------------------------------------------------
|
83
|
-
Please enter the number of the game you would like to learn more about:
|
84
|
-
eos
|
85
|
-
overview_input = gets.to_i
|
86
|
-
|
87
|
-
if overview_input <= @release_dates.length && overview_input > 0
|
88
|
-
|
89
|
-
game_name = @release_dates[overview_input-1].gsub(/\([^\(]+/,"")
|
90
|
-
overview = GamesReleaseDates::Scraper.new.game_overview(game_name)
|
15
|
+
console_input = gets.strip.upcase
|
91
16
|
|
17
|
+
if console_input != "EXIT" && consoles.any? {|sys| sys == console_input}
|
92
18
|
puts <<~eos
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
19
|
+
Please enter the month you would like to see releases for:
|
20
|
+
January May September
|
21
|
+
February June October
|
22
|
+
March July November
|
23
|
+
April August December
|
24
|
+
-----------------------------------------------------------
|
98
25
|
eos
|
99
|
-
|
100
|
-
|
101
|
-
if
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
26
|
+
month_input = gets.strip.upcase
|
27
|
+
|
28
|
+
if months.any? {|mon| mon == month_input}
|
29
|
+
GamesReleaseDates::Scraper.new.make_list
|
30
|
+
puts <<~eos
|
31
|
+
*** #{month} - #{console} ***
|
32
|
+
-----------------------------------------------------------
|
33
|
+
eos
|
34
|
+
GamesReleaseDates::VideoGames.list_releases(month, console)
|
35
|
+
|
36
|
+
puts "Please enter the number of the game you would like to learn more about?"
|
37
|
+
learn_input = gets.strip.to_i
|
38
|
+
if learn_input > 0
|
39
|
+
puts GamesReleaseDates::VideoGames.learn_more(learn_input-1)
|
40
|
+
puts "Thank you. Have a nice day."
|
110
41
|
end
|
42
|
+
else
|
43
|
+
puts "I'm sorry that is not a valid entry. Please try again."
|
44
|
+
menu
|
111
45
|
end
|
46
|
+
|
47
|
+
elsif console_input == "EXIT"
|
48
|
+
puts "Thank you! Please have a nice day!"
|
112
49
|
else
|
113
|
-
|
50
|
+
menu
|
114
51
|
end
|
115
52
|
end
|
116
53
|
end
|
@@ -4,18 +4,15 @@ class GamesReleaseDates::Scraper
|
|
4
4
|
end
|
5
5
|
|
6
6
|
def make_list
|
7
|
-
videogames = []
|
8
7
|
self.get_page.css("div#article section ul li").each do |vg|
|
9
|
-
|
8
|
+
game_attr = vg.text.upcase.split(" – ")
|
9
|
+
|
10
|
+
video_game = {:name => game_attr[0].gsub(/\s\([^\(]+/,""), :consoles => game_attr[0][/\([^\(]+/], :release_date => game_attr[1]}
|
11
|
+
GamesReleaseDates::VideoGames.new(video_game)
|
10
12
|
end
|
11
|
-
videogames
|
12
13
|
end
|
13
14
|
|
14
15
|
def get_game(name)
|
15
|
-
Nokogiri::HTML(open("http://thegamesdb.net/api/GetGame.php?name=#{name}"))
|
16
|
-
end
|
17
|
-
|
18
|
-
def game_overview(name)
|
19
|
-
self.get_game(name).at_css("overview").text
|
16
|
+
Nokogiri::HTML(open("http://thegamesdb.net/api/GetGame.php?name=#{name}")).at_css("overview").text
|
20
17
|
end
|
21
18
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class GamesReleaseDates::VideoGames
|
2
|
+
attr_accessor :name, :consoles, :release_date
|
3
|
+
|
4
|
+
@@video_games = []
|
5
|
+
|
6
|
+
def initialize(params = {})
|
7
|
+
@name = params[:name]
|
8
|
+
@consoles = params[:consoles]
|
9
|
+
@release_date= params[:release_date]
|
10
|
+
@@video_games << self
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.all
|
14
|
+
@@video_games
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.list_releases(month, console)
|
18
|
+
@searched_games = []
|
19
|
+
self.all.each do |vg|
|
20
|
+
if vg.release_date.to_s.include?("#{month}") && vg.consoles.to_s.include?("#{console}")
|
21
|
+
puts "#{@searched_games.length+1}. #{vg.name} #{vg.consoles} - #{vg.release_date}"
|
22
|
+
@searched_games << vg.name
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.learn_more(index)
|
28
|
+
puts "****** #{@searched_games[index]} *******"
|
29
|
+
GamesReleaseDates::Scraper.new.get_game("#{@searched_games[index]}")
|
30
|
+
end
|
31
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: games_release_dates
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alice Balbuena
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -85,11 +85,13 @@ files:
|
|
85
85
|
- games_release_dates-0.1.0.gem
|
86
86
|
- games_release_dates-0.1.2.gem
|
87
87
|
- games_release_dates-0.1.3.gem
|
88
|
+
- games_release_dates-0.2.0.gem
|
88
89
|
- games_release_dates.gemspec
|
89
90
|
- lib/games_release_dates.rb
|
90
91
|
- lib/games_release_dates/cli.rb
|
91
92
|
- lib/games_release_dates/scraper.rb
|
92
93
|
- lib/games_release_dates/version.rb
|
94
|
+
- lib/games_release_dates/video_games.rb
|
93
95
|
homepage: http://rubygems.org/gems/games_release_dates-cli
|
94
96
|
licenses:
|
95
97
|
- MIT
|