desuraify 0.0.5.pre → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +8 -9
- data/lib/desuraify/base.rb +44 -107
- data/lib/desuraify/company.rb +3 -3
- data/lib/desuraify/engine.rb +4 -2
- data/lib/desuraify/game.rb +4 -4
- data/lib/desuraify/member.rb +28 -4
- data/lib/desuraify/version.rb +1 -1
- data/tests/company/company_spec.rb +87 -0
- data/tests/desuraify_spec.rb +9 -0
- data/tests/engine/engine_spec.rb +139 -0
- data/tests/game/game_spec.rb +202 -0
- data/tests/member/member_spec.rb +74 -0
- metadata +9 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3f974d4084840430812f963f50fb0e0e4beb848
|
4
|
+
data.tar.gz: 02c0d4e2f13e8fb1ad4bfb015713e577845841cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c72d769244e50e74160f1a99ce2126f7b7141e43e5ffbb762b18170fda2cb5803a15fa50e86048c8b03eca3ce5580ac8966bab8723679a897321bc7cdef7eb7
|
7
|
+
data.tar.gz: 7a7f994e7375c074aecaaca69dfe94f529dfe7772f4b5617afe488556eaeba3a232394876baa767d8839180e2687e03aa96f85a4ebbf108e95ee33df5d25a32c
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -14,7 +14,7 @@ And then execute:
|
|
14
14
|
|
15
15
|
Or install it yourself as:
|
16
16
|
|
17
|
-
$ gem install desuraify
|
17
|
+
$ gem install desuraify --pre
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
```
|
@@ -62,21 +62,20 @@ Or install it yourself as:
|
|
62
62
|
=> "illwinter-game-design"
|
63
63
|
```
|
64
64
|
|
65
|
-
\# numerous other attributes are available
|
65
|
+
\# numerous other attributes are available
|
66
66
|
```
|
67
67
|
puts Desuraify::Game::ATTRIBUTES.inspect
|
68
68
|
or
|
69
|
-
puts game.attributes
|
69
|
+
puts game.attributes
|
70
70
|
```
|
71
71
|
|
72
|
-
## TODO
|
72
|
+
## TODO
|
73
73
|
|
74
|
-
1.
|
75
|
-
2. Gather
|
76
|
-
|
77
|
-
4. Gather Company data
|
74
|
+
1. Gather Engine data - June 12, 2015
|
75
|
+
2. Gather Member data - July 21, 2015
|
76
|
+
4. Gather Company data - June 13, 2015
|
78
77
|
5. Documentation...
|
79
|
-
6. Tests
|
78
|
+
6. Tests - July 21, 2015
|
80
79
|
|
81
80
|
## Contributing
|
82
81
|
|
data/lib/desuraify/base.rb
CHANGED
@@ -53,6 +53,8 @@ module Desuraify
|
|
53
53
|
headers.each do |header|
|
54
54
|
next if header.text.strip.empty?
|
55
55
|
|
56
|
+
attribute = header.text.strip.split(" ").join("_").downcase.intern
|
57
|
+
|
56
58
|
case header.text.strip
|
57
59
|
when /^Platforms?$/i
|
58
60
|
|
@@ -71,53 +73,30 @@ module Desuraify
|
|
71
73
|
eng
|
72
74
|
end.uniq
|
73
75
|
|
74
|
-
when
|
75
|
-
|
76
|
-
result[:engine_count] = header.next.next.text.strip.to_i rescue nil
|
76
|
+
when /^Developers?/i, /Publishers?$/i
|
77
77
|
|
78
|
-
|
78
|
+
attribute = header.text.downcase
|
79
|
+
attribute << "s" unless attribute[-1] == "s"
|
79
80
|
|
80
|
-
result[
|
81
|
-
|
82
|
-
end.map do |
|
83
|
-
|
84
|
-
|
85
|
-
href =
|
86
|
-
|
87
|
-
|
88
|
-
|
81
|
+
result[attribute.intern] = header.parent.children.select do |entity|
|
82
|
+
entity unless entity == header || entity.text.strip.empty?
|
83
|
+
end.map do |entity|
|
84
|
+
target = Hash.new
|
85
|
+
target[:name] = entity.text.strip
|
86
|
+
href = entity.child.attribute('href').value.split('/')
|
87
|
+
target[:company] = !!href.find{|company| company.match(/^company$/i)}
|
88
|
+
target[:id] = href.last
|
89
|
+
target
|
89
90
|
end.uniq
|
90
91
|
|
91
|
-
when /
|
92
|
-
|
93
|
-
result[:publishers] = header.parent.children.select do |publisher|
|
94
|
-
publisher unless publisher == header || publisher.text.strip.empty?
|
95
|
-
end.map do |pub|
|
96
|
-
publisher = Hash.new
|
97
|
-
publisher[:name] = pub.text.strip
|
98
|
-
href = pub.child.attribute('href').value.split('/')
|
99
|
-
publisher[:company] = !!href.find{|company| company.match(/^company$/i)}
|
100
|
-
publisher[:id] = href.last
|
101
|
-
publisher
|
102
|
-
end.uniq
|
103
|
-
|
104
|
-
when /Languages?/i
|
105
|
-
|
106
|
-
result[:languages] = header.parent.children.select do |language|
|
107
|
-
language unless language == header || language.text.strip.empty?
|
108
|
-
end.map! {|language| language.text.strip }.uniq
|
92
|
+
when /Languages?/i, /^Genres?/i, /^Themes?$/i, "Players", /^Projects?$/
|
109
93
|
|
110
|
-
|
94
|
+
attribute = header.text.downcase
|
95
|
+
attribute << "s" unless attribute[-1] == "s"
|
111
96
|
|
112
|
-
result[
|
113
|
-
|
114
|
-
end.map {|
|
115
|
-
|
116
|
-
when /^Themes?$/i
|
117
|
-
|
118
|
-
result[:themes] = header.parent.children.select do |theme|
|
119
|
-
theme unless theme == header || theme.text.strip.empty?
|
120
|
-
end.map {|theme| theme.text.strip }.uniq
|
97
|
+
result[attribute.intern] = header.parent.children.select do |entity|
|
98
|
+
entity unless entity == header || entity.text.strip.empty?
|
99
|
+
end.map! {|entity| entity.text.strip }.uniq
|
121
100
|
|
122
101
|
when /^This game is an expansion for\s+?/i
|
123
102
|
|
@@ -128,86 +107,39 @@ module Desuraify
|
|
128
107
|
expansion[:id] = header.parent.search('a').attribute('href').value.split('/').last.strip
|
129
108
|
result[:expansion] = expansion
|
130
109
|
|
131
|
-
when /^Projects?$/
|
132
|
-
|
133
|
-
result[:project] = header.parent.children.select do |project|
|
134
|
-
project unless project == header || project.text.strip.empty?
|
135
|
-
end.map {|project| project.text.strip }.uniq
|
136
|
-
|
137
|
-
when "Players"
|
138
|
-
|
139
|
-
result[:players] = header.parent.children.select do |player|
|
140
|
-
player unless player == header || player.text.strip.empty?
|
141
|
-
end.map{|player| player.text.strip }.uniq
|
142
|
-
|
143
110
|
when "Boxshot"
|
144
111
|
|
145
|
-
result[
|
112
|
+
result[attribute] = header.parent.search('a').attribute('href').value.strip rescue nil
|
146
113
|
|
147
114
|
when "Last Update"
|
148
115
|
|
149
116
|
result[:updated] = header.next.next.text.strip rescue nil
|
150
117
|
|
151
|
-
when "
|
152
|
-
|
153
|
-
result[:license] = header.next.next.text.strip rescue nil
|
154
|
-
|
155
|
-
when "Release Date"
|
156
|
-
|
157
|
-
result[:release_date] = header.next.next.text.strip rescue nil
|
158
|
-
|
159
|
-
when "Watchers"
|
160
|
-
|
161
|
-
result[:watchers] = header.next.next.text.strip rescue nil
|
162
|
-
|
163
|
-
when "Images"
|
118
|
+
when "News", "Members", "Videos", "Games", "Images", "Engines"
|
164
119
|
|
165
|
-
|
120
|
+
attribute = header.text.strip.split(" ").push("count").join("_").downcase.intern
|
121
|
+
result[attribute] = header.next.next.text.strip.to_i rescue nil
|
166
122
|
|
167
|
-
when "Games"
|
168
123
|
|
169
|
-
|
170
|
-
|
171
|
-
when "News"
|
172
|
-
|
173
|
-
result[:news_count] = header.next.next.text.strip.to_i rescue nil
|
174
|
-
|
175
|
-
when "Rank"
|
176
|
-
|
177
|
-
result[:rank] = header.next.next.text.strip rescue nil
|
178
|
-
|
179
|
-
when "Videos"
|
180
|
-
|
181
|
-
result[:video_count] = header.next.next.text.strip.to_i rescue nil
|
182
|
-
|
183
|
-
when "Visits"
|
124
|
+
when "Visits", "Profile Visitors"
|
184
125
|
|
185
126
|
result[:visits] = header.next.next.text.strip rescue nil
|
186
127
|
|
187
|
-
when "Official Page"
|
188
|
-
|
189
|
-
result[:official_page] = header.parent.search('a').attribute('href').value.strip rescue nil
|
190
|
-
|
191
|
-
|
192
|
-
when "Homepage"
|
128
|
+
when "Official Page", "Homepage"
|
193
129
|
|
194
130
|
result[:official_page] = header.parent.search('a').attribute('href').value.strip rescue nil
|
195
131
|
|
196
|
-
when "
|
197
|
-
|
198
|
-
result[:member_count] = header.next.next.text.strip.to_i rescue nil
|
132
|
+
when "Offline Since"
|
199
133
|
|
200
|
-
|
134
|
+
result[:offline] = header.next.next.text.strip rescue nil
|
201
135
|
|
202
|
-
|
136
|
+
when "Activity Points"
|
203
137
|
|
204
|
-
|
138
|
+
result[:activity_points] = header.next.next.text.strip.to_i rescue nil
|
205
139
|
|
206
|
-
|
140
|
+
when "Company", "Office", "Time Online", "Site Visits", /^Gender/, /^Country/, "Established", "Watchers", "Rank", "License", "Release Date", "Phone"
|
207
141
|
|
208
|
-
|
209
|
-
|
210
|
-
result[:office] = header.next.next.text.strip rescue nil
|
142
|
+
result[attribute] = header.next.next.text.strip rescue nil
|
211
143
|
|
212
144
|
when "Address"
|
213
145
|
|
@@ -221,30 +153,35 @@ module Desuraify
|
|
221
153
|
|
222
154
|
result[:address] = addresses.map { |address| address.split("\n") }.flatten
|
223
155
|
|
224
|
-
when "Phone"
|
225
|
-
|
226
|
-
result[:phone] = header.next.next.text.strip rescue nil
|
227
156
|
end
|
228
157
|
|
229
158
|
end
|
230
159
|
|
160
|
+
result[:engines_count] = result[:engines_count] || 0
|
161
|
+
result[:images_count] = result[:images_count] || 0
|
162
|
+
result[:videos_count] = result[:videos_count] || 0
|
163
|
+
result[:games_count] = result[:games_count] || 0
|
164
|
+
result[:news_count] = result[:news_count] || 0
|
165
|
+
|
231
166
|
result
|
232
167
|
end
|
233
168
|
|
234
169
|
def parse_similar(doc, img_count=0, vid_count=0)
|
235
170
|
result = Hash.new
|
236
171
|
|
237
|
-
result[:rating] = doc.at_css('.score').text.strip rescue nil
|
172
|
+
result[:rating] = doc.at_css('.score').text.strip.to_f rescue nil
|
173
|
+
result[:level] = result[:rating]
|
238
174
|
|
239
175
|
result[:videos] = doc.css('.videobox').search('a').map do |video|
|
240
176
|
values = video.attribute('href').value.strip.split('/')
|
241
177
|
values.pop
|
242
178
|
"http://www.desura.com#{values.join('/')}"
|
243
179
|
end rescue nil
|
244
|
-
|
180
|
+
|
181
|
+
result[:videos] = rss_update(video_rss) if result[:videos].size < vid_count rescue nil
|
245
182
|
|
246
183
|
result[:images] = doc.css('.mediaitem').search('a').select{|item| item if item.attribute('href').value.match(/^https?/i) }.map{|pic| pic.attribute('href').value.strip }
|
247
|
-
result[:images] = rss_update(image_rss) if result[:images].size < img_count
|
184
|
+
result[:images] = rss_update(image_rss) if result[:images].size < img_count rescue nil
|
248
185
|
|
249
186
|
result[:summary] = doc.at_css('.body.clear').search('p').map{ |paragraph| paragraph.text.strip }
|
250
187
|
result[:page_title] = doc.css('title').text.strip
|
@@ -290,4 +227,4 @@ module Desuraify
|
|
290
227
|
end
|
291
228
|
|
292
229
|
end
|
293
|
-
end
|
230
|
+
end
|
data/lib/desuraify/company.rb
CHANGED
@@ -2,9 +2,9 @@ module Desuraify
|
|
2
2
|
class Company < Base
|
3
3
|
|
4
4
|
ATTRIBUTES = [
|
5
|
-
:
|
6
|
-
:
|
7
|
-
:
|
5
|
+
:address, :company, :engines_count, :games_count, :html, :images, :images_count,
|
6
|
+
:members, :members_count, :news_count, :office, :official_page, :phone, :rank,
|
7
|
+
:videos, :videos_count, :visits, :watchers
|
8
8
|
]
|
9
9
|
|
10
10
|
attr_reader *ATTRIBUTES
|
data/lib/desuraify/engine.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
module Desuraify
|
2
2
|
class Engine < Base
|
3
3
|
ATTRIBUTES = [
|
4
|
-
:developers, :games, :
|
4
|
+
:developers, :games, :games_count, :html, :images, :images_count, :license, :news,
|
5
5
|
:news_count, :official_page, :page_title, :platforms, :publishers, :rank,
|
6
6
|
:rating, :release_date, :reviews, :summary, :title, :updated, :videos,
|
7
|
-
:
|
7
|
+
:videos_count, :visits, :watchers
|
8
8
|
]
|
9
9
|
|
10
10
|
attr_reader *ATTRIBUTES
|
@@ -21,6 +21,8 @@ module Desuraify
|
|
21
21
|
result.merge!(parse_similar(doc, result[:image_count], result[:video_count]))
|
22
22
|
result[:html] = html
|
23
23
|
|
24
|
+
result[:publishers] = result[:developers].map{ |dev| dev.dup } unless result[:publishers] if result[:developers]
|
25
|
+
|
24
26
|
result
|
25
27
|
|
26
28
|
end
|
data/lib/desuraify/game.rb
CHANGED
@@ -3,10 +3,10 @@ module Desuraify
|
|
3
3
|
class Game < Base
|
4
4
|
ATTRIBUTES = [
|
5
5
|
:boxshot, :developers, :engines, :expansion, :genres, :html,
|
6
|
-
:
|
7
|
-
:original_price, :page_title, :platforms, :players, :price, :
|
6
|
+
:images_count, :images, :languages, :news, :news_count, :official_page,
|
7
|
+
:original_price, :page_title, :platforms, :players, :price, :projects,
|
8
8
|
:publishers, :rank, :rating, :reviews, :summary, :themes, :title,
|
9
|
-
:updated, :
|
9
|
+
:updated, :videos, :videos_count, :visits, :watchers
|
10
10
|
]
|
11
11
|
|
12
12
|
attr_reader *ATTRIBUTES
|
@@ -56,4 +56,4 @@ module Desuraify
|
|
56
56
|
end
|
57
57
|
|
58
58
|
end # end of class
|
59
|
-
end
|
59
|
+
end
|
data/lib/desuraify/member.rb
CHANGED
@@ -2,17 +2,41 @@ module Desuraify
|
|
2
2
|
class Member < Base
|
3
3
|
|
4
4
|
ATTRIBUTES = [
|
5
|
-
|
5
|
+
:activity_points, :comments, :country, :gender, :html, :images, :images_count,
|
6
|
+
:level, :offline, :rank, :site_visits, :time_online, :videos, :videos_count,
|
7
|
+
:visits, :watchers
|
6
8
|
]
|
7
9
|
|
8
|
-
|
10
|
+
attr_reader *ATTRIBUTES
|
11
|
+
|
12
|
+
def initialize(id, options={})
|
9
13
|
super(id, options)
|
10
14
|
end
|
11
15
|
|
16
|
+
def parse(html)
|
17
|
+
doc = Nokogiri::HTML(html)
|
18
|
+
|
19
|
+
result = parse_headers(doc.css('h5'))
|
20
|
+
result.merge!(parse_similar(doc, result[:image_count], result[:video_count]))
|
21
|
+
result[:html] = html
|
22
|
+
|
23
|
+
result
|
24
|
+
end
|
25
|
+
|
12
26
|
def attributes
|
13
27
|
ATTRIBUTES
|
14
28
|
end
|
29
|
+
|
30
|
+
def url
|
31
|
+
"http://www.desura.com/members/#{@id}"
|
32
|
+
end
|
33
|
+
|
34
|
+
def image_rss
|
35
|
+
"http://rss.desura.com/members/#{@id}/images/feed/rss.xml"
|
36
|
+
end
|
37
|
+
|
38
|
+
def video_rss
|
39
|
+
"http://rss.desura.com/members/#{@id}/videos/feed/rss.xml"
|
40
|
+
end
|
15
41
|
end
|
16
42
|
end
|
17
|
-
|
18
|
-
# http://rss.desura.com/games/arbalest-3035/images/feed/rss.xml
|
data/lib/desuraify/version.rb
CHANGED
@@ -0,0 +1,87 @@
|
|
1
|
+
require_relative '../../lib/desuraify'
|
2
|
+
|
3
|
+
RSpec.describe Desuraify::Company do
|
4
|
+
before do
|
5
|
+
@company = Desuraify::Company.new('illwinter-game-design')
|
6
|
+
@company.update
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'company data' do
|
10
|
+
it 'should have an address array' do
|
11
|
+
expect(@company.address.class).to eq(Array)
|
12
|
+
expect(@company.address).not_to eq([])
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should have a company' do
|
16
|
+
expect(@company.company.class).to eq(String)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should have an engines_count' do
|
20
|
+
expect(@company.engines_count.class).to eq(Fixnum)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should have a games_count' do
|
24
|
+
expect(@company.games_count.class).to eq(Fixnum)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should have the html page available' do
|
28
|
+
expect(@company.html.class).to eq(String)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should have an array of images' do
|
32
|
+
expect(@company.images.class).to eq(Array)
|
33
|
+
expect(@company.images).to eq([])
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should have an images_count' do
|
37
|
+
expect(@company.images_count.class).to eq(Fixnum)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should have a members_count' do
|
41
|
+
expect(@company.members_count.class).to eq(Fixnum)
|
42
|
+
end
|
43
|
+
|
44
|
+
# not yet implemented
|
45
|
+
# it 'should have a members array' do
|
46
|
+
# expect(@company.members.class).to eq(Array)
|
47
|
+
# expect(@company.members).not_to eq([])
|
48
|
+
# end
|
49
|
+
|
50
|
+
it 'should have a news_count' do
|
51
|
+
expect(@company.news_count.class).to eq(Fixnum)
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'should have an office' do
|
55
|
+
expect(@company.office.class).to eq(String)
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should have an official_page' do
|
59
|
+
expect(@company.official_page.class).to eq(String)
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should have a phone' do
|
63
|
+
expect(@company.phone.class).to eq(String)
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should have a rank' do
|
67
|
+
expect(@company.rank.class).to eq(String)
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'should have an array of videos' do
|
71
|
+
expect(@company.videos.class).to eq(Array)
|
72
|
+
# expect(@company.videos).not_to eq([])
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'should have a videos_count' do
|
76
|
+
expect(@company.videos_count.class).to eq(Fixnum)
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'should have a visits attribute' do
|
80
|
+
expect(@company.visits.class).to eq(String)
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'should have a watchers attribute' do
|
84
|
+
expect(@company.watchers.class).to eq(String)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,139 @@
|
|
1
|
+
require_relative '../../lib/desuraify'
|
2
|
+
|
3
|
+
RSpec.describe Desuraify::Engine do
|
4
|
+
before do
|
5
|
+
@engine = Desuraify::Engine.new('unity')
|
6
|
+
@engine.update
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'engine data' do
|
10
|
+
describe "developers" do
|
11
|
+
it 'should have an array of developer hashes' do
|
12
|
+
expect(@engine.developers.class).to eq(Array)
|
13
|
+
expect(@engine.developers).not_to eq([])
|
14
|
+
expect(@engine.developers.first.class).to eq(Hash)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should have attributes in the developer hash' do
|
18
|
+
expect(@engine.developers.first[:name].class).to eq(String)
|
19
|
+
expect([TrueClass, FalseClass].include?(@engine.developers.first[:company].class)).to eq(true)
|
20
|
+
expect(@engine.developers.first[:id].class).to eq(String)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# not yet implemented
|
25
|
+
# it 'should have an array of games' do
|
26
|
+
# expect(@engine.games.class).to eq(Array)
|
27
|
+
# expect(@engine.games).not_to eq([])
|
28
|
+
# end
|
29
|
+
|
30
|
+
it 'should have a games_count attribute' do
|
31
|
+
expect(@engine.games_count.class).to eq(Fixnum)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should have the html page available' do
|
35
|
+
expect(@engine.html).not_to eq(nil)
|
36
|
+
expect(@engine.html.class).to eq(String)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should have an array of images' do
|
40
|
+
expect(@engine.images.class).to eq(Array)
|
41
|
+
expect(@engine.images).to eq([])
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should have an image_count' do
|
45
|
+
expect(@engine.images_count.class).to eq(Fixnum)
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'has a license attribute' do
|
49
|
+
expect(@engine.license.class).to eq(String)
|
50
|
+
end
|
51
|
+
|
52
|
+
# not yet implemented
|
53
|
+
# it 'has an array of news' do
|
54
|
+
# expect(@engine.news.class).to eq(Array)
|
55
|
+
# expect(@engine.news).not_to eq([])
|
56
|
+
# end
|
57
|
+
|
58
|
+
it 'should have a news_count' do
|
59
|
+
expect(@engine.news_count.class).to eq(Fixnum)
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should have an official_page' do
|
63
|
+
expect(@engine.official_page.class).to eq(String)
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should have a page_title' do
|
67
|
+
expect(@engine.page_title.class).to eq(String)
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'should have an array of platforms' do
|
71
|
+
expect(@engine.platforms.class).to eq(Array)
|
72
|
+
expect(@engine.platforms).not_to eq([])
|
73
|
+
end
|
74
|
+
|
75
|
+
describe "publishers" do
|
76
|
+
it 'should have an array of publisher hashes' do
|
77
|
+
expect(@engine.publishers.class).to eq(Array)
|
78
|
+
expect(@engine.publishers).not_to eq([])
|
79
|
+
expect(@engine.publishers.first.class).to eq(Hash)
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'should have attributes in the publisher hash' do
|
83
|
+
expect(@engine.publishers.first[:name].class).to eq(String)
|
84
|
+
expect([TrueClass, FalseClass].include?(@engine.publishers.first[:company].class)).to eq(true)
|
85
|
+
expect(@engine.publishers.first[:id].class).to eq(String)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'should have a rank attribute' do
|
90
|
+
expect(@engine.rank.class).to eq(String)
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'should have a rating attribute' do
|
94
|
+
expect(@engine.rating.class).to eq(Float)
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'should have a release_date attribute' do
|
98
|
+
expect(@engine.release_date.class).to eq(String)
|
99
|
+
end
|
100
|
+
|
101
|
+
describe 'summary' do
|
102
|
+
it 'should be an array' do
|
103
|
+
expect(@engine.summary.class).to eq(Array)
|
104
|
+
expect(@engine.summary).not_to eq([])
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'should be an array of strings' do
|
108
|
+
@engine.summary.each do |sentence|
|
109
|
+
expect(sentence.class).to eq(String)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should have a title attribute" do
|
115
|
+
expect(@engine.title.class).to eq(String)
|
116
|
+
end
|
117
|
+
|
118
|
+
it 'should have an updated attribute' do
|
119
|
+
expect(@engine.updated.class).to eq(String)
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'should have an array of videos' do
|
123
|
+
expect(@engine.videos.class).to eq(Array)
|
124
|
+
# expect(@engine.videos).not_to eq([])
|
125
|
+
end
|
126
|
+
|
127
|
+
it 'should have a videos_count' do
|
128
|
+
expect(@engine.videos_count.class).to eq(Fixnum)
|
129
|
+
end
|
130
|
+
|
131
|
+
it 'should have a visits attribute' do
|
132
|
+
expect(@engine.visits.class).to eq(String)
|
133
|
+
end
|
134
|
+
|
135
|
+
it 'should have a watchers attribute' do
|
136
|
+
expect(@engine.watchers.class).to eq(String)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
@@ -0,0 +1,202 @@
|
|
1
|
+
require_relative '../../lib/desuraify'
|
2
|
+
|
3
|
+
RSpec.describe Desuraify::Game do
|
4
|
+
before do
|
5
|
+
@game = Desuraify::Game.new("dominions-4-thrones-of-ascensions")
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "initialization" do
|
9
|
+
it 'has an ancestor chain that includes Desuraify::Base' do
|
10
|
+
expect(@game.class.ancestors.include?(Desuraify::Base)).to eq(true)
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should be an instance of Desuraify::Game' do
|
14
|
+
expect(@game.instance_of?(Desuraify::Game)).to eq(true)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should have a Typhoeus::Hydra instance available' do
|
18
|
+
expect(@game.hydra.class).to eq(Typhoeus::Hydra)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should have an id' do
|
22
|
+
expect(@game.id).to eq("dominions-4-thrones-of-ascensions")
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should have an attributes array of methods that are nil' do
|
26
|
+
@game.attributes.each do |attribute|
|
27
|
+
expect(@game.send(attribute)).to eq(nil)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "game data" do
|
33
|
+
before do
|
34
|
+
@game.update
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should have a title" do
|
38
|
+
expect(@game.title.class).to eq(String)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should have a page_title' do
|
42
|
+
expect(@game.page_title.class).to eq(String)
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should have an official_page' do
|
46
|
+
expect(@game.official_page.class).to eq(String)
|
47
|
+
end
|
48
|
+
|
49
|
+
# this may change if the developer adds game videos
|
50
|
+
it 'should have an array of videos' do
|
51
|
+
expect(@game.videos.class).to eq(Array)
|
52
|
+
expect(@game.videos).to eq([])
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should have an array of images' do
|
56
|
+
expect(@game.images.class).to eq(Array)
|
57
|
+
expect(@game.images).not_to eq([])
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "developers" do
|
61
|
+
it 'should have an array of developer hashes' do
|
62
|
+
expect(@game.developers.class).to eq(Array)
|
63
|
+
expect(@game.developers).not_to eq([])
|
64
|
+
expect(@game.developers.first.class).to eq(Hash)
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'should have attributes in the developer hash' do
|
68
|
+
expect(@game.developers.first[:name].class).to eq(String)
|
69
|
+
expect([TrueClass, FalseClass].include?(@game.developers.first[:company].class)).to eq(true)
|
70
|
+
expect(@game.developers.first[:id].class).to eq(String)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "publishers" do
|
75
|
+
it 'should have an array of publisher hashes' do
|
76
|
+
expect(@game.publishers.class).to eq(Array)
|
77
|
+
expect(@game.publishers).not_to eq([])
|
78
|
+
expect(@game.publishers.first.class).to eq(Hash)
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'should have attributes in the publisher hash' do
|
82
|
+
expect(@game.publishers.first[:name].class).to eq(String)
|
83
|
+
expect([TrueClass, FalseClass].include?(@game.publishers.first[:company].class)).to eq(true)
|
84
|
+
expect(@game.publishers.first[:id].class).to eq(String)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe 'engines' do
|
89
|
+
it 'should have an array of engine hashes' do
|
90
|
+
expect(@game.publishers.class).to eq(Array)
|
91
|
+
expect(@game.publishers).not_to eq([])
|
92
|
+
expect(@game.publishers.first.class).to eq(Hash)
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'should have attributes in the engine hash' do
|
96
|
+
expect(@game.engines.first[:name].class).to eq(String)
|
97
|
+
expect(@game.engines.first[:id].class).to eq(String)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe 'platforms' do
|
102
|
+
it 'should have an array of platforms' do
|
103
|
+
expect(@game.platforms.class).to eq(Array)
|
104
|
+
expect(@game.platforms).not_to eq([])
|
105
|
+
end
|
106
|
+
|
107
|
+
# it is my understanding that desura does not support platforms other that those listed
|
108
|
+
it 'should be included in ["Windows", "Mac", "Linux"]' do
|
109
|
+
platforms = ["Windows", "Mac", "Linux"]
|
110
|
+
|
111
|
+
@game.platforms.each do |platform|
|
112
|
+
expect(platforms.include?(platform)).to eq(true)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'should have an array of player modes' do
|
118
|
+
expect(@game.players.class).to eq(Array)
|
119
|
+
expect(@game.players).not_to eq([])
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'should have an array of game classifications (projects)' do
|
123
|
+
expect(@game.projects.class).to eq(Array)
|
124
|
+
expect(@game.projects).not_to eq([])
|
125
|
+
end
|
126
|
+
|
127
|
+
it 'should have an array of themes' do
|
128
|
+
expect(@game.themes.class).to eq(Array)
|
129
|
+
expect(@game.themes).not_to eq([])
|
130
|
+
end
|
131
|
+
|
132
|
+
it 'should have a rank' do
|
133
|
+
expect(@game.rank.class).to eq(String)
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'should have a rating' do
|
137
|
+
expect(@game.rating.class).to eq(Float)
|
138
|
+
end
|
139
|
+
|
140
|
+
describe 'summary' do
|
141
|
+
it 'should be an array' do
|
142
|
+
expect(@game.summary.class).to eq(Array)
|
143
|
+
expect(@game.summary).not_to eq([])
|
144
|
+
end
|
145
|
+
|
146
|
+
it 'should be an array of strings' do
|
147
|
+
@game.summary.each do |sentence|
|
148
|
+
expect(sentence.class).to eq(String)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
it 'should have a boxshot image extension of jpg' do
|
154
|
+
ext = @game.boxshot.split("/").last.split(".").last
|
155
|
+
expect(ext).to eq("jpg")
|
156
|
+
end
|
157
|
+
|
158
|
+
it 'should have an updated attribute' do
|
159
|
+
expect(@game.updated.class).to eq(String)
|
160
|
+
end
|
161
|
+
|
162
|
+
it 'should have an images_count' do
|
163
|
+
expect(@game.images_count.class).to eq(Fixnum)
|
164
|
+
end
|
165
|
+
|
166
|
+
it 'should have a videos_count' do
|
167
|
+
expect(@game.videos_count.class).to eq(Fixnum)
|
168
|
+
end
|
169
|
+
|
170
|
+
it 'should have a news_count' do
|
171
|
+
expect(@game.news_count.class).to eq(Fixnum)
|
172
|
+
end
|
173
|
+
|
174
|
+
it 'should have an array of genres' do
|
175
|
+
expect(@game.genres.class).to eq(Array)
|
176
|
+
expect(@game.genres).not_to eq([])
|
177
|
+
end
|
178
|
+
|
179
|
+
it 'should have the html page available' do
|
180
|
+
expect(@game.html).not_to eq(nil)
|
181
|
+
expect(@game.html.class).to eq(String)
|
182
|
+
end
|
183
|
+
|
184
|
+
it 'should have a visits attribute' do
|
185
|
+
expect(@game.visits.class).to eq(String)
|
186
|
+
end
|
187
|
+
|
188
|
+
it 'should have a watchers attribute' do
|
189
|
+
expect(@game.watchers.class).to eq(String)
|
190
|
+
end
|
191
|
+
|
192
|
+
#langauges not yet implemented by desura, we'll be ready when they do
|
193
|
+
it 'should have languages equal to nil' do
|
194
|
+
expect(@game.languages).to eq(nil)
|
195
|
+
end
|
196
|
+
|
197
|
+
describe /\$\d+.\d+/ do
|
198
|
+
it { should match(@game.price) }
|
199
|
+
it { should match(@game.original_price) }
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require_relative '../../lib/desuraify'
|
2
|
+
|
3
|
+
RSpec.describe Desuraify::Member do
|
4
|
+
before do
|
5
|
+
@member = Desuraify::Member.new('animdude')
|
6
|
+
@member.update
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'member data' do
|
10
|
+
|
11
|
+
it 'should have an activity_points attribute' do
|
12
|
+
expect(@member.activity_points.class).to eq(Fixnum)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should have a country attribute' do
|
16
|
+
expect(@member.country.class).to eq(String)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should have a gender attribute' do
|
20
|
+
expect(@member.gender.class).to eq(String)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should have the html page available' do
|
24
|
+
expect(@member.html).not_to eq(nil)
|
25
|
+
expect(@member.html.class).to eq(String)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should have an array of images' do
|
29
|
+
expect(@member.images.class).to eq(Array)
|
30
|
+
expect(@member.images).to eq([])
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should have an image_count' do
|
34
|
+
expect(@member.images_count.class).to eq(Fixnum)
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should have a level attribute' do
|
38
|
+
expect(@member.level.class).to eq(Float)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should have an offline attribute' do
|
42
|
+
expect(@member.offline.class).to eq(String)
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should have a rank attribute' do
|
46
|
+
expect(@member.rank.class).to eq(String)
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'should have a site_visits attribute' do
|
50
|
+
expect(@member.site_visits.class).to eq(String)
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should have a time_online attribute' do
|
54
|
+
expect(@member.time_online.class).to eq(String)
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should have an array of videos' do
|
58
|
+
expect(@member.videos.class).to eq(Array)
|
59
|
+
expect(@member.videos).to eq([])
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should have a videos_count' do
|
63
|
+
expect(@member.videos_count.class).to eq(Fixnum)
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should have a visits attribute' do
|
67
|
+
expect(@member.visits.class).to eq(String)
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'should have a watchers attribute' do
|
71
|
+
expect(@member.watchers.class).to eq(String)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: desuraify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jfrazx
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -87,6 +87,11 @@ files:
|
|
87
87
|
- lib/desuraify/game.rb
|
88
88
|
- lib/desuraify/member.rb
|
89
89
|
- lib/desuraify/version.rb
|
90
|
+
- tests/company/company_spec.rb
|
91
|
+
- tests/desuraify_spec.rb
|
92
|
+
- tests/engine/engine_spec.rb
|
93
|
+
- tests/game/game_spec.rb
|
94
|
+
- tests/member/member_spec.rb
|
90
95
|
homepage: https://github.com/jfrazx/desuraify
|
91
96
|
licenses:
|
92
97
|
- MIT
|
@@ -102,9 +107,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
102
107
|
version: '0'
|
103
108
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
109
|
requirements:
|
105
|
-
- - "
|
110
|
+
- - ">="
|
106
111
|
- !ruby/object:Gem::Version
|
107
|
-
version:
|
112
|
+
version: '0'
|
108
113
|
requirements: []
|
109
114
|
rubyforge_project:
|
110
115
|
rubygems_version: 2.2.2
|