libuv 0.11.4 → 0.11.5

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 +6 -14
  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 +82 -82
  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 +73 -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 +29 -29
  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 +11 -11
  24. data/lib/libuv/ext/types.rb +238 -238
  25. data/lib/libuv/file.rb +191 -191
  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 +387 -387
  31. data/lib/libuv/mixins/assertions.rb +23 -23
  32. data/lib/libuv/mixins/fs_checks.rb +55 -55
  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 +197 -197
  38. data/lib/libuv/prepare.rb +56 -56
  39. data/lib/libuv/signal.rb +51 -51
  40. data/lib/libuv/tcp.rb +317 -317
  41. data/lib/libuv/timer.rb +91 -91
  42. data/lib/libuv/tty.rb +37 -37
  43. data/lib/libuv/udp.rb +224 -224
  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 +124 -124
  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 +29 -21
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- NzZkMjI0Mjc4OGZiNDYzYzk2NTk0OWFlNWQ4YjE1ODI2NjY2MDJiMA==
5
- data.tar.gz: !binary |-
6
- Zjk3OGQ3NWVjYTM4NDU1ZmNhYjAyMzViYTE3NDI5NzY1NDIwODdhNQ==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- NmM3NTBhYzQwNTMwZGY1YjFhY2UzMzUxZmE0ZDUwZmMwMGRmZDRiYmFiYjlk
10
- NjQ3OGFjZjdhMDlhYzg2MGFmZjgyYzdmOWM3Nzc2ZjE1OTk5NDM3Mzc5NGY2
11
- ZDQxNDJmM2I0Y2ZlZTdiZjMxNjAwZDA4OGIxN2FmMmYzMzk3NTE=
12
- data.tar.gz: !binary |-
13
- OTVhYWVjY2IwOTkyNzIyMGNiODQ2MWMyM2JjNTY5ZmFmODJjYmRjZjE1OTBk
14
- YjJiOGVlNGI5ZjVkYjY0MTNhYWRmNjgyN2ZjN2FjN2JhZGMzN2E4ZWNhYzk3
15
- OTQyOGE2NmVjMTM4YjU1NzdiOGEyZWViNWI4MTA1YjZjMTkxZjQ=
2
+ SHA1:
3
+ metadata.gz: d4e11f7fcf587f1e694af11c237d10a82c769d47
4
+ data.tar.gz: e46f16bebd08eafedf2405ba99138f83ce7d2dd0
5
+ SHA512:
6
+ metadata.gz: 31f35fd8db2074335806a81de50071d56c0671d0166a340ea5b13e52e936085ea739c1e0c6c13a2d62f56b98986937afdb07bf0dbca8d430c1f17ecdcd9dfa7a
7
+ data.tar.gz: 1ee9b1f2352ea42170bd0cda515c172be8c8aaa06c444763de54c50648868e4d2ec27508321ea9fbb1315acdbd5a7d17750faa024bd99796f932fd642bf67d23
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/*
@@ -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
@@ -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,82 +1,82 @@
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
- * Windows users will require a copy of Visual Studio 2010 or later. [Visual Studio Express](http://www.microsoft.com/visualstudio/eng/products/visual-studio-express-products) works fine.
58
-
59
- or
60
-
61
- * setting the environmental variable `USE_GLOBAL_LIBUV` will prevent compiling the packaged version.
62
- * if you have a compatible `libuv.(so | dylib | dll)` on the PATH already
63
-
64
-
65
- ## Libuv features supported
66
-
67
- * TCP (with TLS support)
68
- * UDP
69
- * TTY
70
- * Pipe
71
- * Timer
72
- * Prepare
73
- * Check
74
- * Idle
75
- * Signals
76
- * Async callbacks
77
- * Async DNS Resolution
78
- * Filesystem Events
79
- * Filesystem manipulation
80
- * File manipulation
81
- * Errors
82
- * 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__ to be installed on your system and available on the PATH
57
+ * Windows users will require a copy of Visual Studio 2010 or later. [Visual Studio Express](http://www.microsoft.com/visualstudio/eng/products/visual-studio-express-products) works fine.
58
+
59
+ or
60
+
61
+ * setting the environmental variable `USE_GLOBAL_LIBUV` will prevent compiling the packaged version.
62
+ * if you have a compatible `libuv.(so | dylib | dll)` on the PATH already
63
+
64
+
65
+ ## Libuv features supported
66
+
67
+ * TCP (with TLS support)
68
+ * UDP
69
+ * TTY
70
+ * Pipe
71
+ * Timer
72
+ * Prepare
73
+ * Check
74
+ * Idle
75
+ * Signals
76
+ * Async callbacks
77
+ * Async DNS Resolution
78
+ * Filesystem Events
79
+ * Filesystem manipulation
80
+ * File manipulation
81
+ * Errors
82
+ * 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}")
@@ -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