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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c39c3f1a05df0c48ee724f71bcc0ef936683e2ba
4
- data.tar.gz: 17d05f9ef45235c529b60b972cee14c7159332f7
3
+ metadata.gz: 193418f3fbbd9cb946f415e2c90e8277a134153e
4
+ data.tar.gz: 4774b952eca4d59831f33755454f5512f2cd7ff9
5
5
  SHA512:
6
- metadata.gz: b00108f9dc0f7b83a23920d08d49124bfb72198df8d3fa9fae8b669b91d566788a142f6ed116d40a6d3dc26ea371536a8b2006a85b7a30b70044694664f675ee
7
- data.tar.gz: 0736aed8a69327c11731d8120b1ac23a7d00adb3c66f3a859a5b01219fa906f83e5ce87a1f502b2bf0d71243b6ed63c9df03f06e6ca974f9c8147c907886aac4
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.5)
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 - 1
12
- score=pos[:score] || pos["score"] || 0
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
- @positions[rank] = {entity: player, score: score}
25
+ new_data << {rank: rank, entity: player, score: score}
23
26
  end
24
-
25
- @positions
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 - 1
12
- score=pos[:score] || pos["score"] || 0
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
- @positions[rank] = {entity: team, score: score}
24
+
25
+ new_data << {rank: rank, entity: team, score: score}
23
26
  end
24
-
25
- @positions
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] || pos["rank"]).to_i - 1
27
- score=pos[:score] || pos["score"] || 0
28
- entity= pos[:player] || pos["player"] || pos[:team] || pos["team"] || nil
30
+ rank=(pos[:rank]).to_i - 1
31
+ score=pos[:score] || 0
32
+ entity= pos[:entity] || nil
29
33
 
30
- @positions[rank] = {entity: entity, score: score}
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
 
@@ -1,3 +1,3 @@
1
1
  module PlaylyfeClient
2
- VERSION = "1.0.5"
2
+ VERSION = "1.0.6"
3
3
  end
@@ -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.5
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-10 00:00:00.000000000 Z
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
  - - ">="