tdlib-ruby 0.4.0 → 0.8.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: '048a775eb8c8d07edb85a39c335d9ff33b5d8032'
4
- data.tar.gz: a5b940f2431cf9dffd76fa41775dddc37fc0cfe4
3
+ metadata.gz: 9ae3602c33ec3fcc94afe086dfa85572d59d851b
4
+ data.tar.gz: 219b93cf45f05b909e276b6534b89be70a00f834
5
5
  SHA512:
6
- metadata.gz: 74503569ec06caf882341062c719e32bcbc3715f02a638993800f1e9ec151685b483e7c7152b36e77327f6cd2ea2e135dacbee7412c07b4169b5939481c1c8eb
7
- data.tar.gz: a28c24da2eae0d59313ecd4f6e9de9336a243747da8d6d266143463e8a4d185c745899c450148da65715b02ed122afd694d754947f538df002691a1a4e5c5ccf
6
+ metadata.gz: 0f24b6e7d8c1821d00db49b1e45f653f040bb31e792cc46871c2789ba5e3f62de28f2eaa3a2921d3b0929ce502aa17f56093d44b26fe8044d9700c310b24429d
7
+ data.tar.gz: 42ba3c0ba60e5b7ed0f51be08314e607adf2da3a22c64d0fbaf2a84ee573adfce2d09ac6f1e050152964e7cef5f52595ea33f62a316e5a0be4a36ee4a0492667
@@ -1,3 +1,7 @@
1
+ ### 0.8.0 / 2018-04-25
2
+
3
+ * Fix await methods
4
+
1
5
  ### 0.4.0 / 2018-04-12
2
6
 
3
7
  * Add configurable timeout
@@ -69,6 +69,7 @@ class TD::Client
69
69
  @update_manager = update_manager
70
70
  @config = TD.config.client.to_h.merge(extra_config)
71
71
  authorize
72
+ @update_manager.run
72
73
  end
73
74
 
74
75
  # Sends asynchronous request to the TDLib client
@@ -98,12 +99,13 @@ class TD::Client
98
99
  @update_manager.add_handler(handler)
99
100
  query['@extra'] = extra
100
101
  TD::Api.client_send(@td_client, query)
101
- promise = Promise.new do
102
- time_start = Time.now
103
- until result || Time.now - time_start > timeout do end
104
- result
102
+ time_start = Time.now
103
+ loop do
104
+ sleep 0.1
105
+ break if result
106
+ raise TD::TimeoutError if Time.now - time_start > timeout
105
107
  end
106
- promise.execute.value(timeout) || (raise TD::TimeoutError)
108
+ result
107
109
  end
108
110
 
109
111
  # Synchronously executes TDLib request
@@ -131,11 +133,12 @@ class TD::Client
131
133
  end
132
134
 
133
135
  def on_ready(timeout: TIMEOUT, &_)
134
- promise = Promise.new do
135
- time_start = Time.now
136
- until @ready || Time.now - time_start > timeout do end
136
+ time_start = Time.now
137
+ loop do
138
+ sleep 0.1
139
+ break if @ready
140
+ raise TD::TimeoutError if Time.now - time_start > timeout
137
141
  end
138
- raise TD::TimeoutError unless promise.execute.then { self }.execute.value(timeout)
139
142
  yield self
140
143
  end
141
144
 
@@ -5,7 +5,6 @@ class TD::UpdateManager
5
5
  @td_client = td_client
6
6
  @handlers = []
7
7
  @mutex = Mutex.new
8
- init_update_loop
9
8
  end
10
9
 
11
10
  def add_handler(handler)
@@ -18,6 +17,12 @@ class TD::UpdateManager
18
17
  end
19
18
  end
20
19
 
20
+ def run
21
+ @update_loop_thread = Thread.start do
22
+ loop { stopped? ? break : handle_update }
23
+ end
24
+ end
25
+
21
26
  def stop
22
27
  @stopped = true
23
28
  end
@@ -28,12 +33,6 @@ class TD::UpdateManager
28
33
 
29
34
  private
30
35
 
31
- def init_update_loop
32
- @update_loop_thread = Thread.start do
33
- loop { stopped? ? break : handle_update }
34
- end
35
- end
36
-
37
36
  def handle_update
38
37
  update = TD::Api.client_receive(@td_client, 10)
39
38
  @mutex.synchronize do
@@ -1,4 +1,4 @@
1
1
  module TD
2
2
  # tdlib-ruby version
3
- VERSION = "0.4.0"
3
+ VERSION = "0.8.0"
4
4
  end
@@ -5,6 +5,9 @@ class UpdateManagerStub
5
5
  @td_client, @update, @handlers = td_client, update, []
6
6
  end
7
7
 
8
+ def run
9
+ end
10
+
8
11
  def add_handler(handler)
9
12
  @handlers << handler
10
13
  handler.call(@update)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tdlib-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Southbridge
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-12 00:00:00.000000000 Z
11
+ date: 2018-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-configurable