new-game-scores 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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +5 -1
- data/lib/new_game_scores/cli.rb +20 -11
- data/lib/new_game_scores/collection_scraper.rb +23 -7
- data/lib/new_game_scores/version.rb +1 -1
- data/pkg/new-game-scores-0.1.0.gem +0 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f6d282902963b45175d0472f3514458c128821f
|
4
|
+
data.tar.gz: f730a61495c9d2486f97cd1981b6544916a51fde
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3412eb9eb138464371ba42bf08125af806de8f0bd604eb1ccf382217ef123173f6e63197c379c00bfaee1ed0cc19cde5748fab85ad9310c880d88cba6d78dc5d
|
7
|
+
data.tar.gz: 8c75720264931e8d4f9ec1b66ba28354114293ef62857040bedadc42f7854d08227833ec5b2581b1a8cb644bb094e51a6c51d5844c92c129c786ae1869b2fb42
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -18,7 +18,7 @@ You can install this gem by typing this in your terminal:
|
|
18
18
|
|
19
19
|
To run the program:
|
20
20
|
|
21
|
-
$ bin/new-game-scores
|
21
|
+
$ ruby bin/new-game-scores
|
22
22
|
|
23
23
|
|
24
24
|
## Development
|
@@ -36,3 +36,7 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/lukegh
|
|
36
36
|
|
37
37
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
38
38
|
|
39
|
+
## Version 0.1.1 (chang.log)
|
40
|
+
|
41
|
+
I have added functionality to the application. It now displays the release date for the games. Their is also a filter that only display games based on the minimum review score that the user specifies.
|
42
|
+
|
data/lib/new_game_scores/cli.rb
CHANGED
@@ -26,38 +26,47 @@ class NewGameScores::CLI
|
|
26
26
|
input = nil
|
27
27
|
while input != 'exit'
|
28
28
|
puts ""
|
29
|
-
puts "Please type the number or the name of the platform that you would like to see the latest reviews for."
|
29
|
+
puts " Please type the number or the name of the platform that you would like to see the latest reviews for."
|
30
30
|
puts ""
|
31
|
-
puts "If you would like to exit the program please type 'Exit'."
|
31
|
+
puts " If you would like to exit the program please type 'Exit'."
|
32
32
|
puts ""
|
33
33
|
input = gets.strip.upcase
|
34
|
+
if input != 'EXIT'
|
35
|
+
puts " What is the minimum score you would like to see a list of? (1-100)"
|
36
|
+
puts ""
|
37
|
+
score = gets.strip.upcase
|
38
|
+
end
|
39
|
+
score
|
40
|
+
|
34
41
|
if input == "PS4" || input == "1"
|
35
|
-
list("PS4", "http://www.metacritic.com/browse/games/release-date/new-releases/ps4/metascore")
|
42
|
+
list("PS4", "http://www.metacritic.com/browse/games/release-date/new-releases/ps4/metascore", score)
|
36
43
|
|
37
44
|
elsif input == "XBOX ONE" || input == "2"
|
38
|
-
list("Xbox One", "http://www.metacritic.com/browse/games/release-date/new-releases/xboxone/metascore")
|
45
|
+
list("Xbox One", "http://www.metacritic.com/browse/games/release-date/new-releases/xboxone/metascore", score)
|
39
46
|
|
40
47
|
elsif input == "PC" || input == "3"
|
41
|
-
list("PC", "http://www.metacritic.com/browse/games/release-date/new-releases/pc/metascore")
|
48
|
+
list("PC", "http://www.metacritic.com/browse/games/release-date/new-releases/pc/metascore", score)
|
42
49
|
|
43
50
|
elsif input == "WII U" || input == "4"
|
44
|
-
list("Wii U", "http://www.metacritic.com/browse/games/release-date/new-releases/wii-u/metascore")
|
51
|
+
list("Wii U", "http://www.metacritic.com/browse/games/release-date/new-releases/wii-u/metascore", score)
|
45
52
|
|
46
53
|
elsif input == "3DS" || input == "5"
|
47
|
-
list("3ds", "http://www.metacritic.com/browse/games/release-date/new-releases/3ds/metascore")
|
54
|
+
list("3ds", "http://www.metacritic.com/browse/games/release-date/new-releases/3ds/metascore", score)
|
48
55
|
|
49
56
|
elsif input == "EXIT"
|
50
|
-
puts "Goodbye!"
|
57
|
+
puts " Goodbye!"
|
51
58
|
exit == true
|
52
59
|
end
|
53
60
|
end
|
54
61
|
end
|
55
62
|
|
56
|
-
def list(name, url)
|
63
|
+
def list(name, url, score)
|
57
64
|
puts ""
|
58
|
-
puts "Newest Game Releases for #{name}."
|
59
|
-
list = NewGameScores::CollectionScraper.new(url)
|
65
|
+
puts " Newest Game Releases for #{name}."
|
66
|
+
list = NewGameScores::CollectionScraper.new(url, score)
|
67
|
+
list.clear
|
60
68
|
list.scrape_list
|
69
|
+
list.display_list
|
61
70
|
sleep(3)
|
62
71
|
puts ""
|
63
72
|
start
|
@@ -1,28 +1,44 @@
|
|
1
1
|
class NewGameScores::CollectionScraper
|
2
2
|
|
3
|
-
attr_accessor :name, :title, :game_url, :metascore, :userscore, :url
|
3
|
+
attr_accessor :name, :title, :game_url, :metascore, :userscore, :url, :score
|
4
4
|
|
5
|
+
@@collection = []
|
5
6
|
|
6
|
-
def initialize(url = nil)
|
7
|
+
def initialize(url = nil, score = nil)
|
7
8
|
@url = url
|
9
|
+
@score = score
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.collection
|
13
|
+
@@collection
|
14
|
+
end
|
15
|
+
|
16
|
+
def clear
|
17
|
+
@@collection.clear
|
8
18
|
end
|
9
19
|
|
10
20
|
def scrape_list
|
11
21
|
game_list = Nokogiri::HTML(open(self.url, ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE, 'User-Agent' => 'safari'))
|
12
|
-
collection = []
|
13
22
|
|
14
23
|
game_list.css("ol.list_products li.game_product").each do |game|
|
15
24
|
|
16
|
-
collection << {
|
25
|
+
@@collection << {
|
17
26
|
:title => game.css("div.product_title a").text.strip,
|
18
27
|
:metascore => game.css("div.metascore_w").text,
|
19
28
|
:userscore => game.css("li.product_avguserscore span.textscore").text,
|
29
|
+
:release_date => game.css("li.release_date span.data").text,
|
20
30
|
:game_url => 'http://www.metacritic.com/' +game.css("div.product_title a").attribute("href").text
|
21
31
|
}
|
22
32
|
end
|
23
|
-
|
24
|
-
|
25
|
-
|
33
|
+
end
|
34
|
+
|
35
|
+
def display_list
|
36
|
+
@@collection.each_with_index do |game, i|
|
37
|
+
game.each do |key, value|
|
38
|
+
if key = :metasocre && value.to_i >= @score.to_i
|
39
|
+
puts " \n#{i+1}. #{game[:title]} \n \n Metascore: #{game[:metascore]} \n Userscore: #{game[:userscore]} \n Release Date: #{game[:release_date]}\n Game Link: #{game[:game_url]}\n \n"
|
40
|
+
end
|
41
|
+
end
|
26
42
|
end
|
27
43
|
end
|
28
44
|
|
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: new-game-scores
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lukeghenco
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -141,6 +141,7 @@ files:
|
|
141
141
|
- lib/new_game_scores/collection_scraper.rb
|
142
142
|
- lib/new_game_scores/version.rb
|
143
143
|
- new-game-scores.gemspec
|
144
|
+
- pkg/new-game-scores-0.1.0.gem
|
144
145
|
homepage: https://github.com/Lukeghenco/new-game-scores-ruby-gem
|
145
146
|
licenses:
|
146
147
|
- MIT
|
@@ -162,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
162
163
|
version: '0'
|
163
164
|
requirements: []
|
164
165
|
rubyforge_project:
|
165
|
-
rubygems_version: 2.4.
|
166
|
+
rubygems_version: 2.4.6
|
166
167
|
signing_key:
|
167
168
|
specification_version: 4
|
168
169
|
summary: The Newest Video Game Metacritic Scores.
|