async 1.15.1 → 1.15.2

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
  SHA256:
3
- metadata.gz: b9530ec0131ea1a67aa243eabaaf6a20f2caa1588fe021c5efe4cec58f35c2b4
4
- data.tar.gz: 51dc5db69d0793b9a1e5feea4de6478a5e63bbafedac307f6e1122c5d29be8bf
3
+ metadata.gz: 55519b5f7b29512eaceee354a771301269e468d10d18d7e23293eb1338b5f07d
4
+ data.tar.gz: edddd6b602be01a9bf3cec386746e6de4f95d2f77f614beb1e1e0cb7ae8c615c
5
5
  SHA512:
6
- metadata.gz: 47b3ac832144d0c6555394368d3089f9577e4000fbb68b71972979d555a22d1028f34895ac7180cbe3a3314f6de7889d90ca6140c6ff27424f0f99e45d6ec085
7
- data.tar.gz: abc2da19eb893c978826b07cb7ad13c2616b03fd7b559b39742698ae06bbf3558dbe4155db29f14d2bc2ac66812ad8e5bb35c25fe76a338f55ee905dd69c9396
6
+ metadata.gz: 348c0f62da9255a1c05d4c265445657fca1afdddc468fc9308bd1d4c743d70105e34cb8426859da0f59803e360ba545bf554da5019de18031340739a10df8ef9
7
+ data.tar.gz: 0763a3e5b31f0c9a781598d6cb240aba3c5c282ddbbf68c153adf4e0609ca32ba601b86de0be6bf22b4f5563023cd8a4a82e0645038c75379f87138bbbee988a
@@ -11,6 +11,7 @@ before_script:
11
11
  - sudo sh -c 'echo 0 > /proc/sys/net/ipv6/conf/all/disable_ipv6'
12
12
 
13
13
  after_success:
14
+ - unset COVERAGE
14
15
  - bundle exec rake external
15
16
 
16
17
  matrix:
@@ -19,6 +20,8 @@ matrix:
19
20
  - rvm: 2.4
20
21
  - rvm: 2.5
21
22
  - rvm: 2.6
23
+ - rvm: 2.6
24
+ env: COVERAGE=PartialSummary,Coveralls
22
25
  - rvm: jruby-head
23
26
  env: JRUBY_OPTS="--debug -X+O"
24
27
  - rvm: truffleruby
data/Gemfile CHANGED
@@ -14,6 +14,5 @@ group :test do
14
14
  gem 'benchmark-ips'
15
15
  gem 'ruby-prof', platforms: :mri
16
16
 
17
- gem 'simplecov'
18
- gem 'coveralls', require: false
17
+ gem 'covered', require: 'covered/rspec'
19
18
  end
data/README.md CHANGED
@@ -10,6 +10,8 @@ Async is a composable asynchronous I/O framework for Ruby based on [nio4r] and [
10
10
  [![Coverage Status](https://coveralls.io/repos/socketry/async/badge.svg)](https://coveralls.io/r/socketry/async)
11
11
  [![Gitter](https://badges.gitter.im/join.svg)](https://gitter.im/socketry/async)
12
12
 
13
+ > "Lately I've been looking into `async`, as one of my projects – [tus-ruby-server](https://github.com/janko/tus-ruby-server) – would really benefit from `async` I/O. It's really beautifully designed." *– [janko](https://github.com/janko)*
14
+
13
15
  ## Motivation
14
16
 
15
17
  Several years ago, I was hosting websites on a server in my garage. Back then, my ADSL modem was very basic, and I wanted to have a DNS server which would resolve to an internal IP address when the domain itself resolved to my public IP. Thus was born [RubyDNS]. This project [was originally built on](https://github.com/ioquatix/rubydns/tree/v0.8.5) top of [EventMachine], but a lack of support for [IPv6 at the time](https://github.com/ioquatix/rubydns/issues/45) and [other problems](https://github.com/ioquatix/rubydns/issues/14), meant that I started looking for other options. Around that time [Celluloid] was picking up steam. I had not encountered actors before and I wanted to learn more about it. So, [I reimplemented RubyDNS on top of Celluloid](https://github.com/ioquatix/rubydns/tree/v0.9.0) and this eventually became the first stable release.
@@ -109,11 +111,11 @@ def nested_sleepy(task: Async::Task.current)
109
111
  end
110
112
 
111
113
  Async do |task|
112
- subtask = nested_sleepy
114
+ subtask = nested_sleepy(task: task)
113
115
  end
114
116
  ```
115
117
 
116
- This method effectively creates a child task. It's the most efficient way to schedule a task. The task is executed until the first blocking operation, at which point it will yield control and `#async` will return. The result of this method is the task itself.
118
+ This example creates a child `subtask` from the given parent `task`. It's the most efficient way to schedule a task. The task is executed until the first blocking operation, at which point it will yield control and `#async` will return. The result of this method is the task itself.
117
119
 
118
120
  ### Waiting for Results
119
121
 
data/Rakefile CHANGED
@@ -17,7 +17,7 @@ def clone_and_test(name)
17
17
  file.puts('gem "async", path: "../../"')
18
18
  end
19
19
 
20
- sh("cd #{path} && bundle install && bundle exec rake test")
20
+ sh("cd #{path} && bundle install && bundle exec rspec")
21
21
  end
22
22
 
23
23
  task :external do
@@ -27,6 +27,8 @@ Gem::Specification.new do |spec|
27
27
 
28
28
  spec.add_development_dependency "async-rspec", "~> 1.1"
29
29
 
30
+ spec.add_development_dependency "covered", "~> 0.10"
31
+
30
32
  spec.add_development_dependency "bundler"
31
33
  spec.add_development_dependency "rspec", "~> 3.6"
32
34
  spec.add_development_dependency "rake"
@@ -25,6 +25,22 @@ require 'logger'
25
25
 
26
26
  module Async
27
27
  class Logger
28
+ class Buffer < StringIO
29
+ def initialize(prefix = nil)
30
+ @prefix = prefix
31
+
32
+ super()
33
+ end
34
+
35
+ def puts(*args, prefix: @prefix)
36
+ args.each do |arg|
37
+ self.write(prefix) if prefix
38
+
39
+ super(arg)
40
+ end
41
+ end
42
+ end
43
+
28
44
  LEVELS = {debug: 0, info: 1, warn: 2, error: 3, fatal: 4}
29
45
 
30
46
  LEVELS.each do |name, level|
@@ -89,21 +105,22 @@ module Async
89
105
  end
90
106
 
91
107
  def format(subject = nil, *arguments, &block)
92
- buffer = StringIO.new
93
108
  prefix = time_offset_prefix
94
109
  indent = " " * prefix.size
95
110
 
111
+ buffer = Buffer.new("#{indent}| ")
112
+
96
113
  if subject
97
114
  format_subject(prefix, subject, output: buffer)
98
115
  end
99
116
 
100
117
  arguments.each do |argument|
101
- format_argument(indent, argument, output: buffer)
118
+ format_argument(argument, output: buffer)
102
119
  end
103
120
 
104
121
  if block_given?
105
122
  if block.arity.zero?
106
- format_argument(indent, yield, output: buffer)
123
+ format_argument(yield, output: buffer)
107
124
  else
108
125
  yield(buffer, @terminal)
109
126
  end
@@ -112,16 +129,16 @@ module Async
112
129
  @output.write buffer.string
113
130
  end
114
131
 
115
- def format_argument(prefix, argument, output: @output)
132
+ def format_argument(argument, output: @output)
116
133
  if argument.is_a? Exception
117
- format_exception(prefix, argument, output: output)
134
+ format_exception(argument, output: output)
118
135
  else
119
- format_value(prefix, argument, output: output)
136
+ format_value(argument, output: output)
120
137
  end
121
138
  end
122
139
 
123
- def format_exception(indent, exception, prefix = nil, pwd: Dir.pwd, output: @output)
124
- output.puts "#{indent}| #{prefix}#{@exception_title_style}#{exception.class}#{@reset_style}: #{exception}"
140
+ def format_exception(exception, prefix = nil, pwd: Dir.pwd, output: @output)
141
+ output.puts " #{prefix}#{@exception_title_style}#{exception.class}#{@reset_style}: #{exception}"
125
142
 
126
143
  exception.backtrace.each_with_index do |line, index|
127
144
  path, offset, message = line.split(":")
@@ -129,25 +146,23 @@ module Async
129
146
  # Make the path a bit more readable
130
147
  path.gsub!(/^#{pwd}\//, "./")
131
148
 
132
- output.puts "#{indent}| #{index == 0 ? "→" : " "} #{@exception_line_style}#{path}:#{offset}#{@reset_style} #{message}"
149
+ output.puts " #{index == 0 ? "→" : " "} #{@exception_line_style}#{path}:#{offset}#{@reset_style} #{message}"
133
150
  end
134
151
 
135
152
  if exception.cause
136
- output.puts "#{indent}|"
137
-
138
- format_exception(indent, exception.cause, "Caused by ", pwd: pwd, output: output)
153
+ format_exception(exception.cause, "Caused by ", pwd: pwd, output: output)
139
154
  end
140
155
  end
141
156
 
142
157
  def format_subject(prefix, subject, output: @output)
143
- output.puts "#{@prefix_style}#{prefix}: #{@subject_style}#{subject}#{@reset_style}"
158
+ output.puts "#{@subject_style}#{subject}#{@reset_style}", prefix: "#{@prefix_style}#{prefix}: "
144
159
  end
145
160
 
146
- def format_value(indent, value, output: @output)
161
+ def format_value(value, output: @output)
147
162
  string = value.to_s
148
163
 
149
164
  string.each_line do |line|
150
- output.puts "#{indent}: #{line}"
165
+ output.puts "#{line}"
151
166
  end
152
167
  end
153
168
 
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Async
22
- VERSION = "1.15.1"
22
+ VERSION = "1.15.2"
23
23
  end
@@ -18,6 +18,7 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  # THE SOFTWARE.
20
20
 
21
+ require 'async/rspec'
21
22
  require 'async/condition'
22
23
 
23
24
  require_relative 'condition_examples'
@@ -18,6 +18,7 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  # THE SOFTWARE.
20
20
 
21
+ require 'async'
21
22
  require 'benchmark/ips'
22
23
 
23
24
  RSpec.describe Async::Reactor do
@@ -18,7 +18,8 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  # THE SOFTWARE.
20
20
 
21
- require 'benchmark'
21
+ require 'async/reactor'
22
+ require 'async/clock'
22
23
 
23
24
  RSpec.describe Async::Task do
24
25
  let(:reactor) {Async::Reactor.new}
@@ -188,7 +189,7 @@ RSpec.describe Async::Task do
188
189
  state = :finished
189
190
  end
190
191
 
191
- time = Benchmark.realtime do
192
+ time = Async::Clock.measure do
192
193
  reactor.run
193
194
  end
194
195
 
@@ -18,7 +18,7 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  # THE SOFTWARE.
20
20
 
21
- require 'benchmark'
21
+ require "async/rspec"
22
22
 
23
23
  RSpec.describe Async::Wrapper do
24
24
  include_context Async::RSpec::Reactor
@@ -1,26 +1,5 @@
1
1
 
2
- if ENV['COVERAGE'] || ENV['TRAVIS']
3
- begin
4
- require 'simplecov'
5
-
6
- SimpleCov.start do
7
- add_filter "/spec/"
8
- end
9
-
10
- if ENV['TRAVIS']
11
- require 'coveralls'
12
- Coveralls.wear!
13
- end
14
- rescue LoadError
15
- warn "Could not load simplecov: #{$!}"
16
- end
17
- end
18
-
19
- require "bundler/setup"
20
- require "async"
21
-
22
- # Shared rspec helpers:
23
- require "async/rspec"
2
+ require "covered/rspec"
24
3
 
25
4
  RSpec.configure do |config|
26
5
  # Enable flags like --only-failures and --next-failure
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.15.1
4
+ version: 1.15.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-26 00:00:00.000000000 Z
11
+ date: 2019-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nio4r
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: covered
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.10'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.10'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: bundler
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -171,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
171
185
  - !ruby/object:Gem::Version
172
186
  version: '0'
173
187
  requirements: []
174
- rubygems_version: 3.0.1
188
+ rubygems_version: 3.0.2
175
189
  signing_key:
176
190
  specification_version: 4
177
191
  summary: Async is an asynchronous I/O framework based on nio4r.