libgss 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NWI5MTBmYjkxNGM3OTRjYWZlMzQ5NDYwY2NiZDA5M2ViYmM5Mjc1OQ==
4
+ MzMyYThjOGEyMWZhYmQ5OGQwOTQwY2Y3NTc3N2I4Mjg5N2M0YWY0Mw==
5
5
  data.tar.gz: !binary |-
6
- ZjNiYTE4YWI0NTljNmJjNzcyZDBmOTY1MmU5ZDU2M2FlMTk2NmVhYw==
6
+ ZDM2YTIzZjcxZDU5YTg4ZjZhY2JhNTgwMjBhOWIwYWIzZTU1NmU5NQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- YzNkMDkxNzIzYzZhNmJkNmQ2MTk2NzYxNWExYzUwYmYxOTBiOWVmNmRkMjkw
10
- NDg5OWJiZGU4YjJkODc2ZjBkOWU1NWFmYjZiZDQ4ZDgyMTE1NWVjYjRhYjY0
11
- YmFlNDM0MDBmMWFiYmI1Mjg0NmFiMDZhNGM4YzFkMGM2ZjE2YTA=
9
+ NTA0ODk5MGY5Y2FjNzc0M2VhNzE2YzUxZDFjMmUyYmIzZjM1NGRiNTM5MGJj
10
+ MzhhOWQzNzkxY2FlNTQ3MDcyZmFiN2NmMTA1NmQ5N2EwMGIyZDU4ZDRlZjQ5
11
+ YzNlMzA1OWQyYTdhNTJkZTJhODE5MjRmYjM4M2FmZDg0MWFjNjk=
12
12
  data.tar.gz: !binary |-
13
- ZDE4MDBmNGI1MzFjNzdjZTI5OTc1MDA0NGQ4ZDkzODA4OTBhOTllNDhmOGNm
14
- MTVlYWNlN2RmNzYwMjBlMDk5OTIzNWYxY2FiZmRiZTNiZjBiMTdkNDgxOTNl
15
- ODU2MWFjNDVjOTRmMzZhNGE3ZDA4MjQ4MThmZDRiYzAyY2FiMTQ=
13
+ YTM2YzhhMzY1YTIyMTFmZjM4MzY5OTRiZTAwMjNiNWZmYzRlZWZjOGI0N2Nm
14
+ YmU4NjUyZjMzMjIxNjNiYzY1NWFjYTdmNmUxM2QyMzEyMGJiNDFiMGJiODk1
15
+ NTdhN2JkYjg5NjBhYzIwOGJiNWY4YjlkYTViMjkxN2Q2MTM0Zjc=
data/Gemfile.lock CHANGED
@@ -1,16 +1,18 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- libgss (0.2.0)
4
+ libgss (0.5.0)
5
5
  httpclient
6
6
  json
7
+ oauth
7
8
 
8
9
  GEM
9
10
  remote: https://rubygems.org/
10
11
  specs:
11
12
  diff-lcs (1.2.3)
12
- httpclient (2.3.3)
13
+ httpclient (2.3.4.1)
13
14
  json (1.8.0)
15
+ oauth (0.4.7)
14
16
  rake (10.0.4)
15
17
  rspec (2.13.0)
16
18
  rspec-core (~> 2.13.0)
@@ -21,13 +21,14 @@ module Libgss
21
21
 
22
22
 
23
23
  # 読み込みのみ、書き込み不可
24
- attr_reader :action_url
24
+ attr_reader :action_url, :req_headers
25
25
  attr_reader :status, :outputs
26
26
 
27
27
  # コンストラクタ
28
- def initialize(httpclient, action_url)
28
+ def initialize(httpclient, action_url, req_headers)
29
29
  @httpclient = httpclient
30
30
  @action_url = action_url
31
+ @req_headers = req_headers
31
32
  @status = STATUS_PREPARING
32
33
  @actions = []
33
34
  @action_id = 0;
@@ -51,7 +52,7 @@ module Libgss
51
52
 
52
53
  # アクション群を実行するために実際にHTTPリクエストを送信します。
53
54
  def send_request(&callback)
54
- res = @httpclient.post(action_url, {"inputs" => @actions.map(&:to_hash)}.to_json)
55
+ res = @httpclient.post(action_url, {"inputs" => @actions.map(&:to_hash)}.to_json, req_headers)
55
56
  case res.code.to_i
56
57
  when 200..299 then # OK
