recently_ps4_games 0.2.0 → 0.3.0

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: e0c5a5a232f395ced7e1032e4036d81d26f3db11
4
- data.tar.gz: f20efd1eaaee29a345add70c15613eae862a1468
3
+ metadata.gz: e530123a586981062c8602ad6967f8f343ce4b5f
4
+ data.tar.gz: d63fc715a02cd270a936d55876d5659092d8bb6b
5
5
  SHA512:
6
- metadata.gz: 60bd26551ba9b335ba29f89fbfbec3bf67e6205dcf2ee9e36d4d03f6803ab96ddcc7d2e546fdfd78b65abc775e6335c42f597ff1c984cd244262429fc45f11c9
7
- data.tar.gz: f33fb1bc147c640364739f82e1edf2141efc561704699a653824818213546ad89b9f1494d908faa94aa81b0b78f92ac6f0b73fcbf5d8b2411b5cb79e39e0f5ee
6
+ metadata.gz: 34074a6af4bc5780ff66d52b6ff64c732d9b737a72a9dad2a93663a6e86fb5f85902abd473d0c00c1a50ac3ee5731dc47b9fc421fcad2125d4f010e4efdaea54
7
+ data.tar.gz: 96ccb7ad27dcb02a76008bcef4c6fafa6825a325538671ac36c7bc65a0e30604902906cded5df375844f114c9150aa4116bfa5012158cbe33929ae3f6dc72587
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require_relative '../lib/recently_ps4_games.rb'
3
+ require_relative '../lib/recently_ps4_games'
4
4
 
5
5
  RecentlyPs4Games::Cli.new.call
@@ -3,16 +3,11 @@ class RecentlyPs4Games::Cli
3
3
  def call
4
4
  puts "Welcome to recently_ps4_games!!"
5
5
  puts "...now makinging games list..."
6
- make_games # as Game Instance
7
- interact_with_user # display list, ask input, display details
6
+ RecentlyPs4Games::Scraper.scrape_game_list
7
+ interact_with_user
8
8
  puts "Bye!"
9
9
  end
10
10
 
11
- def make_games
12
- games_arr = RecentlyPs4Games::Scraper.scrape_game_list
13
- RecentlyPs4Games::Game.create_by_games_arr(games_arr)
14
- end
15
-
16
11
  def interact_with_user
17
12
  display_list
18
13
  display_detail(get_detail(ask_what_to_detail))
@@ -38,8 +33,7 @@ class RecentlyPs4Games::Cli
38
33
 
39
34
  def get_detail(id)
40
35
  game = RecentlyPs4Games::Game.find_by_id(id)
41
- detail = RecentlyPs4Games::Scraper.scrape_details(game.detail_url)
42
- game.add_attributes(detail)
36
+ RecentlyPs4Games::Scraper.scrape_details(game)
43
37
  end
44
38
 
45
39
  def display_detail(game)
@@ -7,15 +7,8 @@ class RecentlyPs4Games::Game
7
7
  game_hash.each do |k, v|
8
8
  self.send("#{k}=", v)
9
9
  end
10
+ @id = (@@all.size + 1)
10
11
  @@all << self
11
- @id = @@all.size
12
- self
13
- end
14
-
15
- def self.create_by_games_arr(games_arr)
16
- games_arr.each do |game|
17
- self.new(game)
18
- end
19
12
  end
20
13
 
21
14
  def self.find_by_id(id)
@@ -28,7 +21,6 @@ class RecentlyPs4Games::Game
28
21
  details_hash.each do |k, v|
29
22
  self.send("#{k}=", v)
30
23
  end
31
- self
32
24
  end
33
25
 
34
26
  def self.all
@@ -8,35 +8,31 @@ class RecentlyPs4Games::Scraper
8
8
  end
9
9
 
10
10
  def self.scrape_game_list
11
- games_arr = []
12
11
  list_page = Nokogiri::HTML(self.get_dynamic_page_html)
13
12
  game_grids = list_page.css("div.inlineTabs.section.gameGrid")
14
13
  game_grids.each do |game_grid|
15
14
  games = game_grid.css("ul.clearfix li.layout-type-1 div.tile.clearfix div.game-tile-details h2 a.title")
16
15
  games.each do |game|
17
- games_arr << {
16
+ RecentlyPs4Games::Game.new({
18
17
  title: game.text,
19
18
  detail_url: game.attr("href")
20
- }
19
+ })
21
20
  end
22
21
  end
23
- games_arr
24
22
  end
25
23
 
26
- def self.scrape_details(url)
27
- detail_page = Nokogiri::HTML(open(url))
24
+ def self.scrape_details(game)
25
+ detail_page = Nokogiri::HTML(open(game.detail_url))
28
26
  prod_meta = detail_page.css("div.prod-meta")
29
27
  release_info = prod_meta.css("ul.release-info li")
30
-
31
- details = {
28
+ game.add_attributes({
32
29
  discription: prod_meta.css("p.teaser").text,
33
30
  release_date: release_info.css("span.releasedate").text.delete("\n\t"),
34
31
  genre: release_info[1].children[2].text.delete("\n\t"),
35
32
  publisher: release_info[2].children[1].text.delete("\n\t"),
36
33
  developer: release_info[3].children[1].text.delete("\n\t")
37
- }
38
-
39
- details
34
+ })
35
+ game
40
36
  end
41
37
 
42
38
  end
@@ -1,3 +1,3 @@
1
1
  module RecentlyPs4Games
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recently_ps4_games
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ayafushimi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-25 00:00:00.000000000 Z
11
+ date: 2016-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri