gogcom 0.0.1 → 0.0.2.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -8
- data/lib/gogcom.rb +2 -0
- data/lib/gogcom/game.rb +1 -1
- data/lib/gogcom/gogcom.rb +37 -29
- data/lib/gogcom/review.rb +3 -0
- data/lib/gogcom/version.rb +1 -3
- data/test/helper.rb +2 -0
- data/test/test_gogcom.rb +9 -4
- metadata +74 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d1240977c38c857e33ec0cfd413edaf14f33513
|
4
|
+
data.tar.gz: e662630e6f6d2981bc2310a05d1e0d39134b9ef8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd69b931257d5a6ee027be4c398fd68485e1579176b2bfcee3347e2a42ecdda4f21a98a7dc87807ac75f1b4cf1aa3c241099f291bf74f51e3cdead4a4e557e36
|
7
|
+
data.tar.gz: d84736b37f6ee167dc47df9987f1686709592eaf515b1d311df5881a1a70cde58d91591e7263069e687c701422c70940d76fb6413a2fbace238f891354cdcbcc
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
gogcom [![](https://api.travis-ci.org/rb-/gogcom.svg?branch=develop)](https://travis-ci.org/rb-/gogcom)
|
1
|
+
gogcom [![Gem Version](https://badge.fury.io/rb/gogcom.svg)](http://badge.fury.io/rb/gogcom) [![](https://api.travis-ci.org/rb-/gogcom.svg?branch=develop)](https://travis-ci.org/rb-/gogcom) [![Dependency Status](https://gemnasium.com/rb-/gogcom.svg)](https://gemnasium.com/rb-/gogcom) [![Coverage Status](https://coveralls.io/repos/rb-/gogcom/badge.png?branch=develop)](https://coveralls.io/r/rb-/gogcom?branch=develop)
|
2
2
|
============
|
3
3
|
|
4
4
|
Gogcom is a Ruby library for easy querying gog.com website.
|
@@ -8,7 +8,7 @@ This library is in early stages and not ready for general use.
|
|
8
8
|
## Usage
|
9
9
|
|
10
10
|
```
|
11
|
-
gem 'gogcom', '~> 0.0.
|
11
|
+
gem 'gogcom', '~> 0.0.2'
|
12
12
|
bundle install
|
13
13
|
```
|
14
14
|
|
@@ -18,17 +18,23 @@ require 'gogcom'
|
|
18
18
|
game = Gogcom.game("Spelunky")
|
19
19
|
|
20
20
|
game.title # => "Spelunky"
|
21
|
-
game.genres # => ["
|
21
|
+
game.genres # => ["Action", "Adventure", "Platformer"]
|
22
22
|
game.download_size # => "143 MB"
|
23
|
-
game.release_date # =>
|
23
|
+
game.release_date # => 1375934400 (Unix time)
|
24
24
|
game.price # => "$14.99"
|
25
|
-
game.avg_rating # => 4.
|
26
|
-
game.avg_ratings_count # =>
|
27
|
-
game.platforms # => ["Windows
|
25
|
+
game.avg_rating # => "4.6"
|
26
|
+
game.avg_ratings_count # => 268
|
27
|
+
game.platforms # => ["Windows"]
|
28
28
|
game.languages # => ["English", "French", "Italian", "German", "Spanish"]
|
29
29
|
game.developer # => "Mossmouth"
|
30
30
|
game.publisher # => "Mossmouth"
|
31
|
-
game.game_modes # => ["
|
31
|
+
game.game_modes # => ["Single-player", "Multi-player", "Co-op"]
|
32
|
+
|
33
|
+
# Reviews right now are limited to 5 (sorted by most helpful, same as in actual website)
|
34
|
+
game.reviews[0].title # => "..."
|
35
|
+
game.reviews[0].rating # => "..."
|
36
|
+
game.reviews[0].author # => "..."
|
37
|
+
game.reviews[0].body # => "..."
|
32
38
|
```
|
33
39
|
|
34
40
|
## License
|
data/lib/gogcom.rb
CHANGED
data/lib/gogcom/game.rb
CHANGED
data/lib/gogcom/gogcom.rb
CHANGED
@@ -5,63 +5,71 @@ class Gogcom
|
|
5
5
|
def self.game(name)
|
6
6
|
name = urlfy_name(name)
|
7
7
|
page = Nokogiri::HTML(open(GOG_GAME_BASE_URL + name))
|
8
|
+
data = JSON.parse(page.css('script')[0].text.gsub(/^\s+|\s+$/, "").gsub("var gogData = ", "")[0..-2])
|
8
9
|
|
9
10
|
game = Game.new
|
10
11
|
|
11
12
|
# Game title
|
12
|
-
|
13
|
-
game.title = title_raw.slice(0..(title_raw.index('for download')-2))
|
13
|
+
game.title = data["gameProductData"]["title"]
|
14
14
|
|
15
15
|
# Game genres
|
16
16
|
game.genres = []
|
17
|
-
genres_raw =
|
17
|
+
genres_raw = data["gameProductData"]["genres"]
|
18
18
|
genres_raw.each do |genre|
|
19
|
-
game.genres.push(genre
|
19
|
+
game.genres.push(genre["name"])
|
20
20
|
end
|
21
21
|
|
22
22
|
# Download size
|
23
|
-
game.download_size =
|
23
|
+
game.download_size = data["gameProductData"]["downloadSize"]
|
24
24
|
|
25
25
|
# Release date
|
26
|
-
game.release_date =
|
26
|
+
game.release_date = data["gameProductData"]["releaseDate"]
|
27
27
|
|
28
28
|
# Price
|
29
|
-
price =
|
30
|
-
game.price = "$" + (price.to_f / 100).to_s
|
29
|
+
game.price = data["gameProductData"]["price"]["symbol"] + data["gameProductData"]["price"]["amount"]
|
31
30
|
|
32
31
|
# Average rating
|
33
|
-
game.avg_rating =
|
34
|
-
stuff_raw = page.css('ul.game-specification li')[2].css('.data .usr_rate span')
|
35
|
-
stuff_raw.each do |star|
|
36
|
-
if star.attr('class') == 'usr_s_f'
|
37
|
-
game.avg_rating += 1.0
|
38
|
-
elsif star.attr('class') == 'usr_s_h'
|
39
|
-
game.avg_rating += 0.5
|
40
|
-
end
|
41
|
-
end
|
32
|
+
game.avg_rating = data["gameProductData"]["rating"].to_s.insert(1, ".")
|
42
33
|
|
43
34
|
# Rating count
|
44
|
-
|
45
|
-
game.avg_ratings_count = avg_ratings_count_raw.gsub(/\D/, '').to_i
|
35
|
+
game.avg_ratings_count = data["gameProductData"]["votesCount"]
|
46
36
|
|
47
37
|
# Platforms
|
48
38
|
game.platforms = []
|
49
|
-
platforms_raw =
|
50
|
-
|
39
|
+
platforms_raw = data["gameProductData"]["worksOn"]
|
40
|
+
platforms_raw.each do |platform|
|
41
|
+
if(platform[1])
|
42
|
+
game.platforms.push(platform[0])
|
43
|
+
end
|
44
|
+
end
|
51
45
|
|
52
46
|
# Languages
|
53
|
-
|
54
|
-
game.languages = languages_raw.gsub("Audio and text:", "").gsub("Text only:", "")
|
55
|
-
.gsub(/\s+/, '').gsub('.', ',').split(',')
|
47
|
+
game.languages = data["gameProductData"]["languages"]
|
56
48
|
|
57
|
-
|
58
|
-
game.
|
49
|
+
# Developer & Publisher
|
50
|
+
game.developer = data["gameProductData"]["developer"]["name"]
|
51
|
+
game.publisher = data["gameProductData"]["publisher"]["name"]
|
59
52
|
|
60
53
|
# Game modes
|
61
54
|
game.game_modes = []
|
62
|
-
|
63
|
-
|
64
|
-
|
55
|
+
modes_raw = data["gameProductData"]["modes"]
|
56
|
+
modes_raw.each do |mode|
|
57
|
+
game.game_modes.push(mode["title"])
|
58
|
+
end
|
59
|
+
|
60
|
+
# Reviews
|
61
|
+
game.reviews = []
|
62
|
+
reviews_raw = data["reviews"]["pages"][0]
|
63
|
+
reviews_raw.each do |review|
|
64
|
+
r = Review.new
|
65
|
+
|
66
|
+
r.title = review["title"]
|
67
|
+
r.rating = review["rating"].to_s.insert(1, ".")
|
68
|
+
r.author = review["author"]["name"]
|
69
|
+
r.body = review["description"]
|
70
|
+
|
71
|
+
game.reviews.push(r)
|
72
|
+
end
|
65
73
|
|
66
74
|
game
|
67
75
|
end
|
data/lib/gogcom/version.rb
CHANGED
data/test/helper.rb
ADDED
data/test/test_gogcom.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'minitest/autorun'
|
2
|
+
require 'helper'
|
2
3
|
require 'gogcom'
|
3
4
|
|
4
5
|
class GogcomTest < MiniTest::Test
|
@@ -12,7 +13,7 @@ class GogcomTest < MiniTest::Test
|
|
12
13
|
end
|
13
14
|
|
14
15
|
def test_that_game_has_genres
|
15
|
-
assert_equal ["
|
16
|
+
assert_equal ["Strategy", "Simulation", "Sci-fi"], @game.genres
|
16
17
|
end
|
17
18
|
|
18
19
|
def test_that_game_has_download_size
|
@@ -20,7 +21,7 @@ class GogcomTest < MiniTest::Test
|
|
20
21
|
end
|
21
22
|
|
22
23
|
def test_that_game_has_release_date
|
23
|
-
assert_equal
|
24
|
+
assert_equal 1347595200, @game.release_date
|
24
25
|
end
|
25
26
|
|
26
27
|
def test_that_game_has_price
|
@@ -36,7 +37,7 @@ class GogcomTest < MiniTest::Test
|
|
36
37
|
end
|
37
38
|
|
38
39
|
def test_that_game_has_platforms
|
39
|
-
assert_equal ["Windows
|
40
|
+
assert_equal ["Windows", "Mac"], @game.platforms
|
40
41
|
end
|
41
42
|
|
42
43
|
def test_that_game_has_languages
|
@@ -52,7 +53,11 @@ class GogcomTest < MiniTest::Test
|
|
52
53
|
end
|
53
54
|
|
54
55
|
def test_that_game_has_game_modes
|
55
|
-
assert_equal ["
|
56
|
+
assert_equal ["Single-player"], @game.game_modes
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_that_game_has_reviews
|
60
|
+
assert !@game.reviews.empty?, "Reviews array is empty"
|
56
61
|
end
|
57
62
|
|
58
63
|
end
|
metadata
CHANGED
@@ -1,29 +1,95 @@
|
|
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.2.pre
|
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-
|
11
|
+
date: 2014-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: minitest
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.4'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 5.4.1
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '5.4'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 5.4.1
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rake
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '10.3'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 10.3.2
|
43
|
+
type: :development
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '10.3'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 10.3.2
|
13
53
|
- !ruby/object:Gem::Dependency
|
14
54
|
name: nokogiri
|
15
55
|
requirement: !ruby/object:Gem::Requirement
|
16
56
|
requirements:
|
17
|
-
- -
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '1.6'
|
60
|
+
- - ">="
|
18
61
|
- !ruby/object:Gem::Version
|
19
62
|
version: 1.6.3.1
|
20
63
|
type: :runtime
|
21
64
|
prerelease: false
|
22
65
|
version_requirements: !ruby/object:Gem::Requirement
|
23
66
|
requirements:
|
24
|
-
- -
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '1.6'
|
70
|
+
- - ">="
|
25
71
|
- !ruby/object:Gem::Version
|
26
72
|
version: 1.6.3.1
|
73
|
+
- !ruby/object:Gem::Dependency
|
74
|
+
name: json
|
75
|
+
requirement: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - "~>"
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '1.8'
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.8.1
|
83
|
+
type: :runtime
|
84
|
+
prerelease: false
|
85
|
+
version_requirements: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.8'
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: 1.8.1
|
27
93
|
description: Provides a simple, easy-to-use interface for gog.com website.
|
28
94
|
email:
|
29
95
|
- r.b@riseup.net
|
@@ -37,7 +103,9 @@ files:
|
|
37
103
|
- lib/gogcom.rb
|
38
104
|
- lib/gogcom/game.rb
|
39
105
|
- lib/gogcom/gogcom.rb
|
106
|
+
- lib/gogcom/review.rb
|
40
107
|
- lib/gogcom/version.rb
|
108
|
+
- test/helper.rb
|
41
109
|
- test/test_gogcom.rb
|
42
110
|
homepage: http://rubygems.org/gems/gogcom
|
43
111
|
licenses:
|
@@ -54,9 +122,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
54
122
|
version: '0'
|
55
123
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
124
|
requirements:
|
57
|
-
- - "
|
125
|
+
- - ">"
|
58
126
|
- !ruby/object:Gem::Version
|
59
|
-
version:
|
127
|
+
version: 1.3.1
|
60
128
|
requirements: []
|
61
129
|
rubyforge_project:
|
62
130
|
rubygems_version: 2.2.2
|