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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YjBlOTY0MzIyNTBkNDMzY2ExMGE5NDk2YzQzOTg2NWExNmJhOWQ0Yg==
4
+ Y2Y0OGU1MjZkZDE4ZDA2YmYzM2Q5YzNhNjMzYjczZTQwOThmODFiMg==
5
5
  data.tar.gz: !binary |-
6
- M2IyMzllMWM1ZWMyY2M3ZGFmOTA2MTJhNWQzNWNlNGE1ODJhOTMwYQ==
6
+ NDMwZmZiNTY5OGE3MTk2ZWMzZDRmN2IzNjgzMjkyYjdhNDY2YjBkNw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- Y2M1YWZkNmQ2NTk0NzMwOWRlY2U3NGMwYjE5MDNkZTVkNWM3Yjg5ZWVlZjli
10
- MmU2OTU4MDFiMDZhNzc3OGUwZWU2MzIyNGYxMTZhMTA5Njk3NzQ5NmFiNjU5
11
- MTdmNDJiNDdkYjhjOGNkMmExNWRlOTA4MTNkMTBiM2RjYTg5ZGU=
9
+ ZDQ0NWUxMTNmZTVjZjg2MTJiNGMwZGUyYmI2NDM3NjI1YzJhODRlMjZlNTc4
10
+ MDE3ODg4MTA0MjZhMGQwZTY4ZmI3NTdlNDYzY2MxZjI1Y2NjN2FkMzU5MDFj
11
+ N2FiOWEwNGIxYjY5OTViYWQ4NGRlZDg4OTdkNWIzY2ZiMDExZjA=
12
12
  data.tar.gz: !binary |-
13
- MTU1OWRkNmMyODk4OWRjNDRlYmM3OTVjYmEzNzVjYTVhNGU1Y2FkNDc4NDYw
14
- NjhhYmYzMGM1YmMxMWU1M2ZkMzJjNzA1ZDIyMjM2NTMyNzRiMjcxN2M0OTBj
15
- ZDRlMDdkZjFkNmVjZDcyNDNiMzEwODMwZDU1ZmIyYTY3MjY2ZTY=
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.1)
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.7.7)
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
- TODO: Write a gem description
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
- TODO: Write usage instructions here
22
-
23
- ## Contributing
24
-
25
- 1. Fork it
26
- 2. Create your feature branch (`git checkout -b my-new-feature`)
27
- 3. Commit your changes (`git commit -am 'Add some feature'`)
28
- 4. Push to the branch (`git push origin my-new-feature`)
29
- 5. Create new Pull Request
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
@@ -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)
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Libgss
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -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
 
@@ -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.1
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-20 00:00:00.000000000 Z
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