game_scraper 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 +7 -0
- data/.gitignore +9 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +20 -0
- data/LICENSE.txt +22 -0
- data/README.md +40 -0
- data/Rakefile +5 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/game_scraper.gemspec +36 -0
- data/lib/game_scraper.rb +219 -0
- data/lib/game_scraper/version.rb +5 -0
- data/lib/games.rb +86 -0
- data/lib/person.rb +58 -0
- data/lib/scraper.rb +101 -0
- metadata +58 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 559664d4de5dd64494bd779bee08bfeef14ab679992779434c944329e900e28a
|
4
|
+
data.tar.gz: 668a2adc082fa66cc6656e4261ee25361922f3a3145426eb19bfcfed3745863e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 28148801439acfb666883f2bc78224501a551a007c76d4e545e836b256110feca499d129e55391cf89a44cf7e13b78d1d97406fd593ffc8b5e66a04b9c0de80b
|
7
|
+
data.tar.gz: c4e7ccbaf3a801897d26aaa39a0438f83e55c8b1dd3c46e5c46a07981f2d1f1e7a98ce5c8b696ae436f938368b85130e6fc6c3d7a7ef2d83e75909d25031ba1e
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2021 baezdiazm
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# GameScraper
|
2
|
+
|
3
|
+
This app scrapes data from 'Www.Alphabetagamer.com" to create ruby objects with names and descriptions based on the corresponding info from the website.
|
4
|
+
|
5
|
+
Users will have the hability to "buy" and "trade" games with an NPC that has their own list of games scraped from the same website just a couple of pages further.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
#Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
#```ruby
|
12
|
+
#gem 'game_scraper'
|
13
|
+
#```
|
14
|
+
|
15
|
+
Execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install game_scraper
|
22
|
+
|
23
|
+
``` Usage
|
24
|
+
|
25
|
+
Type 'ruby lib/game_scraper.rb' to run the file
|
26
|
+
|
27
|
+
```
|
28
|
+
## Development
|
29
|
+
|
30
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
31
|
+
|
32
|
+
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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
33
|
+
|
34
|
+
## Contributing
|
35
|
+
|
36
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/game_scraper.
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "game_scraper"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/game_scraper/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "game_scraper"
|
7
|
+
spec.version = GameScraper::VERSION
|
8
|
+
spec.authors = ["baezdiazm"]
|
9
|
+
spec.email = ["baezdiazm@yahoo.com"]
|
10
|
+
|
11
|
+
spec.summary = "This app scrapes game titles and descriptions from www.alphabetagamer.com"
|
12
|
+
spec.homepage = "https://github.com/baezdiazm/game_scraper"
|
13
|
+
spec.license = "MIT"
|
14
|
+
spec.required_ruby_version = ">= 2.4.0"
|
15
|
+
|
16
|
+
#spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
17
|
+
|
18
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
19
|
+
#spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
|
20
|
+
#spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
21
|
+
|
22
|
+
# Specify which files should be added to the gem when it is released.
|
23
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
24
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
25
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
26
|
+
end
|
27
|
+
spec.bindir = "exe"
|
28
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
29
|
+
spec.require_paths = ["lib"]
|
30
|
+
|
31
|
+
# Uncomment to register a new dependency of your gem
|
32
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
33
|
+
|
34
|
+
# For more information and examples about making a new gem, checkout our
|
35
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
36
|
+
end
|
data/lib/game_scraper.rb
ADDED
@@ -0,0 +1,219 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "game_scraper/version"
|
4
|
+
require_relative 'scraper.rb'
|
5
|
+
require_relative 'person.rb'
|
6
|
+
require_relative 'games.rb'
|
7
|
+
require_relative 'scraper.rb'
|
8
|
+
#require 'pry'
|
9
|
+
|
10
|
+
def clear
|
11
|
+
puts "\e[H\e[2J"
|
12
|
+
end
|
13
|
+
|
14
|
+
def returning
|
15
|
+
puts "Returning to main menu"
|
16
|
+
main_screen
|
17
|
+
end
|
18
|
+
|
19
|
+
def trade(want, give)
|
20
|
+
@player.add_game(@npc.games[want-1])
|
21
|
+
@npc.add_game(@player.games[give-1])
|
22
|
+
@player.remove_game(@player.games[give-1])
|
23
|
+
@npc.remove_game(@npc.games[want-1])
|
24
|
+
end
|
25
|
+
|
26
|
+
def greeting
|
27
|
+
@player = nil
|
28
|
+
clear
|
29
|
+
puts "Welcome to this... Whatever this is."
|
30
|
+
puts
|
31
|
+
puts "Looks like this is your first time here."
|
32
|
+
puts "What is your name?"
|
33
|
+
name = gets.chomp
|
34
|
+
@player = Person.new(name)
|
35
|
+
clear
|
36
|
+
puts "Welcome, #{@player.name}!"
|
37
|
+
puts "What would you like to do?"
|
38
|
+
puts
|
39
|
+
main_screen
|
40
|
+
first_time = false
|
41
|
+
end
|
42
|
+
|
43
|
+
def main_screen
|
44
|
+
puts "-----------------------------------MAIN MENU-----------------------------------"
|
45
|
+
puts "1) Shop Games"
|
46
|
+
puts "2) Trade Game"
|
47
|
+
puts "3) Toss Game"
|
48
|
+
puts "4) Give game"
|
49
|
+
puts "5) Take game"
|
50
|
+
puts "6) Change your name"
|
51
|
+
puts "7) View your games"
|
52
|
+
puts "8) View NPC's games"
|
53
|
+
puts "9) Exit"
|
54
|
+
puts
|
55
|
+
|
56
|
+
selection = gets.chomp.to_i
|
57
|
+
if selection > 0 && selection < 10
|
58
|
+
case selection
|
59
|
+
when 1 ####################################### SHOP GAMES
|
60
|
+
clear
|
61
|
+
puts "-----------------------------------SHOPPING GAMES-----------------------------------"
|
62
|
+
puts
|
63
|
+
if Games.all.size > 0
|
64
|
+
puts "Available games:"
|
65
|
+
Games.list_games
|
66
|
+
puts "#{Games.all.size+1}. Exit"
|
67
|
+
puts
|
68
|
+
puts "Select the game you'd like to 'Buy':"
|
69
|
+
choice = gets.chomp.to_i
|
70
|
+
if choice > 0 && choice <= Games.all.size
|
71
|
+
@player.add_game(Games.all[choice-1])
|
72
|
+
Games.all.delete(Games.all[choice-1])
|
73
|
+
clear
|
74
|
+
puts "#{@player.games.last.name} has been added to your inventory"
|
75
|
+
elsif choice == Games.all.size+1 ###(The 'EXIT' button)
|
76
|
+
clear
|
77
|
+
returning
|
78
|
+
else
|
79
|
+
clear
|
80
|
+
puts "INVALID SELECTION"
|
81
|
+
returning
|
82
|
+
end
|
83
|
+
else
|
84
|
+
clear
|
85
|
+
puts "There are no games available at the moment..."
|
86
|
+
end
|
87
|
+
main_screen
|
88
|
+
when 2 ####################################### TRADE GAMES
|
89
|
+
clear
|
90
|
+
puts "-----------------------------------TRADING-----------------------------------"
|
91
|
+
puts
|
92
|
+
if @player.games.size > 0
|
93
|
+
puts "Select the game you want from #{@npc.name}"
|
94
|
+
puts
|
95
|
+
@npc.list_games
|
96
|
+
wanted = gets.chomp.to_i
|
97
|
+
clear
|
98
|
+
puts "-----------------------------------TRADING-----------------------------------"
|
99
|
+
puts
|
100
|
+
puts "You want: #{@npc.games[wanted-1].name}"
|
101
|
+
puts
|
102
|
+
puts "Select a game you want to give:"
|
103
|
+
@player.list_games
|
104
|
+
giving = gets.chomp.to_i
|
105
|
+
puts "You're giving: #{@player.games[giving-1].name}"
|
106
|
+
puts
|
107
|
+
trade(wanted, giving)
|
108
|
+
puts "Trade complete!"
|
109
|
+
returning
|
110
|
+
else
|
111
|
+
puts "You have no games to trade, try shopping for some games first."
|
112
|
+
returning
|
113
|
+
end
|
114
|
+
main_screen
|
115
|
+
when 3 ####################################### TOSS GAMES
|
116
|
+
clear
|
117
|
+
if @player.games.size > 0
|
118
|
+
puts "Select a game you'd like to toss:"
|
119
|
+
puts "WARNING: Games tossed cannot be restored!"
|
120
|
+
puts
|
121
|
+
@player.list_games
|
122
|
+
toss = gets.chomp.to_i-1
|
123
|
+
puts "You're deleting #{@player.games[toss].name}"
|
124
|
+
puts "Are you sure you don't want this game anymore?(y/n)"
|
125
|
+
answer = gets.chomp
|
126
|
+
clear
|
127
|
+
if answer == "y"
|
128
|
+
@player.remove_game(@player.games[toss])
|
129
|
+
elsif answer == "n"
|
130
|
+
puts "You chose to not toss #{@player.games[toss].name}..."
|
131
|
+
returning
|
132
|
+
else
|
133
|
+
puts "Invalid selection, returning to main menu"
|
134
|
+
end
|
135
|
+
else
|
136
|
+
puts "You have no games to toss."
|
137
|
+
returning
|
138
|
+
end
|
139
|
+
main_screen
|
140
|
+
when 4 ####################################### GIVE GAME
|
141
|
+
clear
|
142
|
+
if @player.games.size > 0
|
143
|
+
puts "SELECT the game you'd like to give to #{@npc.name}"
|
144
|
+
@player.list_games
|
145
|
+
give = gets.chomp.to_i-1
|
146
|
+
clear
|
147
|
+
puts "You are giving #{@player.games[give].name} to #{@npc.name}"
|
148
|
+
puts
|
149
|
+
puts "Are you sure you want to give this game away?(y/n)"
|
150
|
+
answer = gets.chomp
|
151
|
+
clear
|
152
|
+
if answer == "y"
|
153
|
+
@npc.add_game(@player.games[give])
|
154
|
+
@player.remove_game(@player.games[give])
|
155
|
+
puts "Done! you gave away: #{@npc.games.last.name}"
|
156
|
+
main_screen
|
157
|
+
elsif answer == "n"
|
158
|
+
puts "You chose to not give your game away."
|
159
|
+
returning
|
160
|
+
main_screen
|
161
|
+
else
|
162
|
+
puts "Invalid answer, #{returning}"
|
163
|
+
main_screen
|
164
|
+
end
|
165
|
+
else
|
166
|
+
puts "You have no games to give, try buying some first."
|
167
|
+
puts "Returning to main menu"
|
168
|
+
main_screen
|
169
|
+
end
|
170
|
+
when 5 ####################################### TAKE GAME
|
171
|
+
puts "Coming soon..."
|
172
|
+
main_screen
|
173
|
+
when 6 ####################################### CHANGE NAME
|
174
|
+
clear
|
175
|
+
puts "-----------------------------------CHANGING NAME-----------------------------------"
|
176
|
+
puts "Your current name is #{@player.name}"
|
177
|
+
puts "What is your new name?"
|
178
|
+
@player.name = gets.chomp
|
179
|
+
puts "Great! Your new name now is: #{@player.name}!"
|
180
|
+
main_screen
|
181
|
+
when 7 ####################################### VIEW YOUR GAMES
|
182
|
+
clear
|
183
|
+
if @player.games.size > 0
|
184
|
+
puts "-----------------------------------#{@player.name.upcase}'S GAMES:-----------------------------------"
|
185
|
+
@player.view_game
|
186
|
+
puts
|
187
|
+
else
|
188
|
+
puts "You have no games in your inventory, try buying some games."
|
189
|
+
puts "Returning to main menu"
|
190
|
+
end
|
191
|
+
main_screen
|
192
|
+
when 8 ####################################### NPC GAMES
|
193
|
+
clear
|
194
|
+
puts "------------------------------------NPC's GAMES:-----------------------------------"
|
195
|
+
@npc.list_games
|
196
|
+
main_screen
|
197
|
+
when 9
|
198
|
+
clear
|
199
|
+
puts "Thanks for playing, #{@player.name}! Goodbye."
|
200
|
+
|
201
|
+
puts
|
202
|
+
exit
|
203
|
+
end
|
204
|
+
else
|
205
|
+
clear
|
206
|
+
puts "Invalid selection, please select a number between 1 and 9"
|
207
|
+
main_screen
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
clear
|
212
|
+
@npc = Person.new("NPC Josh")
|
213
|
+
Scraper.make_games
|
214
|
+
Scraper.cpu_make_games
|
215
|
+
|
216
|
+
Scraper.cpugames.each do |game|
|
217
|
+
@npc.add_game(game)
|
218
|
+
end
|
219
|
+
greeting
|
data/lib/games.rb
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
class Games
|
2
|
+
attr_accessor :name, :description
|
3
|
+
@@all = []
|
4
|
+
|
5
|
+
def initialize(game, desc)
|
6
|
+
#Will take in a HASH of games scrapped from indiegames
|
7
|
+
@name = game
|
8
|
+
@description = desc
|
9
|
+
@@all << self
|
10
|
+
end
|
11
|
+
|
12
|
+
def name
|
13
|
+
@name
|
14
|
+
end
|
15
|
+
|
16
|
+
def description
|
17
|
+
@description
|
18
|
+
end
|
19
|
+
|
20
|
+
def delete_game(game)
|
21
|
+
self.all.delete(game)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.all
|
25
|
+
@@all
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
def self.list_desc
|
30
|
+
index = 1
|
31
|
+
all.each do |game|
|
32
|
+
puts "#{index}. #{game.name}."
|
33
|
+
puts " #{game.description.values.first}"
|
34
|
+
puts
|
35
|
+
puts
|
36
|
+
index += 1
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.list_games
|
41
|
+
index = 1
|
42
|
+
all.each do |game|
|
43
|
+
puts "#{index}. #{game.name}."
|
44
|
+
index += 1
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.make_games(scraper)
|
49
|
+
scraper.all_games.each do |game, desc|
|
50
|
+
Games.new(game, desc)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
def self.prompt
|
56
|
+
puts
|
57
|
+
puts
|
58
|
+
puts "SELECT the game you want to view:"
|
59
|
+
puts
|
60
|
+
index = 1
|
61
|
+
Games.all.each do |game|
|
62
|
+
puts "(#{index}) #{game.name}"
|
63
|
+
index += 1
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.view_game
|
69
|
+
puts "SELECT the game you want to view:"
|
70
|
+
puts
|
71
|
+
index = 1
|
72
|
+
Games.all.each do |game|
|
73
|
+
puts "(#{index}) #{game.name}"
|
74
|
+
index += 1
|
75
|
+
end
|
76
|
+
selection = gets.chomp.to_i
|
77
|
+
index = selection - 1
|
78
|
+
puts
|
79
|
+
if selection <= Games.all.size && selection > 0
|
80
|
+
puts Games.all[index].name.upcase
|
81
|
+
puts Games.all[index].description.values.first
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
data/lib/person.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
class Person
|
2
|
+
attr_accessor :name
|
3
|
+
|
4
|
+
@@all = []
|
5
|
+
def initialize(name)
|
6
|
+
@name = name
|
7
|
+
@games = []
|
8
|
+
@@all << self
|
9
|
+
end
|
10
|
+
|
11
|
+
def all
|
12
|
+
@@all
|
13
|
+
end
|
14
|
+
|
15
|
+
def games
|
16
|
+
@games
|
17
|
+
end
|
18
|
+
|
19
|
+
def add_game(game)
|
20
|
+
@games << game
|
21
|
+
end
|
22
|
+
|
23
|
+
def remove_game(game)
|
24
|
+
@games.delete(game)
|
25
|
+
end
|
26
|
+
|
27
|
+
def trade_game(person, game)
|
28
|
+
person.add_game(game)
|
29
|
+
self.remove_game(game)
|
30
|
+
end
|
31
|
+
|
32
|
+
def list_games
|
33
|
+
index = 1
|
34
|
+
@games.each do |game|
|
35
|
+
puts "#{index}. #{game.name}."
|
36
|
+
index += 1
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def view_game
|
41
|
+
puts "SELECT the game you want to view:"
|
42
|
+
puts
|
43
|
+
index = 1
|
44
|
+
self.games.each do |game|
|
45
|
+
puts "(#{index}) #{game.name}"
|
46
|
+
index += 1
|
47
|
+
end
|
48
|
+
selection = gets.chomp.to_i
|
49
|
+
index = selection - 1
|
50
|
+
puts
|
51
|
+
if selection <= self.games.size && selection > 0
|
52
|
+
puts self.games[index].name.upcase
|
53
|
+
puts self.games[index].description.values.first
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
data/lib/scraper.rb
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
require "nokogiri"
|
2
|
+
require "open-uri"
|
3
|
+
#require 'pry'
|
4
|
+
|
5
|
+
class Scraper
|
6
|
+
|
7
|
+
@cpugames = []
|
8
|
+
|
9
|
+
def self.get_page
|
10
|
+
html = open("https://www.alphabetagamer.com")
|
11
|
+
doc = Nokogiri::HTML(html)
|
12
|
+
doc
|
13
|
+
#Titles ====== get_page.css(".entry-title a")
|
14
|
+
#Descriptions ====== get_page.css(".entry-content p")
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.cpu_get_page
|
18
|
+
html = open("https://www.alphabetagamer.com/page/5/")
|
19
|
+
doc = Nokogiri::HTML(html)
|
20
|
+
doc
|
21
|
+
#Titles ====== get_page.css(".entry-title a")
|
22
|
+
#Descriptions ====== get_page.css(".entry-content p")
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.descriptions
|
26
|
+
arr = []
|
27
|
+
desc = get_page.css(".entry-content p")
|
28
|
+
|
29
|
+
desc.each do |item|
|
30
|
+
if item.text != ""
|
31
|
+
arr << item.text
|
32
|
+
end
|
33
|
+
end
|
34
|
+
arr
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
def self.list_games
|
39
|
+
index = 1
|
40
|
+
all_games.each do |title, description|
|
41
|
+
puts "#{index}. #{(title)}"
|
42
|
+
puts "#{description.values.first}"
|
43
|
+
puts ""
|
44
|
+
puts ""
|
45
|
+
index += 1
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.all_games
|
50
|
+
games = {}
|
51
|
+
p1 = 0
|
52
|
+
p2 = 1
|
53
|
+
get_page.css(".entry-title a").each do |entry|
|
54
|
+
title = entry.text
|
55
|
+
#binding.pry
|
56
|
+
games[title.to_sym] = {
|
57
|
+
:description => descriptions[p1] + " " + descriptions[p2]
|
58
|
+
}
|
59
|
+
p1 += 2
|
60
|
+
p2 += 2
|
61
|
+
end
|
62
|
+
games
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.cpu_games
|
66
|
+
games = {}
|
67
|
+
p1 = 0
|
68
|
+
p2 = 1
|
69
|
+
cpu_get_page.css(".entry-title a").each do |entry|
|
70
|
+
title = entry.text
|
71
|
+
#binding.pry
|
72
|
+
games[title.to_sym] = {
|
73
|
+
:description => descriptions[p1] + " " + descriptions[p2]
|
74
|
+
}
|
75
|
+
p1 += 2
|
76
|
+
p2 += 2
|
77
|
+
end
|
78
|
+
games
|
79
|
+
end
|
80
|
+
|
81
|
+
def self.make_games
|
82
|
+
all_games.each do |game|
|
83
|
+
Games.new(game[0], game[1])
|
84
|
+
end
|
85
|
+
all_games.clear
|
86
|
+
end
|
87
|
+
|
88
|
+
|
89
|
+
def self.cpugames
|
90
|
+
@cpugames
|
91
|
+
end
|
92
|
+
|
93
|
+
def self.cpu_make_games
|
94
|
+
cpu_games.clear
|
95
|
+
cpu_games.each do |game|
|
96
|
+
a = Games.new(game[0], game[1])
|
97
|
+
@cpugames << a
|
98
|
+
Games.all.delete(a)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
metadata
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: game_scraper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- baezdiazm
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-06-23 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email:
|
15
|
+
- baezdiazm@yahoo.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- ".gitignore"
|
21
|
+
- Gemfile
|
22
|
+
- Gemfile.lock
|
23
|
+
- LICENSE.txt
|
24
|
+
- README.md
|
25
|
+
- Rakefile
|
26
|
+
- bin/console
|
27
|
+
- bin/setup
|
28
|
+
- game_scraper.gemspec
|
29
|
+
- lib/game_scraper.rb
|
30
|
+
- lib/game_scraper/version.rb
|
31
|
+
- lib/games.rb
|
32
|
+
- lib/person.rb
|
33
|
+
- lib/scraper.rb
|
34
|
+
homepage: https://github.com/baezdiazm/game_scraper
|
35
|
+
licenses:
|
36
|
+
- MIT
|
37
|
+
metadata:
|
38
|
+
homepage_uri: https://github.com/baezdiazm/game_scraper
|
39
|
+
post_install_message:
|
40
|
+
rdoc_options: []
|
41
|
+
require_paths:
|
42
|
+
- lib
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 2.4.0
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
requirements: []
|
54
|
+
rubygems_version: 3.1.6
|
55
|
+
signing_key:
|
56
|
+
specification_version: 4
|
57
|
+
summary: This app scrapes game titles and descriptions from www.alphabetagamer.com
|
58
|
+
test_files: []
|