playlyfe_client 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +6 -2
- data/lib/playlyfe_client/v2/leaderboard/players_leaderboard.rb +8 -5
- data/lib/playlyfe_client/v2/leaderboard/teams_leaderboard.rb +9 -6
- data/lib/playlyfe_client/v2/leaderboard.rb +15 -4
- data/lib/playlyfe_client/version.rb +1 -1
- data/playlyfe_client.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 193418f3fbbd9cb946f415e2c90e8277a134153e
|
4
|
+
data.tar.gz: 4774b952eca4d59831f33755454f5512f2cd7ff9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33b415033499ea4b757a90e4942e8c6e3dffa613e9c615b5ef7bc93cda7916d9902c937538d5ae16650b24e535739fc95be9236fd90b97b1724300a87ae11159
|
7
|
+
data.tar.gz: c7299c3e9c1c1a61c82fb873b9d4b87b0da568b435b4e9a4858492375f1be4aff0177fd0caec357918d1f73ff25ee8616f53ee81bb0c71f01b0538115fd6fccc
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
playlyfe_client (1.0.
|
4
|
+
playlyfe_client (1.0.6)
|
5
5
|
json
|
6
6
|
jwt
|
7
7
|
rest-client
|
@@ -11,6 +11,7 @@ GEM
|
|
11
11
|
specs:
|
12
12
|
ansi (1.5.0)
|
13
13
|
builder (3.2.2)
|
14
|
+
byebug (9.0.5)
|
14
15
|
coderay (1.1.1)
|
15
16
|
domain_name (0.5.20160310)
|
16
17
|
unf (>= 0.0.5, < 1.0.0)
|
@@ -31,6 +32,9 @@ GEM
|
|
31
32
|
coderay (~> 1.1.0)
|
32
33
|
method_source (~> 0.8.1)
|
33
34
|
slop (~> 3.4)
|
35
|
+
pry-byebug (3.4.0)
|
36
|
+
byebug (~> 9.0)
|
37
|
+
pry (~> 0.10)
|
34
38
|
rake (10.5.0)
|
35
39
|
rest-client (1.8.0)
|
36
40
|
http-cookie (>= 1.0.2, < 2.0)
|
@@ -52,7 +56,7 @@ DEPENDENCIES
|
|
52
56
|
minitest
|
53
57
|
minitest-reporters
|
54
58
|
playlyfe_client!
|
55
|
-
pry
|
59
|
+
pry-byebug
|
56
60
|
rake (~> 10.0)
|
57
61
|
rest-client
|
58
62
|
|
@@ -7,9 +7,12 @@ module PlaylyfeClient
|
|
7
7
|
private
|
8
8
|
|
9
9
|
def fill_positions(data)
|
10
|
+
#preproces data into new_data
|
11
|
+
new_data=[]
|
12
|
+
|
10
13
|
data.each do |pos|
|
11
|
-
rank=(pos[:rank] || pos["rank"]).to_i
|
12
|
-
score=pos[:score] || pos["score"]
|
14
|
+
rank=(pos[:rank] || pos["rank"]).to_i
|
15
|
+
score=pos[:score] || pos["score"]
|
13
16
|
entity= pos[:player] || pos["player"]
|
14
17
|
|
15
18
|
player=game.players.find(entity[:id] || entity["id"])
|
@@ -19,10 +22,10 @@ module PlaylyfeClient
|
|
19
22
|
fail PlaylyfeClient::LeaderboardError.new("{\"error\": \"Player not found\", \"error_description\": \"Player '#{entity[:id] || entity["id"]}' from '#{self.name}'[#{self.id}] leaderboard was not found between game.players!\"}")
|
20
23
|
end
|
21
24
|
|
22
|
-
|
25
|
+
new_data << {rank: rank, entity: player, score: score}
|
23
26
|
end
|
24
|
-
|
25
|
-
|
27
|
+
|
28
|
+
super(new_data)
|
26
29
|
end
|
27
30
|
|
28
31
|
end
|
@@ -7,9 +7,12 @@ module PlaylyfeClient
|
|
7
7
|
private
|
8
8
|
|
9
9
|
def fill_positions(data)
|
10
|
+
#preproces data into new_data
|
11
|
+
new_data=[]
|
12
|
+
|
10
13
|
data.each do |pos|
|
11
|
-
rank=(pos[:rank] || pos["rank"]).to_i
|
12
|
-
score=pos[:score] || pos["score"]
|
14
|
+
rank=(pos[:rank] || pos["rank"]).to_i
|
15
|
+
score=pos[:score] || pos["score"]
|
13
16
|
entity= pos[:team] || pos["team"]
|
14
17
|
|
15
18
|
team=game.teams.find(entity[:id] || entity["id"])
|
@@ -18,11 +21,11 @@ module PlaylyfeClient
|
|
18
21
|
if team.nil?
|
19
22
|
fail PlaylyfeClient::LeaderboardError.new("{\"error\": \"Team not found\", \"error_description\": \"Team '#{entity[:id] || entity["id"]}' from '#{self.name}'[#{self.id}] leaderboard was not found between game.teams!\"}")
|
20
23
|
end
|
21
|
-
|
22
|
-
|
24
|
+
|
25
|
+
new_data << {rank: rank, entity: team, score: score}
|
23
26
|
end
|
24
|
-
|
25
|
-
|
27
|
+
|
28
|
+
super(new_data)
|
26
29
|
end
|
27
30
|
|
28
31
|
end
|
@@ -21,15 +21,26 @@ module PlaylyfeClient
|
|
21
21
|
fill_positions(lbd_hash[:data] || lbd_hash["data"] || [])
|
22
22
|
end
|
23
23
|
|
24
|
+
#positions[x] is array of entities
|
25
|
+
#If there are 3 entities at rank 4, there will be array with 3 items at positions[3]
|
26
|
+
#Positions[4] and positions[5] will be []
|
27
|
+
#Playlyfe have this style of ranking too ( #1, #2, #3, #4, #4, #4, #7)
|
24
28
|
def fill_positions(data)
|
25
29
|
data.each do |pos|
|
26
|
-
rank=(pos[:rank]
|
27
|
-
score=pos[:score] ||
|
28
|
-
entity= pos[:
|
30
|
+
rank=(pos[:rank]).to_i - 1
|
31
|
+
score=pos[:score] || 0
|
32
|
+
entity= pos[:entity] || nil
|
29
33
|
|
30
|
-
@positions[rank]
|
34
|
+
if @positions[rank].nil?
|
35
|
+
@positions[rank] = [{entity: entity, score: score}]
|
36
|
+
else
|
37
|
+
@positions[rank] << {entity: entity, score: score}
|
38
|
+
end
|
31
39
|
end
|
32
40
|
|
41
|
+
#fill empty positions with []
|
42
|
+
@positions.each_with_index {|p,i| @positions[i]=[] if p.nil? }
|
43
|
+
|
33
44
|
@positions
|
34
45
|
end
|
35
46
|
|
data/playlyfe_client.gemspec
CHANGED
@@ -26,5 +26,5 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.add_development_dependency "rake", "~> 10.0"
|
27
27
|
spec.add_development_dependency "minitest"
|
28
28
|
spec.add_development_dependency "minitest-reporters"
|
29
|
-
spec.add_development_dependency "pry"
|
29
|
+
spec.add_development_dependency "pry-byebug"
|
30
30
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: playlyfe_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Foton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -109,7 +109,7 @@ dependencies:
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name: pry
|
112
|
+
name: pry-byebug
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - ">="
|