gogcom 0.0.25 → 0.0.26
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -6
- data/lib/gogcom.rb +8 -8
- data/lib/gogcom/game.rb +63 -43
- data/lib/gogcom/news.rb +45 -36
- data/lib/gogcom/sale.rb +65 -50
- data/lib/gogcom/version.rb +1 -1
- data/test/test_game.rb +35 -42
- data/test/test_gogcom.rb +9 -2
- data/test/test_news.rb +16 -14
- data/test/test_sale.rb +32 -24
- metadata +3 -6
- data/lib/gogcom/func.rb +0 -8
- data/lib/gogcom/review.rb +0 -5
- data/test/test_func.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2ab1fa3184f6d9478b232c68f36aff9b96acb65
|
4
|
+
data.tar.gz: a2e348f78102657ec7e296df005f3f53e3625ebd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c889666703185cfdea0d8830d723139d47a5a8dc633507fa5d83ace9b15dbcb5b48cebfe00ac802ef87a7c269ff14c7fa4a3f220881c93c93e1ea2bc9761d9f
|
7
|
+
data.tar.gz: f5ae8c2bd3e78260117219436dac09dca92e6db1a840bd13db28cea0498f5b78ec15b874f2c8f45a1f863dfb3f1360e7d76dd047ff543094c155b3891cd61eae
|
data/README.md
CHANGED
@@ -1,9 +1,12 @@
|
|
1
|
-
gogcom [![Gem Version](https://badge.fury.io/rb/gogcom.svg)](http://badge.fury.io/rb/gogcom) [![Build Status](https://travis-ci.org/rbrs/gogcom.svg?branch=develop)](https://travis-ci.org/rbrs/gogcom) [![Dependency Status](https://gemnasium.com/rbrs/gogcom.svg)](https://gemnasium.com/
|
1
|
+
gogcom [![Gem Version](https://badge.fury.io/rb/gogcom.svg)](http://badge.fury.io/rb/gogcom) [![Build Status](https://travis-ci.org/rbrs/gogcom.svg?branch=develop)](https://travis-ci.org/rbrs/gogcom) [![Dependency Status](https://gemnasium.com/rbrs/gogcom.svg)](https://gemnasium.com/rbrs/gogcom) [![Coverage Status](https://coveralls.io/repos/rbrs/gogcom/badge.png?branch=develop)](https://coveralls.io/r/rbrs/gogcom?branch=develop)
|
2
2
|
============
|
3
3
|
|
4
4
|
Gogcom is a Ruby library for easy querying gog.com website.
|
5
5
|
|
6
|
-
|
6
|
+
Because GOG.com doesn't have official API, data is being gathered by parsing global javascript object.
|
7
|
+
That means that there's no guarantee that gem will always work as expected. **Do not use this in production.**
|
8
|
+
|
9
|
+
I might be working on unnoficial GOG database, to make this API safe for production use. There's no timeline when it will be done, though.
|
7
10
|
|
8
11
|
## Usage
|
9
12
|
|
@@ -17,7 +20,7 @@ bundle install
|
|
17
20
|
```ruby
|
18
21
|
require 'gogcom'
|
19
22
|
|
20
|
-
game = Gogcom.game("Spelunky")
|
23
|
+
game = Gogcom.game(:name => "Spelunky")
|
21
24
|
|
22
25
|
game.title # => "Spelunky"
|
23
26
|
game.genres # => ["Action", "Adventure", "Platformer"]
|
@@ -29,7 +32,7 @@ game.avg_rating # => "4.6"
|
|
29
32
|
game.avg_ratings_count # => 268
|
30
33
|
game.platforms # => ["Windows"]
|
31
34
|
game.languages # => ["English", "French", "Italian", "German", "Spanish"]
|
32
|
-
game.
|
35
|
+
game.pegi_age # => false
|
33
36
|
game.developer # => "Mossmouth"
|
34
37
|
game.publisher # => "Mossmouth"
|
35
38
|
game.bonus_content # => [...]
|
@@ -51,11 +54,12 @@ require 'gogcom'
|
|
51
54
|
sale = Gogcom.sale
|
52
55
|
# sale = Gogcom.sale(:type => "games")
|
53
56
|
# sale = Gogcom.sale(:type => "movies")
|
57
|
+
# sale = Gogcom.sale(:limit => 5)
|
54
58
|
|
55
59
|
sale.each do |game|
|
56
60
|
game.title
|
57
|
-
game.
|
58
|
-
game.
|
61
|
+
game.current_price
|
62
|
+
game.original_price
|
59
63
|
game.discount_percentage
|
60
64
|
game.discount_amount
|
61
65
|
end
|
data/lib/gogcom.rb
CHANGED
@@ -2,18 +2,20 @@ module Gogcom
|
|
2
2
|
class << self
|
3
3
|
# Gets game information from website.
|
4
4
|
#
|
5
|
-
# @param [
|
6
|
-
|
7
|
-
|
5
|
+
# @param [Hash]
|
6
|
+
# :name => "Spelunky"
|
7
|
+
def game(options)
|
8
|
+
Gogcom::Game.new(options).get()
|
8
9
|
end
|
9
10
|
|
10
11
|
# Gets all items on sale.
|
11
12
|
#
|
12
13
|
# @param [Hash]
|
13
14
|
# :type => "games"
|
14
|
-
# :type => "movies"
|
15
|
+
# :type => "movies"
|
16
|
+
# :limit => 5
|
15
17
|
def sale(options = {})
|
16
|
-
|
18
|
+
Gogcom::Sale.new(options).get()
|
17
19
|
end
|
18
20
|
|
19
21
|
# Gets all news
|
@@ -21,7 +23,7 @@ module Gogcom
|
|
21
23
|
# @param [Hash]
|
22
24
|
# :limit => 5
|
23
25
|
def news(options = {})
|
24
|
-
Gogcom::News.
|
26
|
+
Gogcom::News.new(options).get()
|
25
27
|
end
|
26
28
|
end
|
27
29
|
end
|
@@ -30,8 +32,6 @@ require 'net/http'
|
|
30
32
|
require 'json'
|
31
33
|
require 'simple-rss'
|
32
34
|
|
33
|
-
require 'gogcom/func'
|
34
|
-
require 'gogcom/review'
|
35
35
|
require 'gogcom/game'
|
36
36
|
require 'gogcom/sale'
|
37
37
|
require 'gogcom/news'
|
data/lib/gogcom/game.rb
CHANGED
@@ -1,21 +1,47 @@
|
|
1
1
|
module Gogcom
|
2
2
|
class Game
|
3
|
-
attr_accessor :title, :genres, :download_size, :release_date, :description, :price, :avg_rating,
|
4
|
-
:avg_ratings_count, :platforms, :pegiAge, :languages, :developer, :publisher,
|
5
|
-
:game_modes, :bonus_content, :reviews
|
6
3
|
|
7
|
-
def
|
8
|
-
name =
|
4
|
+
def initialize(options)
|
5
|
+
@name = options[:name] || nil
|
6
|
+
end
|
7
|
+
|
8
|
+
# Main method to get game data
|
9
|
+
def get()
|
10
|
+
parse(fetch())
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
# Fetches raw data and parses as JSON object
|
16
|
+
#
|
17
|
+
# @return [Object]
|
18
|
+
def fetch()
|
19
|
+
name = urlfy(@name)
|
9
20
|
page = Net::HTTP.get(URI("http://www.gog.com/game/" + name))
|
10
21
|
data = JSON.parse(page[/(?<=var gogData = )(.*)(?=;)/,1])
|
11
22
|
data
|
12
23
|
end
|
13
24
|
|
14
|
-
|
25
|
+
# Parses raw data and returns game item.
|
26
|
+
#
|
27
|
+
# @param [Object]
|
28
|
+
# @return [Struct]
|
29
|
+
def parse(data)
|
30
|
+
game = GameItem.new(get_title(data), get_genres(data),
|
31
|
+
get_download_size(data), get_release_date(data), get_description(data),
|
32
|
+
get_price(data), get_avg_rating(data), get_avg_ratings_count(data),
|
33
|
+
get_platforms(data), get_languages(data), get_developer(data),
|
34
|
+
get_publisher(data), get_modes(data), get_bonus_content(data),
|
35
|
+
get_reviews(data), get_pegi_age(data))
|
36
|
+
|
37
|
+
game
|
38
|
+
end
|
39
|
+
|
40
|
+
def get_title(data)
|
15
41
|
data["gameProductData"]["title"]
|
16
42
|
end
|
17
43
|
|
18
|
-
def
|
44
|
+
def get_genres(data)
|
19
45
|
genres = []
|
20
46
|
genres_raw = data["gameProductData"]["genres"]
|
21
47
|
genres_raw.each do |genre|
|
@@ -25,31 +51,31 @@ module Gogcom
|
|
25
51
|
genres
|
26
52
|
end
|
27
53
|
|
28
|
-
def
|
54
|
+
def get_download_size(data)
|
29
55
|
data["gameProductData"]["downloadSize"]
|
30
56
|
end
|
31
57
|
|
32
|
-
def
|
58
|
+
def get_release_date(data)
|
33
59
|
data["gameProductData"]["releaseDate"]
|
34
60
|
end
|
35
61
|
|
36
|
-
def
|
62
|
+
def get_description(data)
|
37
63
|
data["gameProductData"]["description"]["full"]
|
38
64
|
end
|
39
65
|
|
40
|
-
def
|
66
|
+
def get_price(data)
|
41
67
|
data["gameProductData"]["price"]["symbol"] + data["gameProductData"]["price"]["amount"]
|
42
68
|
end
|
43
69
|
|
44
|
-
def
|
70
|
+
def get_avg_rating(data)
|
45
71
|
data["gameProductData"]["rating"].to_s.insert(1, ".")
|
46
72
|
end
|
47
73
|
|
48
|
-
def
|
74
|
+
def get_avg_ratings_count(data)
|
49
75
|
data["gameProductData"]["votesCount"]
|
50
76
|
end
|
51
77
|
|
52
|
-
def
|
78
|
+
def get_platforms(data)
|
53
79
|
platforms = []
|
54
80
|
platforms_raw = data["gameProductData"]["worksOn"]
|
55
81
|
platforms_raw.each do |platform|
|
@@ -61,19 +87,19 @@ module Gogcom
|
|
61
87
|
platforms
|
62
88
|
end
|
63
89
|
|
64
|
-
def
|
90
|
+
def get_languages(data)
|
65
91
|
data["gameProductData"]["languages"]
|
66
92
|
end
|
67
93
|
|
68
|
-
def
|
94
|
+
def get_developer(data)
|
69
95
|
data["gameProductData"]["developer"]["name"]
|
70
96
|
end
|
71
97
|
|
72
|
-
def
|
98
|
+
def get_publisher(data)
|
73
99
|
data["gameProductData"]["publisher"]["name"]
|
74
100
|
end
|
75
101
|
|
76
|
-
def
|
102
|
+
def get_modes(data)
|
77
103
|
game_modes = []
|
78
104
|
modes_raw = data["gameProductData"]["modes"]
|
79
105
|
modes_raw.each do |mode|
|
@@ -83,7 +109,7 @@ module Gogcom
|
|
83
109
|
game_modes
|
84
110
|
end
|
85
111
|
|
86
|
-
def
|
112
|
+
def get_bonus_content(data)
|
87
113
|
bonusContent = []
|
88
114
|
bonusContent_raw = data["gameProductData"]["bonusContent"]
|
89
115
|
|
@@ -98,7 +124,7 @@ module Gogcom
|
|
98
124
|
bonusContent
|
99
125
|
end
|
100
126
|
|
101
|
-
def
|
127
|
+
def get_reviews(data)
|
102
128
|
reviews = []
|
103
129
|
reviews_raw = data["reviews"]["pages"][0]
|
104
130
|
reviews_raw.each do |review|
|
@@ -115,32 +141,26 @@ module Gogcom
|
|
115
141
|
reviews
|
116
142
|
end
|
117
143
|
|
118
|
-
def
|
144
|
+
def get_pegi_age(data)
|
119
145
|
data["gameProductData"]["pegiAge"]
|
120
146
|
end
|
121
147
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
game.release_date = get_release_date(data)
|
130
|
-
game.description = get_description(data)
|
131
|
-
game.price = get_price(data)
|
132
|
-
game.avg_rating = get_avg_rating(data)
|
133
|
-
game.avg_ratings_count = get_avg_ratings_count(data)
|
134
|
-
game.platforms = get_platforms(data)
|
135
|
-
game.pegiAge = get_pegiAge(data)
|
136
|
-
game.languages = get_languages(data)
|
137
|
-
game.developer = get_developer(data)
|
138
|
-
game.publisher = get_publisher(data)
|
139
|
-
game.game_modes = get_modes(data)
|
140
|
-
game.bonus_content = get_bonusContent(data)
|
141
|
-
game.reviews = get_reviews(data)
|
142
|
-
|
143
|
-
game
|
148
|
+
# Converts "Game Name" to "game_name"
|
149
|
+
#
|
150
|
+
# @param [String]
|
151
|
+
# @return [String]
|
152
|
+
def urlfy(name)
|
153
|
+
name = name.gsub(/[^0-9A-Za-z\s]/, '').gsub(/\s/, '_').downcase
|
154
|
+
name
|
144
155
|
end
|
145
156
|
end
|
157
|
+
|
158
|
+
class GameItem < Struct.new(:title, :genres, :download_size, :release_date,
|
159
|
+
:description, :price, :avg_rating, :avg_ratings_count, :platforms,
|
160
|
+
:languages, :developer, :publisher, :game_modes, :bonus_content, :reviews,
|
161
|
+
:pegi_age)
|
162
|
+
end
|
163
|
+
|
164
|
+
class Review < Struct.new(:title, :rating, :author, :body)
|
165
|
+
end
|
146
166
|
end
|
data/lib/gogcom/news.rb
CHANGED
@@ -1,38 +1,47 @@
|
|
1
1
|
module Gogcom
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
2
|
+
class News
|
3
|
+
|
4
|
+
def initialize(options)
|
5
|
+
@limit = options[:limit] || nil
|
6
|
+
end
|
7
|
+
|
8
|
+
# Main method to get news data.
|
9
|
+
def get()
|
10
|
+
parse(fetch())
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
# Fetches raw data from source.
|
16
|
+
#
|
17
|
+
# @return [String]
|
18
|
+
def fetch()
|
19
|
+
url = "http://www.gog.com/frontpage/rss"
|
20
|
+
page = Net::HTTP.get(URI(url))
|
21
|
+
page
|
22
|
+
end
|
23
|
+
|
24
|
+
# Parses raw data and returns news items
|
25
|
+
#
|
26
|
+
# @return [Array]
|
27
|
+
def parse(data)
|
28
|
+
rss = SimpleRSS.parse data
|
29
|
+
news = Array.new
|
30
|
+
|
31
|
+
rss.items.each do |item|
|
32
|
+
news_item = NewsItem.new(item.title, item.link, item.description.force_encoding("UTF-8"), item.pubDate)
|
33
|
+
|
34
|
+
news.push news_item
|
35
|
+
end
|
36
|
+
|
37
|
+
unless @limit.nil?
|
38
|
+
news.take(@limit)
|
39
|
+
else
|
40
|
+
news
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
class NewsItem < Struct.new(:title, :link, :body, :date)
|
46
|
+
end
|
38
47
|
end
|
data/lib/gogcom/sale.rb
CHANGED
@@ -1,73 +1,88 @@
|
|
1
1
|
module Gogcom
|
2
2
|
class Sale
|
3
|
-
attr_accessor :title, :price_current, :price_original, :discount_percentage,
|
4
|
-
:discount_amount
|
5
3
|
|
6
|
-
def
|
7
|
-
|
8
|
-
|
9
|
-
data
|
4
|
+
def initialize(options)
|
5
|
+
@type = options[:type] || nil
|
6
|
+
@limit = options[:limit] || nil
|
10
7
|
end
|
11
8
|
|
12
|
-
|
13
|
-
|
9
|
+
# Main method to get sales data.
|
10
|
+
def get()
|
11
|
+
parse(fetch())
|
14
12
|
end
|
15
13
|
|
16
|
-
|
17
|
-
data["on_sale"][i]["price"]["symbol"] + data["on_sale"][i]["price"]["amount"]
|
18
|
-
end
|
14
|
+
private
|
19
15
|
|
20
|
-
|
21
|
-
|
16
|
+
# Fetches raw data from source.
|
17
|
+
#
|
18
|
+
# @return [Object]
|
19
|
+
def fetch()
|
20
|
+
url = "http://www.gog.com/"
|
21
|
+
page = Net::HTTP.get(URI(url))
|
22
|
+
@data = JSON.parse(page[/(?<=var gogData = )(.*)(?=;)/,1])
|
22
23
|
end
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
25
|
+
# Parses raw data and returns sale items.
|
26
|
+
#
|
27
|
+
# @return [Array]
|
28
|
+
def parse(data)
|
29
|
+
items = []
|
30
|
+
|
31
|
+
data["on_sale"].each do |item|
|
32
|
+
sale_item = SaleItem.new(get_title(item), get_current_price(item),
|
33
|
+
get_original_price(item), get_discount_percentage(item),
|
34
|
+
get_discount_amount(item))
|
35
|
+
|
36
|
+
if @type.nil?
|
37
|
+
items.push(sale_item)
|
38
|
+
else
|
39
|
+
if (@type == "games" && is_game?(item))
|
40
|
+
items.push(sale_item)
|
41
|
+
end
|
42
|
+
|
43
|
+
if (@type == "movies" && is_movie?(item))
|
44
|
+
items.push(sale_item)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
unless @limit.nil?
|
50
|
+
items.take(@limit)
|
51
|
+
else
|
52
|
+
items
|
53
|
+
end
|
54
|
+
end
|
27
55
|
|
28
|
-
def
|
29
|
-
|
56
|
+
def get_title(data)
|
57
|
+
data["title"]
|
30
58
|
end
|
31
59
|
|
32
|
-
def
|
33
|
-
data["
|
60
|
+
def get_current_price(data)
|
61
|
+
data["price"]["symbol"] + data["price"]["amount"]
|
34
62
|
end
|
35
63
|
|
36
|
-
def
|
37
|
-
data["
|
64
|
+
def get_original_price(data)
|
65
|
+
data["price"]["symbol"] + data["price"]["baseAmount"]
|
38
66
|
end
|
39
67
|
|
40
|
-
def
|
41
|
-
data
|
42
|
-
|
43
|
-
count = 0
|
44
|
-
type = options[:type] || nil
|
68
|
+
def get_discount_percentage(data)
|
69
|
+
data["price"]["discountPercentage"]
|
70
|
+
end
|
45
71
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
game.title = get_title(data, count)
|
50
|
-
game.price_current = get_price_current(data, count)
|
51
|
-
game.price_original = get_price_original(data, count)
|
52
|
-
game.discount_percentage = get_discount_percentage(data, count)
|
53
|
-
game.discount_amount = get_discount_amount(data, count)
|
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
|
72
|
+
def get_discount_amount(data)
|
73
|
+
data["price"]["symbol"] + data["price"]["discountDifference"]
|
74
|
+
end
|
66
75
|
|
67
|
-
|
68
|
-
|
76
|
+
def is_game?(data)
|
77
|
+
data["isGame"]
|
78
|
+
end
|
69
79
|
|
70
|
-
|
80
|
+
def is_movie?(data)
|
81
|
+
data["isMovie"]
|
71
82
|
end
|
72
83
|
end
|
84
|
+
|
85
|
+
class SaleItem < Struct.new(:title, :current_price, :original_price,
|
86
|
+
:discount_percentage, :discount_amount, :isGame, :isMovie)
|
87
|
+
end
|
73
88
|
end
|
data/lib/gogcom/version.rb
CHANGED
data/test/test_game.rb
CHANGED
@@ -3,82 +3,75 @@ require 'helper'
|
|
3
3
|
class GogcomGameTest < Minitest::Test
|
4
4
|
def setup
|
5
5
|
VCR.use_cassette('game') do
|
6
|
-
@
|
6
|
+
@game = Gogcom.game(:name => "Faster Than Light")
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
-
def
|
11
|
-
assert @
|
10
|
+
def test_game
|
11
|
+
assert @game.is_a?(Struct)
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
15
|
-
assert_equal
|
14
|
+
def test_game_title
|
15
|
+
assert_equal @game.title, "FTL: Advanced Edition"
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
19
|
-
assert_equal
|
18
|
+
def test_game_genres
|
19
|
+
assert_equal @game.genres, ["Strategy", "Simulation", "Sci-fi"]
|
20
20
|
end
|
21
21
|
|
22
|
-
def
|
23
|
-
assert_equal
|
22
|
+
def test_game_download_size
|
23
|
+
assert_equal @game.download_size, "205 MB"
|
24
24
|
end
|
25
25
|
|
26
|
-
def
|
27
|
-
assert_equal
|
26
|
+
def test_game_release_date
|
27
|
+
assert_equal @game.release_date, 1347595200
|
28
28
|
end
|
29
29
|
|
30
|
-
def
|
31
|
-
assert_kind_of String,
|
30
|
+
def test_game_description
|
31
|
+
assert_kind_of String, @game.description
|
32
32
|
end
|
33
33
|
|
34
|
-
def
|
35
|
-
assert_match /^\$\d+(\.\d{2})?$/,
|
34
|
+
def test_game_price
|
35
|
+
assert_match /^\$\d+(\.\d{2})?$/, @game.price
|
36
36
|
end
|
37
37
|
|
38
|
-
def
|
39
|
-
assert_match /\d.\d/,
|
38
|
+
def test_game_avg_ratings
|
39
|
+
assert_match /\d.\d/, @game.avg_rating.to_s
|
40
40
|
end
|
41
41
|
|
42
|
-
def
|
43
|
-
assert_kind_of Integer,
|
42
|
+
def test_game_avg_ratings_count
|
43
|
+
assert_kind_of Integer, @game.avg_ratings_count
|
44
44
|
end
|
45
45
|
|
46
|
-
def
|
47
|
-
assert_equal
|
46
|
+
def test_game_platforms
|
47
|
+
assert_equal @game.platforms, ["Windows", "Mac"]
|
48
48
|
end
|
49
49
|
|
50
|
-
def
|
51
|
-
assert_equal
|
50
|
+
def test_game_pegi_age
|
51
|
+
assert_equal @game.pegi_age, false
|
52
52
|
end
|
53
53
|
|
54
|
-
def
|
55
|
-
assert_equal
|
54
|
+
def test_game_languages
|
55
|
+
assert_equal @game.languages, ["English"]
|
56
56
|
end
|
57
57
|
|
58
|
-
def
|
59
|
-
assert_equal
|
58
|
+
def test_game_developer
|
59
|
+
assert_equal @game.developer, "Subset Games"
|
60
60
|
end
|
61
61
|
|
62
|
-
def
|
63
|
-
assert_equal
|
62
|
+
def test_game_publisher
|
63
|
+
assert_equal @game.publisher, "Subset Games"
|
64
64
|
end
|
65
65
|
|
66
|
-
def
|
67
|
-
assert_equal
|
66
|
+
def test_game_modes
|
67
|
+
assert_equal @game.game_modes, ["Single-player"]
|
68
68
|
end
|
69
69
|
|
70
|
-
def
|
71
|
-
assert_equal
|
70
|
+
def test_game_bonus_content
|
71
|
+
assert_equal @game.bonus_content, ["wallpaper", "soundtrack sample (5 tracks)", "avatars", "artworks"]
|
72
72
|
end
|
73
73
|
|
74
|
-
def
|
75
|
-
assert
|
76
|
-
end
|
77
|
-
|
78
|
-
def test_get
|
79
|
-
VCR.use_cassette('game') do
|
80
|
-
game = Gogcom::Game.get("Faster Than Light")
|
81
|
-
assert_kind_of Object, game
|
82
|
-
end
|
74
|
+
def test_game_reviews
|
75
|
+
assert @game.reviews.is_a?(Array)
|
83
76
|
end
|
84
77
|
end
|
data/test/test_gogcom.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
class GogcomTest < Minitest::Test
|
2
2
|
def test_game
|
3
3
|
VCR.use_cassette('game') do
|
4
|
-
game = Gogcom.game("Faster Than Light")
|
5
|
-
assert_kind_of
|
4
|
+
game = Gogcom.game(:name => "Faster Than Light")
|
5
|
+
assert_kind_of Struct, game
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
@@ -12,4 +12,11 @@ class GogcomTest < Minitest::Test
|
|
12
12
|
assert_kind_of Array, sale
|
13
13
|
end
|
14
14
|
end
|
15
|
+
|
16
|
+
def test_news
|
17
|
+
VCR.use_cassette('news') do
|
18
|
+
news = Gogcom.news
|
19
|
+
assert_kind_of Array, news
|
20
|
+
end
|
21
|
+
end
|
15
22
|
end
|
data/test/test_news.rb
CHANGED
@@ -1,20 +1,22 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
3
|
class GogcomNewsTest < Minitest::Test
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
end
|
4
|
+
def setup
|
5
|
+
VCR.use_cassette('news') do
|
6
|
+
@news = Gogcom.news()
|
7
|
+
end
|
9
8
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
VCR.use_cassette('news') do
|
10
|
+
@news_limit = Gogcom.news(:limit => 2)
|
11
|
+
end
|
12
|
+
end
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
def test_news
|
15
|
+
assert @news.is_a?(Array)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_news_limit
|
19
|
+
assert @news_limit.is_a?(Array)
|
20
|
+
assert @news_limit.count, 2
|
21
|
+
end
|
20
22
|
end
|
data/test/test_sale.rb
CHANGED
@@ -3,48 +3,56 @@ require 'helper'
|
|
3
3
|
class GogcomSaleTest < Minitest::Test
|
4
4
|
def setup
|
5
5
|
VCR.use_cassette('index') do
|
6
|
-
@
|
6
|
+
@items = Gogcom.sale()
|
7
7
|
end
|
8
8
|
|
9
|
-
|
9
|
+
VCR.use_cassette('index') do
|
10
|
+
@items_type_games = Gogcom.sale(type: "games")
|
11
|
+
end
|
12
|
+
|
13
|
+
VCR.use_cassette('index') do
|
14
|
+
@items_type_movies = Gogcom.sale(type: "movies")
|
15
|
+
end
|
16
|
+
|
17
|
+
VCR.use_cassette('index') do
|
18
|
+
@items_limit = Gogcom.sale(limit: 2)
|
19
|
+
end
|
10
20
|
end
|
11
21
|
|
12
|
-
def
|
13
|
-
assert @
|
22
|
+
def test_sale
|
23
|
+
assert @items.is_a?(Array)
|
14
24
|
end
|
15
25
|
|
16
|
-
def
|
17
|
-
|
26
|
+
def test_sale_type_games
|
27
|
+
assert @items_type_games.is_a?(Array)
|
18
28
|
end
|
19
29
|
|
20
|
-
def
|
21
|
-
|
30
|
+
def test_sale_type_movies
|
31
|
+
assert @items_type_movies.is_a?(Array)
|
22
32
|
end
|
23
33
|
|
24
|
-
def
|
25
|
-
|
34
|
+
def test_sale_limit
|
35
|
+
assert @items_limit.is_a?(Array)
|
36
|
+
assert_equal @items_limit.count, 2
|
26
37
|
end
|
27
38
|
|
28
|
-
def
|
29
|
-
assert_equal
|
39
|
+
def test_sale_title
|
40
|
+
assert_equal @items.first.title, "Witcher 3: Wild Hunt, The - preorder"
|
30
41
|
end
|
31
42
|
|
32
|
-
def
|
33
|
-
assert_equal
|
43
|
+
def test_sale_current_price
|
44
|
+
assert_equal @items.first.current_price, "$53.99"
|
34
45
|
end
|
35
46
|
|
36
|
-
def
|
37
|
-
assert_equal
|
47
|
+
def test_sale_original_price
|
48
|
+
assert_equal @items.first.original_price, "$59.99"
|
38
49
|
end
|
39
|
-
|
40
|
-
def
|
41
|
-
assert_equal
|
50
|
+
|
51
|
+
def test_sale_discount_percentage
|
52
|
+
assert_equal @items.first.discount_percentage, 10
|
42
53
|
end
|
43
54
|
|
44
|
-
def
|
45
|
-
|
46
|
-
sale = Gogcom::Sale.get
|
47
|
-
assert_kind_of Object, sale
|
48
|
-
end
|
55
|
+
def test_discount_amount
|
56
|
+
assert_equal @items.first.discount_amount, "$6.00"
|
49
57
|
end
|
50
58
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gogcom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.26
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rolandas Barysas
|
@@ -92,14 +92,14 @@ dependencies:
|
|
92
92
|
requirements:
|
93
93
|
- - "~>"
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version: '1.
|
95
|
+
version: '1.20'
|
96
96
|
type: :development
|
97
97
|
prerelease: false
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
100
|
- - "~>"
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: '1.
|
102
|
+
version: '1.20'
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: json
|
105
105
|
requirement: !ruby/object:Gem::Requirement
|
@@ -151,17 +151,14 @@ files:
|
|
151
151
|
- README.md
|
152
152
|
- Rakefile
|
153
153
|
- lib/gogcom.rb
|
154
|
-
- lib/gogcom/func.rb
|
155
154
|
- lib/gogcom/game.rb
|
156
155
|
- lib/gogcom/news.rb
|
157
|
-
- lib/gogcom/review.rb
|
158
156
|
- lib/gogcom/sale.rb
|
159
157
|
- lib/gogcom/version.rb
|
160
158
|
- test/fixtures/vcr_cassettes/game.yml
|
161
159
|
- test/fixtures/vcr_cassettes/index.yml
|
162
160
|
- test/fixtures/vcr_cassettes/news.yml
|
163
161
|
- test/helper.rb
|
164
|
-
- test/test_func.rb
|
165
162
|
- test/test_game.rb
|
166
163
|
- test/test_gogcom.rb
|
167
164
|
- test/test_news.rb
|
data/lib/gogcom/func.rb
DELETED
data/lib/gogcom/review.rb
DELETED