libgss 0.10.0 → 0.11.0

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: 04a7f3350eb992b75f94b53b265dcaccf33aa168
4
- data.tar.gz: 3f915ba45f3bfbf49cc8313b7b61b465882d36f7
3
+ metadata.gz: c105a79bf1264de318a3bfcd0e045d4d7e670687
4
+ data.tar.gz: 05eefa0dea16f7a46cf465d1dc9975f085ec370c
5
5
  SHA512:
6
- metadata.gz: 428061466d77c8e1764bd3c4bc21430c70d77ac31704a31bd4ab133188ddfbd631b072443c415ae3bff53f52910c3fe908875f179cc3a3de862260dfcc821ac3
7
- data.tar.gz: e020cecda53511ceb7e739340b9d68d6aa864714408534a778f791134ea1aa43aa5b4afa172e5c7fe5cb322d6ed82701104806b585f9768f533757d12a334278
6
+ metadata.gz: 34ac90df59cfe2435882ce59ab526303d890f77dccd8eb3097be9f04891b9d48a202539b721d7c968b9d4e391e171c504db49b345049436c8e5e6d9ae53626f2
7
+ data.tar.gz: d7a407d2e4be36704cd3656686c0e7dfec393cbecc163b3665dd3a894492dd45f8f4c97db318cac72520388f85a53429ffdd0e662ea20a9990a123cc482a6ad0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- libgss (0.9.0)
4
+ libgss (0.11.0)
5
5
  httpclient
6
6
  json
7
7
  oauth
@@ -24,9 +24,9 @@ GEM
24
24
  fontana_client_support (0.8.0)
25
25
  httpclient (2.3.4.1)
26
26
  i18n (0.6.5)
27
- json (1.8.0)
28
- macaddr (1.6.1)
29
- systemu (~> 2.5.0)
27
+ json (1.8.1)
28
+ macaddr (1.7.1)
29
+ systemu (~> 2.6.2)
30
30
  mongoid (3.1.5)
31
31
  activemodel (~> 3.2)
32
32
  moped (~> 1.4)
@@ -45,7 +45,7 @@ GEM
45
45
  rspec-expectations (2.13.0)
46
46
  diff-lcs (>= 1.1.3, < 2.0)
47
47
  rspec-mocks (2.13.1)
48
- systemu (2.5.2)
48
+ systemu (2.6.4)
49
49
  tengine_support (1.2.2)
50
50
  activesupport (>= 3.0.0, < 4.0.0)
51
51
  tzinfo (0.3.37)
@@ -5,6 +5,7 @@ require 'httpclient'
5
5
  require 'json'
6
6
  require 'uri'
7
7
  require 'tengine/support/yaml_with_erb'
8
+ require 'tengine/support/core_ext/hash/keys'
8
9
 
9
10
  require 'uuid'
10
11
 
@@ -63,16 +64,19 @@ module Libgss
63
64
  # @option options [String] :client_version GSS/fontanaに登録されたクライアントリリースのバージョン
64
65
  # @option options [Integer] :https_port HTTPSで接続する際の接続先のポート番号
65
66
  def initialize(base_url_or_host, options = {})
66
- @ssl_disabled = options.delete(:ssl_disabled)
67
67
  if base_url_or_host =~ URI.regexp
68
68
  @base_url = base_url_or_host.sub(/\/\Z/, '')
69
69
  uri = URI.parse(@base_url)
70
- @ssl_base_url = build_https_url(uri, options[:https_port])
71
70
  else
71
+ if config_path = search_file(".libgss.yml")
72
+ config = YAML.load_file_with_erb(config_path)
73
+ options = config[base_url_or_host.to_s].deep_symbolize_keys.update(options)
74
+ end
72
75
  uri = URI::Generic.build({scheme: "http", host: base_url_or_host, port: DEFAULT_HTTP_PORT}.update(options))
73
76
  @base_url = uri.to_s
74
- @ssl_base_url = build_https_url(uri, options[:https_port])
75
77
  end
78
+ @ssl_base_url = build_https_url(uri, options[:https_port])
79
+ @ssl_disabled = options.delete(:ssl_disabled)
76
80
  @ssl_base_url = @base_url if @ssl_disabled
77
81
  @platform = options[:platform] || "fontana"
78
82
  @api_version = options[:api_version] || "1.0.0"
@@ -92,8 +96,16 @@ module Libgss
92
96
 
93
97
  @httpclient = HTTPClient.new
94
98
  @httpclient.ssl_config.verify_mode = nil # 自己署名の証明書をOKにする
99
+
100
+ load_app_garden
95
101
  end
96
102
 
103
+ def search_file(basename)
104
+ dirs = [".", "./config", ENV['HOME']].join(",")
105
+ Dir["{#{dirs}}/#{basename}"].select{|path| File.readable?(path)}.first
106
+ end
107
+ private :search_file
108
+
97
109
  def inspect
98
110
  r = "#<#{self.class.name}:#{self.object_id} "
