libuv 0.11.21 → 0.11.22

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +17 -17
  3. data/.gitmodules +3 -3
  4. data/.rspec +1 -1
  5. data/.travis.yml +16 -16
  6. data/Gemfile +4 -4
  7. data/LICENSE +23 -23
  8. data/README.md +89 -88
  9. data/Rakefile +31 -31
  10. data/lib/libuv.rb +54 -54
  11. data/lib/libuv/async.rb +47 -47
  12. data/lib/libuv/check.rb +55 -55
  13. data/lib/libuv/dns.rb +85 -85
  14. data/lib/libuv/error.rb +74 -73
  15. data/lib/libuv/ext/ext.rb +258 -258
  16. data/lib/libuv/ext/platform/darwin_x64.rb +23 -23
  17. data/lib/libuv/ext/platform/linux.rb +7 -7
  18. data/lib/libuv/ext/platform/unix.rb +29 -29
  19. data/lib/libuv/ext/platform/windows.rb +40 -40
  20. data/lib/libuv/ext/tasks.rb +31 -31
  21. data/lib/libuv/ext/tasks/mac.rb +23 -23
  22. data/lib/libuv/ext/tasks/unix.rb +23 -23
  23. data/lib/libuv/ext/tasks/win.rb +14 -14
  24. data/lib/libuv/ext/types.rb +238 -238
  25. data/lib/libuv/file.rb +269 -269
  26. data/lib/libuv/filesystem.rb +232 -232
  27. data/lib/libuv/fs_event.rb +31 -31
  28. data/lib/libuv/handle.rb +85 -85
  29. data/lib/libuv/idle.rb +56 -56
  30. data/lib/libuv/loop.rb +412 -412
  31. data/lib/libuv/mixins/assertions.rb +23 -23
  32. data/lib/libuv/mixins/fs_checks.rb +58 -58
  33. data/lib/libuv/mixins/listener.rb +34 -34
  34. data/lib/libuv/mixins/net.rb +40 -40
  35. data/lib/libuv/mixins/resource.rb +27 -27
  36. data/lib/libuv/mixins/stream.rb +154 -154
  37. data/lib/libuv/pipe.rb +203 -203
  38. data/lib/libuv/prepare.rb +56 -56
  39. data/lib/libuv/signal.rb +51 -51
  40. data/lib/libuv/tcp.rb +334 -332
  41. data/lib/libuv/timer.rb +85 -85
  42. data/lib/libuv/tty.rb +37 -37
  43. data/lib/libuv/udp.rb +240 -240
  44. data/lib/libuv/version.rb +3 -3
  45. data/lib/libuv/work.rb +75 -75
  46. data/libuv.gemspec +56 -56
  47. data/spec/async_spec.rb +60 -60
  48. data/spec/cpu_spec.rb +10 -10
  49. data/spec/defer_spec.rb +980 -980
  50. data/spec/dns_spec.rb +90 -90
  51. data/spec/filesystem_spec.rb +261 -250
  52. data/spec/idle_spec.rb +56 -56
  53. data/spec/pipe_spec.rb +160 -160
  54. data/spec/tcp_spec.rb +267 -267
  55. metadata +55 -61
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f4fcd6272b191590fe0de54dd1ac550274029817
4
- data.tar.gz: 6daeb3384ddc251d3646b7899b08bdc783e0002f
3
+ metadata.gz: 314a3251be261152c7aec915b6e65dcc90e67af7
4
+ data.tar.gz: 7f64d85ebc3466e1572066168de7fe1e9012e46f
5
5
  SHA512:
