gameworks 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +7 -7
- data/build.sh +8 -0
- data/lib/gameworks/game.rb +8 -1
- data/lib/gameworks/notifier.rb +45 -0
- data/lib/gameworks/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df917ca798961d763e0a0767a16e65754d6d6153
|
4
|
+
data.tar.gz: 4a5afc01de838e342c9fee794ba576741ee3002a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82b73405e851e4e98a1758a2b42e2baf122243c8b93b611f7c57579bf0f3d75d5e558cc2b16e6250670ec6e2c7749768420e4d5046ed13cbaec32d257ca2b645
|
7
|
+
data.tar.gz: 45115aec3dd59ea486da297686beaede76c34c3b08020605df97022dabe379d3b9c17ab3e1c0893580465f517ec9653f23f9d056efbcfb80a3d53f41bebb64d7
|
data/Gemfile.lock
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
gameworks (1.0.
|
5
|
-
eventmachine (~> 1.0.7)
|
6
|
-
json (~> 1.8.3)
|
4
|
+
gameworks (1.0.1)
|
5
|
+
eventmachine (~> 1.0, >= 1.0.7)
|
6
|
+
json (~> 1.8, >= 1.8.3)
|
7
7
|
rake (~> 10.0)
|
8
|
-
thin (~> 1.6.3)
|
8
|
+
thin (~> 1.6, >= 1.6.3)
|
9
9
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
@@ -43,8 +43,8 @@ PLATFORMS
|
|
43
43
|
DEPENDENCIES
|
44
44
|
bundler (~> 1.8)
|
45
45
|
gameworks!
|
46
|
-
rspec (~> 3.3.0)
|
47
|
-
rspec-eventmachine (~> 0.2
|
46
|
+
rspec (~> 3.3, >= 3.3.0)
|
47
|
+
rspec-eventmachine (~> 0.2)
|
48
48
|
|
49
49
|
BUNDLED WITH
|
50
|
-
1.10.
|
50
|
+
1.10.5
|
data/build.sh
ADDED
data/lib/gameworks/game.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require_relative 'player'
|
2
|
+
require_relative 'notifier'
|
2
3
|
require_relative 'game_snapshot'
|
3
4
|
require_relative 'fuse'
|
4
5
|
|
@@ -11,9 +12,10 @@ module Gameworks
|
|
11
12
|
STATE_IN_PLAY = 'in play'
|
12
13
|
STATE_COMPLETED = 'completed'
|
13
14
|
|
14
|
-
attr_reader :players, :state, :id, :delay_time
|
15
|
+
attr_reader :players, :state, :id, :delay_time, :notifier
|
15
16
|
|
16
17
|
def initialize(payload={})
|
18
|
+
@notifier = Notifier.new
|
17
19
|
@players = []
|
18
20
|
@state = STATE_INITIATING
|
19
21
|
@delay_time = payload['delay_time'] || DEFAULT_DELAY
|
@@ -35,6 +37,7 @@ module Gameworks
|
|
35
37
|
cb.call(delta(snapshot).to_json)
|
36
38
|
cb.succeed if end_game
|
37
39
|
end
|
40
|
+
notifier.push(self, delta(initial_snapshot).to_json)
|
38
41
|
end
|
39
42
|
|
40
43
|
def snapshot_for_observer(token)
|
@@ -46,6 +49,10 @@ module Gameworks
|
|
46
49
|
snapshot
|
47
50
|
end
|
48
51
|
|
52
|
+
def initial_snapshot
|
53
|
+
@initial_snapshot ||= snapshot
|
54
|
+
end
|
55
|
+
|
49
56
|
def player_changed?(player, snapshot, for_player=nil)
|
50
57
|
player.score != snapshot.player_scores[player]
|
51
58
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require "net/http"
|
2
|
+
|
3
|
+
module Gameworks
|
4
|
+
class Notifier
|
5
|
+
def configured?
|
6
|
+
![app_id, key, secret, base_url].any?(&:nil?)
|
7
|
+
end
|
8
|
+
|
9
|
+
def push(game, body)
|
10
|
+
return unless configured?
|
11
|
+
|
12
|
+
uri = URI(build_url(game))
|
13
|
+
req = Net::HTTP::Post.new(uri)
|
14
|
+
|
15
|
+
req.basic_auth(key, secret)
|
16
|
+
req.body = body
|
17
|
+
req["Content-Type"] = "application/json"
|
18
|
+
Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
|
19
|
+
http.request(req)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def build_url(game)
|
26
|
+
"%s/channel/%s/public/games/%s" % [base_url, app_id, game.id]
|
27
|
+
end
|
28
|
+
|
29
|
+
def app_id
|
30
|
+
@app_id ||= ENV["PANDA_PUSH_APP_ID"]
|
31
|
+
end
|
32
|
+
|
33
|
+
def key
|
34
|
+
@key ||= ENV["PANDA_PUSH_KEY"]
|
35
|
+
end
|
36
|
+
|
37
|
+
def secret
|
38
|
+
@secret ||= ENV["PANDA_PUSH_SECRET"]
|
39
|
+
end
|
40
|
+
|
41
|
+
def base_url
|
42
|
+
@base_url ||= ENV["PANDA_PUSH_URL"]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/gameworks/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gameworks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Palmer
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2015-07-
|
15
|
+
date: 2015-07-09 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rake
|
@@ -154,12 +154,14 @@ files:
|
|
154
154
|
- Rakefile
|
155
155
|
- bin/console
|
156
156
|
- bin/setup
|
157
|
+
- build.sh
|
157
158
|
- gameworks.gemspec
|
158
159
|
- lib/gameworks.rb
|
159
160
|
- lib/gameworks/fuse.rb
|
160
161
|
- lib/gameworks/game.rb
|
161
162
|
- lib/gameworks/game_registry.rb
|
162
163
|
- lib/gameworks/game_snapshot.rb
|
164
|
+
- lib/gameworks/notifier.rb
|
163
165
|
- lib/gameworks/player.rb
|
164
166
|
- lib/gameworks/server.rb
|
165
167
|
- lib/gameworks/servlet/add_move.rb
|