57
58
  else
@@ -312,6 +313,15 @@ module Libgss
312
313
  add_action(args)
313
314
  end
314
315
 
316
+
317
+ # マスタの差分を取得します
318
+ # @param [Hash] downloaded_versions キーが対象となるコレクション名、値がそのバージョンを示すHash
319
+ # @return 差分コレクション毎の差分を示すHashの配列
320
+ def master_diffs(downloaded_versions)
321
+ args = {action: "master_diffs", downloaded_versions: downloaded_versions}
322
+ add_action(args)
323
+ end
324
+
315
325
  end
316
326
 
317
327
  end
@@ -10,18 +10,19 @@ module Libgss
10
10
  STATUS_ERROR = 5
11
11
  STATUS_TIMEOUT = 6
12
12
 
13
- attr_reader :url, :status, :response_data
13
+ attr_reader :url, :req_headers, :status, :response_data
14
14
 
15
15
  # コンストラクタ
16
- def initialize(httpclient, url)
16
+ def initialize(httpclient, url, req_headers)
17
17
  @httpclient = httpclient
18
18
  @url = url
19
+ @req_headers = req_headers
19
20
  @response_data = nil
20
21
  @status = STATUS_PREPARING
21
22
  end
22
23
 
23
24
  def send_request(&callback)
24
- res = @httpclient.get(url)
25
+ res = @httpclient.get(url, nil, req_headers)
25
26
  @response_data = res.body
26
27
  callback.call(@response_data) if callback
27
28
  end
@@ -26,6 +26,8 @@ module Libgss
26
26
  attr_accessor :public_asset_url_prefix
27
27
  attr_accessor :public_asset_url_suffix
28
28
 
29
+ attr_accessor :client_version
30
+ attr_accessor :device_type_cd
29
31
 
30
32
  DEFAULT_HTTP_PORT = (ENV['DEFAULT_HTTP_PORT' ] || 80).to_i
31
33
  DEFAULT_HTTPS_PORT = (ENV['DEFAULT_HTTPS_PORT'] || 443).to_i
@@ -60,6 +62,9 @@ module Libgss
60
62
  @consumer_secret = options[:consumer_secret] || ENV["CONSUMER_SECRET"]
61
63
  @ignore_signature_key = !!options[:ignore_signature_key]
62
64
 
65
+ @device_type_cd = options[:device_type_cd]
66
+ @client_version = options[:client_version]
67
+
63
68
  @httpclient = HTTPClient.new
64
69
  @httpclient.ssl_config.verify_mode = nil # 自己署名の証明書をOKにする
65
70
  end
@@ -70,6 +75,12 @@ module Libgss
70
75
  r << fields.join(", ") << ">"
71
76
  end
72
77
 
78
+ def req_headers
79
+ {
80
+ "X-Device-Type" => device_type_cd,
81
+ "X-Client-Version" => client_version,
82
+ }
83
+ end
73
84
 
74
85
  # GSSサーバに接続してログインの検証と処理を行います。
75
86
  #
@@ -80,7 +91,7 @@ module Libgss
80
91
  def login(extra = {})
81
92
  attrs = { "player[id]" => player_id }
82
93
  extra.each{|k, v| attrs[ "player[#{k}]" ] = v }
83
- res = @httpclient.post(login_url, attrs)
94
+ res = @httpclient.post(login_url, attrs, req_headers)
84
95
  process_json_response(res) do |obj|
85
96
  @player_id ||= obj["player_id"]
86
97
  @auth_token = obj["auth_token"]
@@ -99,15 +110,15 @@ module Libgss
99
110
  end
100
111
 
101
112
  def new_action_request
102
- ActionRequest.new(httpclient_for_action, action_url)
113
+ ActionRequest.new(httpclient_for_action, action_url, req_headers)
103
114
  end
104
115
 
105
116
  def new_public_asset_request(asset_path)
106
- AssetRequest.new(@httpclient, public_asset_url(asset_path))
117
+ AssetRequest.new(@httpclient, public_asset_url(asset_path), req_headers)
107
118
  end
108
119
 
109
120
  def new_protected_asset_request(asset_path)
110
- AssetRequest.new(@httpclient, protected_asset_url(asset_path))
121
+ AssetRequest.new(@httpclient, protected_asset_url(asset_path), req_headers)
111
122
  end
112
123
 
113
124
  def httpclient_for_action
@@ -1,3 +1,3 @@
1
1
  module Libgss
