tamashii-client 0.1.2 → 0.2.1

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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: be044e47ec7a244c52a655253dd614914f16d9c3
4
- data.tar.gz: 572050ce905a7f055a1fe2db1551731a68962779
3
+ metadata.gz: aeeb6f1b88c8a5350d6be7c42bb6779f87b59e10
4
+ data.tar.gz: 10f952b754919daf6bba2f1a482d884e34f385e8
5
5
  SHA512:
6
- metadata.gz: efaecb8ab11fb8facf2d0b9b6468f937699f4f5b24a4b553ac81340bdc4ab3a6c50b36712943d8c6eb079738749fc872411f0b774d29b449cbb6ef2e88d46d55
7
- data.tar.gz: 8d6c7c85d20a035fd825c1c3bdd1e05e342eba5e68d282b119b5b54836153a3988864ad1f2c55af5db073caeb11e299ce66752d5b67bb678062295c05823607f
6
+ metadata.gz: f34b7b826b5ef70eab5235bbdd8ebf8d798f0b58773792008dd47133289500590d82ec34969c531eb74016242a953084600a6e73ed77df8fd91801655919c1ee
7
+ data.tar.gz: 33f6f01f482850cd410e1e27d9130f6367021148d8d154b6f45b8a7ff9628d244b9d5316d927d21fff84d44e7f00634c0f829c301ef87c9f9e7bc45a101bdf68
@@ -1,3 +1,4 @@
1
+ require "tamashii/config"
1
2
  require "tamashii/common"
2
3
  require "tamashii/client/version"
3
4
  require "tamashii/client/config"
@@ -7,12 +8,13 @@ module Tamashii
7
8
  autoload :Base, "tamashii/client/base"
8
9
 
9
10
  def self.config(&block)
10
- return Config.class_eval(&block) if block_given?
11
- Config
11
+ @config ||= Config.new
12
+ return instance_exec(@config, &block) if block_given?
13
+ @config
12
14
  end
13
15
 
14
16
  def self.logger
15
- @logger ||= Tamashii::Logger.new(Config.log_file).tap do |logger|
17
+ @logger ||= Tamashii::Logger.new(self.config.log_file).tap do |logger|
16
18
  logger.progname = "WebSocket Client"
17
19
  end
18
20
  end
@@ -6,7 +6,6 @@ require 'timeout'
6
6
  require 'websocket/driver'
7
7
 
8
8
 
9
- require "tamashii/common"
10
9
  require "tamashii/client/config"
11
10
 
12
11
  module Tamashii
@@ -20,8 +19,8 @@ module Tamashii
20
19
  end
21
20
 
22
21
  def initialize
23
- entry_point_with_slash = Config.entry_point.start_with?("/") ? Config.entry_point : "/#{Config.entry_point}"
24
- @url = "#{Config.use_ssl ? "wss" : "ws"}://#{Config.host}:#{Config.port}#{entry_point_with_slash}"
22
+ entry_point_with_slash = Tamashii::Client.config.entry_point.start_with?("/") ? Tamashii::Client.config.entry_point : "/#{Tamashii::Client.config.entry_point}"
23
+ @url = "#{Tamashii::Client.config.use_ssl ? "wss" : "ws"}://#{Tamashii::Client.config.host}:#{Tamashii::Client.config.port}#{entry_point_with_slash}"
25
24
 
26
25
  @callbacks = {}
27
26
 
@@ -118,8 +117,8 @@ module Tamashii
118
117
  end
119
118
 
120
119
  def wait_for_worker_thread
121
- if !@thread.join(Config.closing_timeout)
122
- logger.error "Unable to stop worker thread in #{Config.closing_timeout} second! Force kill the worker thread"
120
+ if !@thread.join(Tamashii::Client.config.closing_timeout)
121
+ logger.error "Unable to stop worker thread in #{Tamashii::Client.config.closing_timeout} second! Force kill the worker thread"
123
122
  kill_worker_thread
124
123
  end
125
124
  end
@@ -131,15 +130,15 @@ module Tamashii
131
130
  end
132
131
 
133
132
  def open_socket
134
- Timeout::timeout(Config.opening_timeout) do
135
- if Config.use_ssl
136
- OpenSSL::SSL::SSLSocket.new(TCPSocket.new(Config.host, Config.port)).connect
133
+ Timeout::timeout(Tamashii::Client.config.opening_timeout) do
134
+ if Tamashii::Client.config.use_ssl
135
+ OpenSSL::SSL::SSLSocket.new(TCPSocket.new(Tamashii::Client.config.host, Tamashii::Client.config.port)).connect
137
136
  else
