libgss 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/Gemfile.lock +2 -2
- data/README.md +28 -10
- data/README_ja.md +57 -0
- data/lib/libgss/action_request.rb +6 -0
- data/lib/libgss/network.rb +6 -0
- data/lib/libgss/outputs.rb +2 -2
- data/lib/libgss/version.rb +1 -1
- data/spec/libgss/action_request_spec.rb +8 -0
- data/spec/libgss/network_spec.rb +10 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Y2Y0OGU1MjZkZDE4ZDA2YmYzM2Q5YzNhNjMzYjczZTQwOThmODFiMg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NDMwZmZiNTY5OGE3MTk2ZWMzZDRmN2IzNjgzMjkyYjdhNDY2YjBkNw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZDQ0NWUxMTNmZTVjZjg2MTJiNGMwZGUyYmI2NDM3NjI1YzJhODRlMjZlNTc4
|
10
|
+
MDE3ODg4MTA0MjZhMGQwZTY4ZmI3NTdlNDYzY2MxZjI1Y2NjN2FkMzU5MDFj
|
11
|
+
N2FiOWEwNGIxYjY5OTViYWQ4NGRlZDg4OTdkNWIzY2ZiMDExZjA=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
Y2JkMDE0NTljMmNlOGY5M2UwMTFlODY0NTkwNjUxZTVkMGNjNDQxZjkzNGNl
|
14
|
+
ZGM0Mzc3ZDNiNzgyM2ZjMGU5MGNiZGVjYjUwZTljMzU0YzIyMjcwNTZkNzMw
|
15
|
+
MDAwZDdjMmQyMTUxZjUzMzFlNTRhZTVjNDQ2MGI0ODA0OTZkZjk=
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
libgss (0.0.
|
4
|
+
libgss (0.0.2)
|
5
5
|
httpclient
|
6
6
|
json
|
7
7
|
|
@@ -10,7 +10,7 @@ GEM
|
|
10
10
|
specs:
|
11
11
|
diff-lcs (1.2.3)
|
12
12
|
httpclient (2.3.3)
|
13
|
-
json (1.
|
13
|
+
json (1.8.0)
|
14
14
|
rake (10.0.4)
|
15
15
|
rspec (2.13.0)
|
16
16
|
rspec-core (~> 2.13.0)
|
data/README.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# Libgss
|
2
2
|
|
3
|
-
|
3
|
+
Network library for Groovenauts GSS.
|
4
|
+
|
5
|
+
Usually game developers use other network libraries built in each environment,
|
6
|
+
but can use this network library in oder to write test script about Stored Script
|
7
|
+
which is server side script in GSS.
|
4
8
|
|
5
9
|
## Installation
|
6
10
|
|
@@ -18,12 +22,26 @@ Or install it yourself as:
|
|
18
22
|
|
19
23
|
## Usage
|
20
24
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
25
|
+
$ irb -r libgss
|
26
|
+
|
27
|
+
>> network = Libgss::Network.new("http://localhost:3000", ssl_disabled: true)
|
28
|
+
=> #<Libgss::Network:2152782140 @ssl_disabled=true, @base_url="http://localhost:3000", @ssl_base_url="http://localhost:3000", @platform="fontana">
|
29
|
+
>> network.player_id = "1000001"
|
30
|
+
=> "1000001"
|
31
|
+
>> network.login
|
32
|
+
=> true
|
33
|
+
>>
|
34
|
+
?> req1 = network.new_action_request
|
35
|
+
=> #<Libgss::ActionRequest:2152568320 @action_url="http://localhost:3000/api/1.0.0/actions.json?auth_token=259rKDuSb3CT1UxbywAf", @status=0, @actions=[], @action_id=0>
|
36
|
+
>> req1.execute("ItemRubyStoredScript", "use_item", {"item_cd" => "20001"})
|
37
|
+
=> #<Libgss::Action:0x0000010092f7b0 @id=1, @args={:action=>"execute", :name=>"ItemRubyStoredScript", :key=>"use_item", :args=>{"item_cd"=>"20001"}}>
|
38
|
+
>> req1.get_by_game_data
|
39
|
+
=> #<Libgss::Action:0x000001008f9188 @id=2, @args={:action=>"get", :name=>"GameData"}>
|
40
|
+
>> req1.send_request
|
41
|
+
=> nil
|
42
|
+
>>
|
43
|
+
?> req1.outputs
|
44
|
+
=> [{"result"=>"You don't have enough item", "id"=>1}, {"result"=>{"content"=>{"hp"=>15, "max_hp"=>15, "mp"=>5, "max_mp"=>5, "exp"=>100, "money"=>200, "items"=>{"20001"=>0, "20005"=>1}, "equipments"=>{"head"=>10018, "body"=>10012, "right_hand"=>10001, "left_hand"=>nil}}, "greeting_points"=>0, "login_bonus"=>[[10001, 1]], "invitation_code"=>nil, "invite_player"=>nil, "read_notifications"=>[]}, "id"=>2}]
|
45
|
+
>>
|
46
|
+
?> req1.outputs.get(1)
|
47
|
+
=> {"result"=>"You don't have enough item", "id"=>1}
|
data/README_ja.md
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# libgss-ruby
|
2
|
+
|
3
|
+
libgss-rubyはGroovenautsのGSS用通信ライブラリです。
|
4
|
+
|
5
|
+
通常、GSSと通信するためには、直接HTTPのAPIをコールするか、それぞれの環境に合わせた
|
6
|
+
通信ライブラリを用いる必要があります。
|
7
|
+
|
8
|
+
しかしこのlibgss-rubyとRSpecやminitestなどを組み合わせることによって、GSSにおける
|
9
|
+
サーバーサイドスクリプトであるストアドスクリプトのユニットテストを記述することが
|
10
|
+
できます。
|
11
|
+
|
12
|
+
## インストール方法
|
13
|
+
|
14
|
+
### bundlerを使う方法
|
15
|
+
|
16
|
+
アプリケーションのGemfileに以下の行を追加します:
|
17
|
+
|
18
|
+
gem 'libgss'
|
19
|
+
|
20
|
+
以下の行を実行します:
|
21
|
+
|
22
|
+
$ bundle
|
23
|
+
|
24
|
+
|
25
|
+
### 手動でインストールする方法
|
26
|
+
|
27
|
+
手動で以下のコマンドを実行してインストールできます:
|
28
|
+
|
29
|
+
$ gem install libgss
|
30
|
+
|
31
|
+
## irbでの使用方法
|
32
|
+
|
33
|
+
$ irb -r libgss
|
34
|
+
|
35
|
+
>> network = Libgss::Network.new("http://localhost:3000", ssl_disabled: true)
|
36
|
+
=> #<Libgss::Network:2152782140 @ssl_disabled=true, @base_url="http://localhost:3000", @ssl_base_url="http://localhost:3000", @platform="fontana">
|
37
|
+
>> network.player_id = "1000001"
|
38
|
+
=> "1000001"
|
39
|
+
>> network.login
|
40
|
+
=> true
|
41
|
+
>>
|
42
|
+
?> req1 = network.new_action_request
|
43
|
+
=> #<Libgss::ActionRequest:2152568320 @action_url="http://localhost:3000/api/1.0.0/actions.json?auth_token=259rKDuSb3CT1UxbywAf", @status=0, @actions=[], @action_id=0>
|
44
|
+
>> req1.execute("ItemRubyStoredScript", "use_item", {"item_cd" => "20001"})
|
45
|
+
=> #<Libgss::Action:0x0000010092f7b0 @id=1, @args={:action=>"execute", :name=>"ItemRubyStoredScript", :key=>"use_item", :args=>{"item_cd"=>"20001"}}>
|
46
|
+
>> req1.get_by_game_data
|
47
|
+
=> #<Libgss::Action:0x000001008f9188 @id=2, @args={:action=>"get", :name=>"GameData"}>
|
48
|
+
>> req1.send_request
|
49
|
+
=> nil
|
50
|
+
>>
|
51
|
+
?> req1.outputs
|
52
|
+
=> [{"result"=>"You don't have enough item", "id"=>1}, {"result"=>{"content"=>{"hp"=>15, "max_hp"=>15, "mp"=>5, "max_mp"=>5, "exp"=>100, "money"=>200, "items"=>{"20001"=>0, "20005"=>1}, "equipments"=>{"head"=>10018, "body"=>10012, "right_hand"=>10001, "left_hand"=>nil}}, "greeting_points"=>0, "login_bonus"=>[[10001, 1]], "invitation_code"=>nil, "invite_player"=>nil, "read_notifications"=>[]}, "id"=>2}]
|
53
|
+
>>
|
54
|
+
?> req1.outputs.get(1)
|
55
|
+
=> {"result"=>"You don't have enough item", "id"=>1}
|
56
|
+
|
57
|
+
|
@@ -30,6 +30,12 @@ module Libgss
|
|
30
30
|
@action_id = 0;
|
31
31
|
end
|
32
32
|
|
33
|
+
def inspect
|
34
|
+
r = "#<#{self.class.name}:#{self.object_id} "
|
35
|
+
fields = (instance_variables - [:@httpclient]).map{|f| "#{f}=#{instance_variable_get(f).inspect}"}
|
36
|
+
r << fields.join(", ") << ">"
|
37
|
+
end
|
38
|
+
|
33
39
|
def next_action_id
|
34
40
|
@action_id += 1
|
35
41
|
end
|
data/lib/libgss/network.rb
CHANGED
@@ -44,6 +44,12 @@ module Libgss
|
|
44
44
|
@httpclient.ssl_config.verify_mode = nil # 自己署名の証明書をOKにする
|
45
45
|
end
|
46
46
|
|
47
|
+
def inspect
|
48
|
+
r = "#<#{self.class.name}:#{self.object_id} "
|
49
|
+
fields = (instance_variables - [:@httpclient]).map{|f| "#{f}=#{instance_variable_get(f).inspect}"}
|
50
|
+
r << fields.join(", ") << ">"
|
51
|
+
end
|
52
|
+
|
47
53
|
def login
|
48
54
|
raise "player_id is not set." if player_id.nil? || player_id.empty?
|
49
55
|
res = @httpclient.post(login_url, "player[id]" => player_id)
|
data/lib/libgss/outputs.rb
CHANGED
@@ -7,17 +7,17 @@ module Libgss
|
|
7
7
|
|
8
8
|
class Outputs
|
9
9
|
extend Forwardable
|
10
|
+
include Enumerable
|
10
11
|
|
11
12
|
def initialize(array)
|
12
13
|
@array = array
|
13
14
|
end
|
14
15
|
|
15
16
|
# メソッドを@arrayに移譲する
|
16
|
-
def_delegators :@array, :[], :length, :first, :last
|
17
|
+
def_delegators :@array, :[], :length, :first, :last, :inspect, :each
|
17
18
|
|
18
19
|
def get(id)
|
19
20
|
@array.detect{|output| output["id"] == id}
|
20
21
|
end
|
21
|
-
|
22
22
|
end
|
23
23
|
end
|
data/lib/libgss/version.rb
CHANGED
@@ -154,6 +154,14 @@ describe Libgss::ActionRequest do
|
|
154
154
|
end
|
155
155
|
|
156
156
|
|
157
|
+
it "outputs is an Enumerable" do
|
158
|
+
request.get_by_player.with(ACITON_ID_PLAYER)
|
159
|
+
request.server_time.with(ACITON_ID_SERVER_TIME)
|
160
|
+
request.get_by_game_data.with(ACITON_ID_GAME_DATA) # withメソッドで短く書くこともできます。
|
161
|
+
request.send_request
|
162
|
+
request.outputs.map{|r| r["id"]}.should == [ACITON_ID_PLAYER, ACITON_ID_SERVER_TIME, ACITON_ID_GAME_DATA]
|
163
|
+
end
|
164
|
+
|
157
165
|
end
|
158
166
|
end
|
159
167
|
|
data/spec/libgss/network_spec.rb
CHANGED
@@ -72,4 +72,14 @@ describe Libgss::Network do
|
|
72
72
|
its(:status){ should == Libgss::ActionRequest::STATUS_PREPARING }
|
73
73
|
end
|
74
74
|
|
75
|
+
describe "#inspect" do
|
76
|
+
it "doesn't contain @httpclient" do
|
77
|
+
network.inspect.should_not =~ /@httpclient/
|
78
|
+
end
|
79
|
+
|
80
|
+
it "isn't too long" do
|
81
|
+
network.inspect.length.should < 200
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
75
85
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libgss
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- akima
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-05-
|
11
|
+
date: 2013-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -94,6 +94,7 @@ files:
|
|
94
94
|
- Gemfile.lock
|
95
95
|
- LICENSE.txt
|
96
96
|
- README.md
|
97
|
+
- README_ja.md
|
97
98
|
- Rakefile
|
98
99
|
- lib/libgss.rb
|
99
100
|
- lib/libgss/action.rb
|