2
- VERSION = "0.4.1"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -53,7 +53,7 @@ describe Libgss::ActionRequest do
53
53
 
54
54
 
55
55
  expected_player_1000001 = {
56
- "player_id"=>"fontana:1000001",
56
+ "player_id"=>"1000001",
57
57
  "nickname"=>nil,
58
58
  "level"=>1,
59
59
  "first_login_at"=> Time.parse("2012/7/15 21:50+09:00").to_i, # 1342356600,
@@ -24,8 +24,8 @@ describe "Libgss::ActionRequest friendship" do
24
24
  request.outputs.length.should == 1
25
25
  result = request.outputs.first["result"]
26
26
  result.length.should == 8
27
- result[0..6].each{|friendship| friendship["requester_id"].should == "fontana:1000001"}
28
- result[7..7].each{|friendship| friendship["accepter_id" ].should == "fontana:1000001"}
27
+ result[0..6].each{|friendship| friendship["requester_id"].should == "1000001"}
28
+ result[7..7].each{|friendship| friendship["accepter_id" ].should == "1000001"}
29
29
  end
30
30
  end
31
31
 
@@ -49,7 +49,7 @@ describe "Libgss::ActionRequest friendship" do
49
49
  friendships = request.outputs.last["result"]
50
50
  friendships.length.should == 8 + (new_data ? 1 : 0)
51
51
  friendships.detect{|f|
52
- f["requester_id"] == "fontana:1000001" &&
52
+ f["requester_id"] == "1000001" &&
53
53
  f["accepter_id"] == target &&
54
54
  f["status_cd"] == status_cd
55
55
  }.should_not be_nil
@@ -61,7 +61,7 @@ describe "Libgss::ActionRequest friendship" do
61
61
  friendships = request.outputs.last["result"]
62
62
  friendships.length.should == 8
63
63
  friendships.detect{|f|
64
- f["requester_id"] == "fontana:1000001" &&
64
+ f["requester_id"] == "1000001" &&
65
65
  f["accepter_id"] == target
66
66
  }.should be_nil
67
67
 
@@ -73,12 +73,12 @@ describe "Libgss::ActionRequest friendship" do
73
73
  friendships.length.should == 8
74
74
  if new_data
75
75
  friendships.detect{|f|
76
- f["requester_id"] == "fontana:1000001" &&
76
+ f["requester_id"] == "1000001" &&
77
77
  f["accepter_id"] == target
78
78
  }.should be_nil
79
79
  else
80
80
  friendships.detect{|f|
81
- f["requester_id"] == "fontana:1000001" &&
81
+ f["requester_id"] == "1000001" &&
82
82
  f["accepter_id"] == target &&
83
83
  f["status_cd"] == status_cd
84
84
  }.should_not be_nil
@@ -100,38 +100,38 @@ describe "Libgss::ActionRequest friendship" do
100
100
 
101
101
  # フレンドシップがない初期状態
102
102
  context "without friendship" do
103
- it_should_behave_like "friendship state transition", "fontana:1000009", :apply , "OK", FriendshipApplied_r, :new
104
- it_should_behave_like "friendship state transition", "fontana:1000009", :approve , "NG", 1003
105
- it_should_behave_like "friendship state transition", "fontana:1000009", :breakoff, "IG", nil, :new
106
- it_should_behave_like "friendship state transition", "fontana:1000009", :block , "OK", FriendshipBlocked_r, :new
107
- it_should_behave_like "friendship state transition", "fontana:1000009", :unblock , "IG", nil, :new
103
+ it_should_behave_like "friendship state transition", "1000009", :apply , "OK", FriendshipApplied_r, :new
104
+ it_should_behave_like "friendship state transition", "1000009", :approve , "NG", 1003
105
+ it_should_behave_like "friendship state transition", "1000009", :breakoff, "IG", nil, :new
106
+ it_should_behave_like "friendship state transition", "1000009", :block , "OK", FriendshipBlocked_r, :new
107
+ it_should_behave_like "friendship state transition", "1000009", :unblock , "IG", nil, :new
108
108
  end
109
109
 
110
110
  context "approve" do
111
- it_should_behave_like "friendship state transition", "fontana:1000005", :approve , "OK", FriendshipApproved
111
+ it_should_behave_like "friendship state transition", "1000005", :approve , "OK", FriendshipApproved
112
112
  end
113
113
 
114
114
  context "breakoff" do
115
- it_should_behave_like "friendship state transition", "fontana:1000002", :breakoff , "OK", FriendshipDeleted
116
- it_should_behave_like "friendship state transition", "fontana:1000003", :breakoff , "OK", FriendshipDeleted
117
- it_should_behave_like "friendship state transition", "fontana:1000004", :breakoff , "IG", FriendshipDeleted
118
- it_should_behave_like "friendship state transition", "fontana:1000005", :breakoff , "OK", FriendshipDeleted
115
+ it_should_behave_like "friendship state transition", "1000002", :breakoff , "OK", FriendshipDeleted
116
+ it_should_behave_like "friendship state transition", "1000003", :breakoff , "OK", FriendshipDeleted
117
+ it_should_behave_like "friendship state transition", "1000004", :breakoff , "IG", FriendshipDeleted
118
+ it_should_behave_like "friendship state transition", "1000005", :breakoff , "OK", FriendshipDeleted
119
119
  end
120
120
 
121
121
  context "block" do
122
- it_should_behave_like "friendship state transition", "fontana:1000002", :block , "OK", FriendshipBlocked_r
123
- it_should_behave_like "friendship state transition", "fontana:1000003", :block , "OK", FriendshipBlocked_r
124
- it_should_behave_like "friendship state transition", "fontana:1000004", :block , "OK", FriendshipBlocked_r
125
- it_should_behave_like "friendship state transition", "fontana:1000005", :block , "OK", FriendshipBlocked_r
126
- it_should_behave_like "friendship state transition", "fontana:1000006", :block , "OK", FriendshipBlocked_r
127
- it_should_behave_like "friendship state transition", "fontana:1000007", :block , "OK", FriendshipBlocked_lr
128
- it_should_behave_like "friendship state transition", "fontana:1000008", :block , "OK", FriendshipBlocked_lr
122
+ it_should_behave_like "friendship state transition", "1000002", :block , "OK", FriendshipBlocked_r
123
+ it_should_behave_like "friendship state transition", "1000003", :block , "OK", FriendshipBlocked_r
124
+ it_should_behave_like "friendship state transition", "1000004", :block , "OK", FriendshipBlocked_r
125
+ it_should_behave_like "friendship state transition", "1000005", :block , "OK", FriendshipBlocked_r
126
+ it_should_behave_like "friendship state transition", "1000006", :block , "OK", FriendshipBlocked_r
127
+ it_should_behave_like "friendship state transition", "1000007", :block , "OK", FriendshipBlocked_lr
128
+ it_should_behave_like "friendship state transition", "1000008", :block , "OK", FriendshipBlocked_lr
129
129
  end
130
130
 
131
131
  context "unblock" do
132
- it_should_behave_like "friendship state transition", "fontana:1000006", :unblock , "OK", FriendshipDeleted
133
- it_should_behave_like "friendship state transition", "fontana:1000007", :unblock , "OK", FriendshipBlocked_l
134
- it_should_behave_like "friendship state transition", "fontana:1000008", :unblock , "OK", FriendshipBlocked_l
132
+ it_should_behave_like "friendship state transition", "1000006", :unblock , "OK", FriendshipDeleted
133
+ it_should_behave_like "friendship state transition", "1000007", :unblock , "OK", FriendshipBlocked_l
134
+ it_should_behave_like "friendship state transition", "1000008", :unblock , "OK", FriendshipBlocked_l
135
135
  end
136
136
  end
137
137
 
@@ -3,7 +3,8 @@ require 'spec_helper'
3
3
  describe Libgss::Network do
4
4
 
5
5
  let(:network) do
6
- Libgss::Network.new("http://localhost:3000")
6
+ # Libgss::Network.new("http://localhost:3000")
7
+ new_network
7
8
  end
8
9
 
9
10
  describe "#setup" do
data/spec/spec_helper.rb CHANGED
@@ -13,6 +13,8 @@ end
13
13
  def new_network(url = "http://localhost:3000", player_id = "1000001")
14
14
  config = YAML.load_file(File.expand_path("../../fontana_sample/config/app_garden.yml", __FILE__))
15
15
  opts = {
16
+ device_type_cd: 1,
17
+ client_version: "2013073101",
16
18
  consumer_secret: config["consumer_secret"],
17
19
  player_id: player_id
18
20
  }
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.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - akima
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-16 00:00:00.000000000 Z
11
+ date: 2013-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler