gogcom 0.0.23 → 0.0.24

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: e37708791570280951030af88ea870318d16f284
4
- data.tar.gz: eb17640ac5aa6944ce1a694e35271d7b0b7f29a3
3
+ metadata.gz: 3593702eb56104ba530291dc096d53ff42695c26
4
+ data.tar.gz: 523ff8f4b3387e23f77d8e37d5185b83ec8c579f
5
5
  SHA512:
6
- metadata.gz: a6f503adad14087b792b1a6ef93e7f0d296109f40fb33b5b1a523effa8924bca5bcafc7c1943ff5f7001673d6437ac24fafd43b4aec62a4661a2080b8ce5d01f
7
- data.tar.gz: 6050f1efee8c24be5f7b7075a999f5f2dfadc24c9058520789feddcd3b30461c22212d0dc5d3dddaeda39464a4c96b03e78dbb1f531e0b80166501dab0417b7d
6
+ metadata.gz: d738502b4be1ee7469de8781cb54e0f593af1fb397ef355b69314daa8cc097d8a422a86a419fc6439c5796c1bc68d7e4424937de6a1b521dbc1102fa6775f791
7
+ data.tar.gz: b3c29b325887c3ab4968340e2a3e7b9255667421e92c3f7b4755c78ef330dbea7a8b16f12972ad6713d11c72379fb9bfe40fe96f265c0566c154b5e438498489
data/README.md CHANGED
@@ -9,7 +9,7 @@ This library is in early stages and not ready for general use.
9
9
 
10
10
  #### Installation
11
11
  ```
12
- gem 'gogcom', '~> 0.0.23'
12
+ gem 'gogcom', '~> 0.0.24'
13
13
  bundle install
14
14
  ```
15
15
 
@@ -23,11 +23,13 @@ game.title # => "Spelunky"
23
23
  game.genres # => ["Action", "Adventure", "Platformer"]
24
24
  game.download_size # => "143 MB"
25
25
  game.release_date # => 1375934400 (Unix time)
26
+ game.description # => "..."
26
27
  game.price # => "$14.99"
27
28
  game.avg_rating # => "4.6"
28
29
  game.avg_ratings_count # => 268
29
30
  game.platforms # => ["Windows"]
30
31
  game.languages # => ["English", "French", "Italian", "German", "Spanish"]
32
+ game.pegiAge # => false
31
33
  game.developer # => "Mossmouth"
32
34
  game.publisher # => "Mossmouth"
33
35
  game.game_modes # => ["Single-player", "Multi-player", "Co-op"]
@@ -46,6 +48,8 @@ end
46
48
  require 'gogcom'
47
49
 
48
50
  sale = Gogcom.sale
51
+ # sale = Gogcom.sale(:type => "games")
52
+ # sale = Gogcom.sale(:type => "movies")
49
53
 
50
54
  sale.each do |game|
51
55
  game.title
@@ -4,8 +4,8 @@ module Gogcom
4
4
  Gogcom::Game.get(name)
5
5
  end
6
6
 
7
- def sale
8
- Gogcom::Sale.get
7
+ def sale(options = {})
8
+ Gogcom::Sale.get(options)
9
9
  end
10
10
  end
11
11
  end
@@ -1,7 +1,7 @@
1
1
  module Gogcom
2
2
  class Game
3
- attr_accessor :title, :genres, :download_size, :release_date, :price, :avg_rating,
4
- :avg_ratings_count, :platforms, :languages, :developer, :publisher,
3
+ attr_accessor :title, :genres, :download_size, :release_date, :description, :price, :avg_rating,
4
+ :avg_ratings_count, :platforms, :pegiAge, :languages, :developer, :publisher,
5
5
  :game_modes, :reviews
6
6
 
7
7
  def self.get_data(game_name)
@@ -33,6 +33,10 @@ module Gogcom
33
33
  data["gameProductData"]["releaseDate"]
34
34
  end
35
35
 
36
+ def self.get_description(data)
37
+ data["gameProductData"]["description"]["full"]
38
+ end
39
+
36
40
  def self.get_price(data)
37
41
  data["gameProductData"]["price"]["symbol"] + data["gameProductData"]["price"]["amount"]
38
42
  end
@@ -96,6 +100,10 @@ module Gogcom
96
100
  reviews
97
101
  end
98
102
 
103
+ def self.get_pegiAge(data)
104
+ data["gameProductData"]["pegiAge"]
105
+ end
106
+
99
107
  def self.get(game_name)
100
108
  data = self.get_data(game_name)
101
109
  game = Game.new
@@ -104,10 +112,12 @@ module Gogcom
104
112
  game.genres = get_genres(data)
105
113
  game.download_size = get_download_size(data)
106
114
  game.release_date = get_release_date(data)
115
+ game.description = get_description(data)
107
116
  game.price = get_price(data)
108
117
  game.avg_rating = get_avg_rating(data)
109
118
  game.avg_ratings_count = get_avg_ratings_count(data)
110
119
  game.platforms = get_platforms(data)
120
+ game.pegiAge = get_pegiAge(data)
111
121
  game.languages = get_languages(data)
112
122
  game.developer = get_developer(data)
113
123
  game.publisher = get_publisher(data)
@@ -29,10 +29,19 @@ module Gogcom
29
29
  data["on_sale"][i]["price"]["symbol"] + data["on_sale"][i]["price"]["discountDifference"]
30
30
  end
31
31
 
32
- def self.get
32
+ def self.is_game?(data, i)
33
+ data["on_sale"][i]["isGame"]
34
+ end
35
+
36
+ def self.is_movie?(data, i)
37
+ data["on_sale"][i]["isMovie"]
38
+ end
39
+
40
+ def self.get(options = {})
33
41
  data = self.get_data
34
42
  sale = []
35
43
  count = 0
44
+ type = options[:type] || nil
36
45
 
37
46
  data["on_sale"].each do |item|
38
47
  game = Sale.new
@@ -42,8 +51,19 @@ module Gogcom
42
51
  game.price_original = get_price_original(data, count)
43
52
  game.discount_percentage = get_discount_percentage(data, count)
44
53
  game.discount_amount = get_discount_amount(data, count)
45
-
46
- sale.push(game)
54
+
55
+ if (type == "games")
56
+ if (is_game?(data, count))
57
+ sale.push(game)
58
+ end
59
+ elsif (type == "movies")
60
+ if (is_movie?(data, count))
61
+ sale.push(game)
62
+ end
63
+ else
64
+ sale.push(game)
65
+ end
66
+
47
67
  count += 1
48
68
  end
49
69
 
@@ -1,3 +1,3 @@
1
1
  module Gogcom
2
- VERSION = "0.0.23"
2
+ VERSION = "0.0.24"
3
3
  end
@@ -27,6 +27,10 @@ class GogcomGameTest < Minitest::Test
27
27
  assert_equal Gogcom::Game.get_release_date(@data), 1347595200
28
28
  end
29
29
 
30
+ def test_description
31
+ assert_kind_of String, Gogcom::Game.get_description(@data)
32
+ end
33
+
30
34
  def test_price
31
35
  assert_match /^\$\d+(\.\d{2})?$/, Gogcom::Game.get_price(@data)
32
36
  end
@@ -43,6 +47,10 @@ class GogcomGameTest < Minitest::Test
43
47
  assert_equal Gogcom::Game.get_platforms(@data), ["Windows", "Mac"]
44
48
  end
45
49
 
50
+ def test_pegiAge
51
+ assert_equal Gogcom::Game.get_pegiAge(@data), false
52
+ end
53
+
46
54
  def test_languages
47
55
  assert_equal Gogcom::Game.get_languages(@data), ["English"]
48
56
  end
@@ -33,6 +33,14 @@ class GogcomSaleTest < Minitest::Test
33
33
  assert_equal Gogcom::Sale.get_discount_amount(@data, @game_id), "$6.00"
34
34
  end
35
35
 
36
+ def test_is_game?
37
+ assert_equal Gogcom::Sale.is_game?(@data, @game_id), true
38
+ end
39
+
40
+ def test_is_movie?
41
+ assert_equal Gogcom::Sale.is_movie?(@data, @game_id), false
42
+ end
43
+
36
44
  def test_get
37
45
  VCR.use_cassette('index') do
38
46
  sale = Gogcom::Sale.get
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gogcom
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.23
4
+ version: 0.0.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rolandas Barysas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-02 00:00:00.000000000 Z
11
+ date: 2014-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: coveralls