6
- metadata.gz: 9c47d85028732940c607923f295322e03caf08c6076b13f4b2b5f1295024f081489010e03f95d7a0992549f89b33fc37516b4e72980e9d0d2f0ebbc3b61ed846
7
- data.tar.gz: 0b71157234bda204ae8a105d8abf8f1c6f05d74b9f735823e268b25a2e610136f811b7b3929586e388c493cbc46d5dfc0084d5a1e75a230d6e3b1ced5670e8f2
6
+ metadata.gz: 61c92ca9fa9aec3bb39d686911789416483a389d66d444db68b777171bb75c896679e3b06594f500eede88225d6db65a1188744c0d5bd1f0d19660b6a797e91f
7
+ data.tar.gz: 434d36a3ad68a6dea0305baf08345bfcbe9029ff68cfe134237bc1b8c883b22137dadae87d89110e97b13488ccb5e1dd2680cbc9c115b85c851a7fbaadbf0589
data/.gitignore CHANGED
@@ -1,17 +1,17 @@
1
- *.sw?
2
- .DS_Store
3
- coverage
4
- rdoc
5
- html
6
- pkg
7
- doc
8
- tmp
9
- rerun.txt
10
- Gemfile.lock
11
- .bundle
12
- .idea
13
- *.rbc
14
- .yardoc
15
- bin
16
- Gemfile-custom
17
- ext/*
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ html
6
+ pkg
7
+ doc
8
+ tmp
9
+ rerun.txt
10
+ Gemfile.lock
11
+ .bundle
12
+ .idea
13
+ *.rbc
14
+ .yardoc
15
+ bin
16
+ Gemfile-custom
17
+ ext/*
data/.gitmodules CHANGED
@@ -1,3 +1,3 @@
1
- [submodule "ext/libuv"]
2
- path = ext/libuv
3
- url = https://github.com/joyent/libuv.git
1
+ [submodule "ext/libuv"]
2
+ path = ext/libuv
3
+ url = https://github.com/joyent/libuv.git
data/.rspec CHANGED
@@ -1 +1 @@
1
- --format progress
1
+ --format progress
data/.travis.yml CHANGED
@@ -1,16 +1,16 @@
1
- language: ruby
2
- rvm:
3
- - "1.9.3"
4
- - "2.0.0"
5
- - ruby-head
6
- - rbx-2.2.1
7
- - jruby-head
8
- branches:
9
- only:
10
- - master
11
- before_install:
12
- - sudo apt-get install subversion
13
- - git submodule update --init --recursive
14
- - echo "yes" | gem uninstall ffi -a
15
- before_script:
16
- - rake compile
1
+ language: ruby
2
+ rvm:
3
+ - "1.9.3"
4
+ - "2.0.0"
5
+ - ruby-head
6
+ - rbx-2.2.1
7
+ - jruby-head
8
+ branches:
9
+ only:
10
+ - master
11
+ before_install:
12
+ - sudo apt-get install subversion
13
+ - git submodule update --init --recursive
14
+ - echo "yes" | gem uninstall ffi -a
15
+ before_script:
16
+ - rake compile
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "https://rubygems.org"
2
- gemspec
3
-
4
- gem "rubysl", :platform => :rbx
1
+ source "https://rubygems.org"
2
+ gemspec
3
+
4
+ gem "rubysl", :platform => :rbx
data/LICENSE CHANGED
@@ -1,24 +1,24 @@
1
- Copyright (c) 2004-2013 Cotag Media
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy
4
- of this software and associated documentation files (the "Software"), to deal
5
- in the Software without restriction, including without limitation the rights
6
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- copies of the Software, and to permit persons to whom the Software is furnished
8
- to do so, subject to the following conditions:
9
-
10
- The above copyright notice and this permission notice shall be included in all
11
- copies or substantial portions of the Software.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- THE SOFTWARE.
20
-
21
- ===
22
-
23
- This license applies to all parts of uvrb (Ruby FFI bindings for libuv only)
1
+ Copyright (c) 2004-2013 Cotag Media
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is furnished
8
+ to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
20
+
21
+ ===
22
+
23
+ This license applies to all parts of uvrb (Ruby FFI bindings for libuv only)
24
24
  Libuv itself [is using Node license](https://github.com/joyent/libuv/blob/master/LICENSE)
data/README.md CHANGED
@@ -1,88 +1,89 @@
1
- # Libuv FFI bindings for Ruby
2
-
3
- [![Build Status](https://travis-ci.org/cotag/libuv.png?branch=master)](https://travis-ci.org/cotag/libuv)
4
-
5
- [Libuv](https://github.com/joyent/libuv) is a cross platform asynchronous IO implementation that powers NodeJS. It supports sockets, both UDP and TCP, filesystem watch, TTY, Pipes and other asynchronous primitives like timer, check, prepare and idle.
6
-
7
- The Libuv gem contains Libuv and a Ruby wrapper that implements [pipelined promises](http://en.wikipedia.org/wiki/Futures_and_promises#Promise_pipelining) for asynchronous flow control
8
-
9
- ## Usage
10
-
11
- Create a new libuv loop or use a default one
12
-
13
- ```ruby
14
- require 'libuv'
15
-
16
- loop = Libuv::Loop.default
17
- # or
18
- # loop = Libuv::Loop.new
19
-
20
- loop.run do
21
- timer = loop.timer do
22
- puts "5 seconds passed"
23
- timer.close
24
- loop.stop
25
- end
26
- timer.catch do |error|
27
- puts "error with timer: #{error}"
28
- end
29
- timer.finally do
30
- puts "timer handle was closed"
31
- end
32
- timer.start(5000)
33
- end
34
- ```
35
-
36
- Check out the [yard documentation](http://rubydoc.info/gems/libuv/Libuv/Loop)
37
-
38
-
39
- ## Installation
40
-
41
- ```shell
42
- gem install libuv
43
- ```
44
-
45
- or
46
-
47
- ```shell
48
- git clone https://github.com/cotag/libuv.git
49
- cd libuv
50
- bundle install
51
- rake compile
52
- ```
53
-
54
- ### Prerequisites
55
-
56
- * The installation requires __subversion__ to be installed on your system and available on the PATH
57
- * setting the environmental variable `USE_GLOBAL_LIBUV` will prevent compiling the packaged version.
58
- * if you have a compatible `libuv.(so | dylib | dll)` on the PATH already
59
-
60
- Windows users will additionally require:
61
-
62
- - A copy of Visual Studio 2010 or later. [Visual Studio Express](http://www.microsoft.com/visualstudio/eng/products/visual-studio-express-products) works fine.
63
- - A copy of [OpenSSL](http://slproweb.com/products/Win32OpenSSL.html) matching the installed ruby (x86 / x64)
64
- - with the environmental variable `OPENSSL_CONF` Set `OPENSSL_CONF=X:\path_to\OpenSSL\bin\openssl.cfg`
65
- - If using jRuby then [GCC](http://win-builds.org/stable/) is also required
66
- - Setup the paths as described on the gcc page
67
- - Add required environmental variable `set LIBRARY_PATH=X:\win-builds-64\lib;X:\win-builds-64\x86_64-w64-mingw32\lib`
68
-
69
-
70
-
71
- ## Libuv features supported
72
-
73
- * TCP (with TLS support)
74
- * UDP
75
- * TTY
76
- * Pipe
77
- * Timer
78
- * Prepare
79
- * Check
80
- * Idle
81
- * Signals
82
- * Async callbacks
83
- * Async DNS Resolution
84
- * Filesystem Events
85
- * Filesystem manipulation
86
- * File manipulation
87
- * Errors
88
- * Work queue (thread pool)
1
+ # Libuv FFI bindings for Ruby
2
+
3
+ [![Build Status](https://travis-ci.org/cotag/libuv.png?branch=master)](https://travis-ci.org/cotag/libuv)
4
+
5
+ [Libuv](https://github.com/joyent/libuv) is a cross platform asynchronous IO implementation that powers NodeJS. It supports sockets, both UDP and TCP, filesystem watch, TTY, Pipes and other asynchronous primitives like timer, check, prepare and idle.
6
+
7
+ The Libuv gem contains Libuv and a Ruby wrapper that implements [pipelined promises](http://en.wikipedia.org/wiki/Futures_and_promises#Promise_pipelining) for asynchronous flow control
8
+
9
+ ## Usage
10
+
11
+ Create a new libuv loop or use a default one
12
+
13
+ ```ruby
14
+ require 'libuv'
15
+
16
+ loop = Libuv::Loop.default
17
+ # or
18
+ # loop = Libuv::Loop.new
19
+
20
+ loop.run do
21
+ timer = loop.timer do
22
+ puts "5 seconds passed"
23
+ timer.close
24
+ loop.stop
25
+ end
26
+ timer.catch do |error|
27
+ puts "error with timer: #{error}"
28
+ end
29
+ timer.finally do
30
+ puts "timer handle was closed"
31
+ end
32
+ timer.start(5000)
33
+ end
34
+ ```
35
+
36
+ Check out the [yard documentation](http://rubydoc.info/gems/libuv/Libuv/Loop)
37
+
38
+
39
+ ## Installation
40
+
41
+ ```shell
42
+ gem install libuv
43
+ ```
44
+
45
+ or
46
+
47
+ ```shell
48
+ git clone https://github.com/cotag/libuv.git
49
+ cd libuv
50
+ bundle install
51
+ rake compile
52
+ ```
53
+
54
+ ### Prerequisites
55
+
56
+ * The installation requires [subversion](http://subversion.apache.org/packages.html) to be installed on your system and available on the PATH
57
+ * The installation also requires [python 2.x](http://www.python.org/getit/) to be installed and available on the PATH
58
+ * setting the environmental variable `USE_GLOBAL_LIBUV` will prevent compiling the packaged version.
59
+ * if you have a compatible `libuv.(so | dylib | dll)` on the PATH already
60
+
61
+ Windows users will additionally require:
62
+
63
+ - A copy of Visual Studio 2010 or later. [Visual Studio Express](http://www.microsoft.com/visualstudio/eng/products/visual-studio-express-products) works fine.
64
+ - A copy of [OpenSSL](http://slproweb.com/products/Win32OpenSSL.html) matching the installed ruby (x86 / x64)
65
+ - with the environmental variable `OPENSSL_CONF` Set `OPENSSL_CONF=X:\path_to\OpenSSL\bin\openssl.cfg`
66
+ - If using jRuby then [GCC](http://win-builds.org/stable/) is also required
67
+ - Setup the paths as described on the gcc page
68
+ - Add required environmental variable `set LIBRARY_PATH=X:\win-builds-64\lib;X:\win-builds-64\x86_64-w64-mingw32\lib`
69
+
70
+
71
+
72
+ ## Libuv features supported
73
+
74
+ * TCP (with TLS support)
75
+ * UDP
76
+ * TTY
77
+ * Pipes
78
+ * Timer
79
+ * Prepare
80
+ * Check
81
+ * Idle
82
+ * Signals
83
+ * Async callbacks
84
+ * Async DNS Resolution
85
+ * Filesystem Events
86
+ * Filesystem manipulation
87
+ * File manipulation
88
+ * Errors (with a catch-all fallback for anything unhandled on the event loop)
89
+ * Work queue (thread pool)
data/Rakefile CHANGED
@@ -1,31 +1,31 @@
1
- require 'rubygems'
2
- require 'rspec/core/rake_task' # testing framework
3
- require 'yard' # yard documentation
4
- require 'ffi' # loads the extension
5
- require 'rake/clean' # for the :clobber rake task
6
- require File.expand_path('../lib/libuv/ext/tasks', __FILE__) # platform specific rake tasks used by compile
7
-
8
-
9
-
10
- # By default we don't run network tests
11
- task :default => :limited_spec
12
- RSpec::Core::RakeTask.new(:limited_spec) do |t|
13
- # Exclude network tests
14
- t.rspec_opts = "--tag ~network"
15
- end
16
- RSpec::Core::RakeTask.new(:spec)
17
-
18
-
19
- desc "Run all tests"
20
- task :test => [:spec]
21
-
22
-
23
- YARD::Rake::YardocTask.new do |t|
24
- t.files = ['lib/**/*.rb', '-', 'ext/README.md', 'README.md']
25
- end
26
-
27
-
28
- desc "Compile libuv from submodule"
29
- task :compile => ["ext/libuv.#{FFI::Platform::LIBSUFFIX}"]
30
-
31
- CLOBBER.include("ext/libuv.#{FFI::Platform::LIBSUFFIX}")
1
+ require 'rubygems'
2
+ require 'rspec/core/rake_task' # testing framework
3
+ require 'yard' # yard documentation
4
+ require 'ffi' # loads the extension
5
+ require 'rake/clean' # for the :clobber rake task
6
+ require File.expand_path('../lib/libuv/ext/tasks', __FILE__) # platform specific rake tasks used by compile
7
+
8
+
9
+
10
+ # By default we don't run network tests
11
+ task :default => :limited_spec
12
+ RSpec::Core::RakeTask.new(:limited_spec) do |t|
13
+ # Exclude network tests
14
+ t.rspec_opts = "--tag ~network"
15
+ end
16
+ RSpec::Core::RakeTask.new(:spec)
17
+
18
+
19
+ desc "Run all tests"
20
+ task :test => [:spec]
21
+
22
+
23
+ YARD::Rake::YardocTask.new do |t|
24
+ t.files = ['lib/**/*.rb', '-', 'ext/README.md', 'README.md']
25
+ end
26
+
27
+
28
+ desc "Compile libuv from submodule"
29
+ task :compile => ["ext/libuv.#{FFI::Platform::LIBSUFFIX}"]
30
+
31
+ CLOBBER.include("ext/libuv.#{FFI::Platform::LIBSUFFIX}")
data/lib/libuv.rb CHANGED
@@ -1,54 +1,54 @@
1
- require 'forwardable'
2
- require 'ffi'
3
-
4
- module Libuv
5
- require 'libuv/ext/ext' # The libuv ffi ext
6
- require 'libuv/error' # List of errors (matching those in uv.h)
7
- require 'libuv/q' # The promise library
8
-
9
- require 'libuv/mixins/assertions' # Common code to check arguments
10
- require 'libuv/mixins/fs_checks' # Common code to check file system results
11
- require 'libuv/mixins/resource' # Common code to check for errors
12
- require 'libuv/mixins/listener' # Common callback code
13
- require 'libuv/mixins/stream' # For all libuv streams (tcp, pipes, tty)
14
- require 'libuv/mixins/net' # Common functions for tcp and udp
15
-
16
- # -- The classes required for a loop instance --
17
- require 'libuv/handle' # Base class for most libuv functionality
18
- require 'libuv/async' # Provide a threadsafe way to signal the event loop
19
- require 'libuv/timer' # High resolution timer
20
- require 'libuv/loop' # The libuv reactor or event loop
21
- # --
22
-
23
- require 'libuv/filesystem' # Async directory manipulation
24
- require 'libuv/fs_event' # Notifies of changes to files and folders as they occur
25
- require 'libuv/prepare' # Called at the end of a loop cycle
26
- require 'libuv/signal' # Used to handle OS signals
27
- require 'libuv/check' # Called before processing events on the loop
28
- require 'libuv/file' # Async file reading and writing
29
- require 'libuv/idle' # Called when there are no events to process
30
- require 'libuv/work' # Provide work to be completed on another thread (thread pool)
31
- require 'libuv/udp' # Communicate over UDP
32
- require 'libuv/dns' # Async DNS lookup
33
-
34
- # Streams
35
- require 'libuv/pipe' # Communicate over Pipes
36
- require 'libuv/tcp' # Communicate over TCP
37
- require 'libuv/tty' # Terminal output
38
-
39
-
40
- # Returns the number of CPU cores on the host platform
41
- #
42
- # @return [Fixnum, nil] representing the number of CPU cores or nil if failed
43
- def self.cpu_count
44
- cpu_info = FFI::MemoryPointer.new(:pointer)
45
- cpu_count = FFI::MemoryPointer.new(:int)
46
- if ::Libuv::Ext.cpu_info(cpu_info, cpu_count) >= 0
47
- count = cpu_count.read_int
48
- ::Libuv::Ext.free_cpu_info(cpu_info.read_pointer, count)
49
- return count
50
- else
51
- return nil
52
- end
53
- end
54
- end
1
+ require 'forwardable'
2
+ require 'ffi'
3
+
4
+ module Libuv
5
+ require 'libuv/ext/ext' # The libuv ffi ext
6
+ require 'libuv/error' # List of errors (matching those in uv.h)
7
+ require 'libuv/q' # The promise library
8
+
9
+ require 'libuv/mixins/assertions' # Common code to check arguments
10
+ require 'libuv/mixins/fs_checks' # Common code to check file system results
11
+ require 'libuv/mixins/resource' # Common code to check for errors
12
+ require 'libuv/mixins/listener' # Common callback code
13
+ require 'libuv/mixins/stream' # For all libuv streams (tcp, pipes, tty)
14
+ require 'libuv/mixins/net' # Common functions for tcp and udp
15
+
16
+ # -- The classes required for a loop instance --
17
+ require 'libuv/handle' # Base class for most libuv functionality
18
+ require 'libuv/async' # Provide a threadsafe way to signal the event loop
19
+ require 'libuv/timer' # High resolution timer
20
+ require 'libuv/loop' # The libuv reactor or event loop
21
+ # --
22
+
23
+ require 'libuv/filesystem' # Async directory manipulation
24
+ require 'libuv/fs_event' # Notifies of changes to files and folders as they occur
25
+ require 'libuv/prepare' # Called at the end of a loop cycle
26
+ require 'libuv/signal' # Used to handle OS signals
27
+ require 'libuv/check' # Called before processing events on the loop
28
+ require 'libuv/file' # Async file reading and writing
29
+ require 'libuv/idle' # Called when there are no events to process
30
+ require 'libuv/work' # Provide work to be completed on another thread (thread pool)
31
+ require 'libuv/udp' # Communicate over UDP
32
+ require 'libuv/dns' # Async DNS lookup
33
+
34
+ # Streams
35
+ require 'libuv/pipe' # Communicate over Pipes
36
+ require 'libuv/tcp' # Communicate over TCP
37
+ require 'libuv/tty' # Terminal output
38
+
39
+
40
+ # Returns the number of CPU cores on the host platform
41
+ #
42
+ # @return [Fixnum, nil] representing the number of CPU cores or nil if failed
43
+ def self.cpu_count
44
+ cpu_info = FFI::MemoryPointer.new(:pointer)
45
+ cpu_count = FFI::MemoryPointer.new(:int)
46
+ if ::Libuv::Ext.cpu_info(cpu_info, cpu_count) >= 0
47
+ count = cpu_count.read_int
48
+ ::Libuv::Ext.free_cpu_info(cpu_info.read_pointer, count)
49
+ return count
50
+ else
51
+ return nil
52
+ end
53
+ end
54
+ end