138
- TCPSocket.new(Config.host, Config.port)
137
+ TCPSocket.new(Tamashii::Client.config.host, Tamashii::Client.config.port)
139
138
  end
140
139
  end
141
140
  rescue Timeout::Error => e
142
- logger.error "Opening timeout after #{Config.opening_timeout} seconds"
141
+ logger.error "Opening timeout after #{Tamashii::Client.config.opening_timeout} seconds"
143
142
  nil
144
143
  rescue => e
145
144
  nil
@@ -163,7 +162,7 @@ module Tamashii
163
162
 
164
163
  def open_socket_async
165
164
  if !closing? && !stopped?
166
- @open_socket_task = Concurrent::ScheduledTask.execute(Config.opening_retry_interval, &method(:open_socket_runner))
165
+ @open_socket_task = Concurrent::ScheduledTask.execute(Tamashii::Client.config.opening_retry_interval, &method(:open_socket_runner))
167
166
  else
168
167
  logger.warn "Client is closing, no longer need to create socket"
169
168
  end
@@ -1,16 +1,17 @@
1
- require 'tamashii/common'
2
1
  module Tamashii
3
2
  module Client
4
- class Config < Tamashii::Config
5
- register :log_file, STDOUT
3
+ class Config
4
+ include Tamashii::Configurable
6
5
 
7
- register :use_ssl, false
8
- register :entry_point, ""
9
- register :host, "localhost"
10
- register :port, 3000
11
- register :opening_timeout, 10
12
- register :opening_retry_interval, 1
13
- register :closing_timeout, 10
6
+ config :log_file, default: STDOUT
7
+
8
+ config :use_ssl, default: false
9
+ config :entry_point, default: ''
10
+ config :host, default: 'localhost'
11
+ config :port, default: 3000
12
+ config :opening_timeout, default: 10
13
+ config :opening_retry_interval, default: 1
14
+ config :closing_timeout, default: 10
14
15
 
15
16
  def log_level(level = nil)
16
17
  return Client.logger.level if level.nil?
@@ -1,5 +1,5 @@
1
1
  module Tamashii
2
2
  module Client
3
- VERSION = "0.1.2"
3
+ VERSION = "0.2.1"
4
4
  end
5
5
  end
@@ -32,7 +32,8 @@ Gem::Specification.new do |spec|
32
32
  spec.add_runtime_dependency "websocket-driver"
33
33
  spec.add_runtime_dependency "nio4r"
34
34
  spec.add_runtime_dependency "logger-colors"
35
- spec.add_runtime_dependency "tamashii-common"
35
+ spec.add_runtime_dependency "tamashii-config"
36
+ spec.add_runtime_dependency "tamashii-common", ">= 0.2"
36
37
  spec.add_runtime_dependency "concurrent-ruby"
37
38
 
38
39
  spec.add_development_dependency "bundler", "~> 1.13"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tamashii-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - 蒼時弦也
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2017-09-10 00:00:00.000000000 Z
13
+ date: 2017-11-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: websocket-driver
@@ -55,7 +55,7 @@ dependencies:
55
55
  - !ruby/object:Gem::Version
56
56
  version: '0'
57
57
  - !ruby/object:Gem::Dependency
58
- name: tamashii-common
58
+ name: tamashii-config
59
59
  requirement: !ruby/object:Gem::Requirement
60
60
  requirements:
61
61
  - - ">="
@@ -68,6 +68,20 @@ dependencies:
68
68
  - - ">="
69
69
  - !ruby/object:Gem::Version
70
70
  version: '0'
71
+ - !ruby/object:Gem::Dependency
72
+ name: tamashii-common
73
+ requirement: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0.2'
78
+ type: :runtime
79
+ prerelease: false
80
+ version_requirements: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0.2'
71
85
  - !ruby/object:Gem::Dependency
72
86
  name: concurrent-ruby
73
87
  requirement: !ruby/object:Gem::Requirement
@@ -209,7 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
209
223
  version: '0'
210
224
  requirements: []
211
225
  rubyforge_project:
212
- rubygems_version: 2.5.1
226
+ rubygems_version: 2.6.11
213
227
  signing_key:
214
228
  specification_version: 4
215
229
  summary: The WebSocket client of Tamashii framework