99
111
  fields = (instance_variables - [:@httpclient]).map{|f| "#{f}=#{instance_variable_get(f).inspect}"}
@@ -149,6 +161,14 @@ module Libgss
149
161
  end
150
162
  end
151
163
 
164
+ # @return [Hash] サーバの諸情報を表すデータ
165
+ def status
166
+ res = Libgss.with_retry("status"){ @httpclient.get(status_url) }
167
+ process_json_response(res) do |obj|
168
+ return obj
169
+ end
170
+ end
171
+
152
172
  # @return [Boolean] コンストラクタに指定されたignore_signature_keyを返します
153
173
  def ignore_signature_key?
154
174
  @ignore_signature_key
@@ -187,12 +207,16 @@ module Libgss
187
207
  end
188
208
 
189
209
  # @param [String] path 対象となるapp_garden.ymlへのパス。デフォルトは "config/app_garden.yml" あるいは "config/app_garden.yml.erb"
190
- # @return 成功した場合自身のオブジェクトを返します。
210
+ # @return [Libgss::Network] selfを返します。
191
211
  def load_app_garden(path = nil)
192
- path ||= Dir.glob("config/app_garden.yml*").first
193
- raise ArgumentError, "file not found config/app_garden.yml* at #{Dir.pwd}" unless path
194
-
212
+ if path
213
+ raise ArgumentError, "file not found config/app_garden.yml* at #{Dir.pwd}" unless File.readable?(path)
214
+ else
215
+ path = search_file("app_garden.yml")
216
+ return self unless path
217
+ end
195
218
  # hash = YAML.load_file_with_erb(path, binding: binding) # tengine_supportが対応したらこんな感じで書きたい
219
+ puts "loading #{path}"
196
220
  erb = ERB.new(IO.read(path))
197
221
  erb.filename = path
198
222
  text = erb.result(binding) # Libgss::FontanaをFontanaとしてアクセスできるようにしたいので、このbindingの指定が必要です
@@ -205,7 +229,7 @@ module Libgss
205
229
  self.platform = name
206
230
  end
207
231
  end
208
- self
232
+ return self
209
233
  end
210
234
 
211
235
  # device_idを生成します
@@ -316,6 +340,10 @@ module Libgss
316
340
  path = URI.encode(asset_path) # パラメータとして渡されるのでURLエンコードする必要がある
317
341
  @action_url ||= base_url + "/api/#{api_version}/assets?path=#{path}&auth_token=#{auth_token}"
318
342
  end
343
+
344
+ def status_url
345
+ @status_url ||= base_url + "/api-server-status/all.json"
346
+ end
319
347
  end
320
348
 
321
349
  end
@@ -1,3 +1,3 @@
1
1
  module Libgss
2
- VERSION = "0.10.0"
2
+ VERSION = "0.11.0"
3
3
  end
metadata CHANGED
@@ -1,167 +1,167 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libgss
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.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-12-18 00:00:00.000000000 Z
11
+ date: 2014-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: fontana_client_support
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: mongoid
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: factory_girl
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: httpclient
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '>='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - '>='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: json
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - '>='
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - '>='
122
+ - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: oauth
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - '>='
129
+ - - ">="
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - '>='
136
+ - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: tengine_support
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - '>='
143
+ - - ">="
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0'
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - '>='
150
+ - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: uuid
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - '>='
157
+ - - ">="
158
158
  - !ruby/object:Gem::Version
159
159
  version: '0'
160
160
  type: :runtime
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
- - - '>='
164
+ - - ">="
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
167
  description: network library for Groovenauts GSS
@@ -173,10 +173,10 @@ executables:
173
173
  extensions: []
174
174
  extra_rdoc_files: []
175
175
  files:
176
- - .gitignore
177
- - .gitmodules
178
- - .rspec
179
- - .travis.yml
176
+ - ".gitignore"
177
+ - ".gitmodules"
178
+ - ".rspec"
179
+ - ".travis.yml"
180
180
  - Gemfile
181
181
  - Gemfile.lock
182
182
  - LICENSE.txt
@@ -236,17 +236,17 @@ require_paths:
236
236
  - lib
237
237
  required_ruby_version: !ruby/object:Gem::Requirement
238
238
  requirements:
239
- - - '>='
239
+ - - ">="
240
240
  - !ruby/object:Gem::Version
241
241
  version: '0'
242
242
  required_rubygems_version: !ruby/object:Gem::Requirement
243
243
  requirements:
244
- - - '>='
244
+ - - ">="
245
245
  - !ruby/object:Gem::Version
246
246
  version: '0'
247
247
  requirements: []
248
248
  rubyforge_project:
249
- rubygems_version: 2.0.3
249
+ rubygems_version: 2.2.2
250
250
  signing_key:
251
251
  specification_version: 4
252
252
  summary: network library for Groovenauts GSS
@@ -281,4 +281,3 @@ test_files:
281
281
  - spec/support/models/client_release.rb
282
282
  - spec/support/models/game_data.rb
283
283
  - spec/support/models/player.rb
284
- has_rdoc: