rb-kqueue 0.2.5 → 0.2.6
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 +5 -5
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/lib/rb-kqueue/event.rb +10 -1
- data/lib/rb-kqueue/native/flags.rb +43 -39
- data/lib/rb-kqueue/queue.rb +7 -1
- data/lib/rb-kqueue/version.rb +1 -1
- data/rb-kqueue.gemspec +2 -10
- data/spec/kqueue_queue_spec.rb +7 -7
- metadata +8 -8
- data/VERSION +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0f24844743c7766edc2ddfa6c7c125a5ff7419eac128d6695fcb8da70c07d66b
|
4
|
+
data.tar.gz: '008dd0f2124471e3a190cb80458774076d6ed5f1cbba1dc020f8e6a0f3250eb8'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d86c4ef6d17773c5ca1b6567ea9be15b7c2b179bac98253d7c2d230dea89d6ba8c0c20badd335e3944843eb1902b077fb0690eb392ba0b6cf357c8362521676d
|
7
|
+
data.tar.gz: bbdde67f0d98268d46c7b4c8a13fe0497a017671efdfbab0c7754f577c2a58aa4e8397603f033ad316fb4f28633a6fe78e1ee21c1e3bb71c2c62fc4b6ba0fa7b
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rb-kqueue
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.6.5
|
data/lib/rb-kqueue/event.rb
CHANGED
@@ -3,6 +3,11 @@ module KQueue
|
|
3
3
|
# Each {Watcher} can fire many events,
|
4
4
|
# which are passed to that Watcher's callback.
|
5
5
|
class Event
|
6
|
+
|
7
|
+
# Exception raised on an attempt to construct an {Event}
|
8
|
+
# from a native event with unexpected field values.
|
9
|
+
class UnexpectedEvent < Exception; end
|
10
|
+
|
6
11
|
# Some integer data, the interpretation of which
|
7
12
|
# is specific to each individual {Watcher}.
|
8
13
|
# For specifics, see the individual Watcher subclasses.
|
@@ -64,7 +69,11 @@ module KQueue
|
|
64
69
|
@native = native
|
65
70
|
@queue = queue
|
66
71
|
@data = @native[:data]
|
67
|
-
|
72
|
+
begin
|
73
|
+
@filter = KQueue::Native::Flags.from_flag("EVFILT", @native[:filter])
|
74
|
+
rescue Native::Flags::FlagNotFound
|
75
|
+
raise UnexpectedEvent
|
76
|
+
end
|
68
77
|
@flags = Native::Flags.from_mask("EV", @native[:flags])
|
69
78
|
|
70
79
|
KQueue.handle_error @native[:data] if @flags.include?(:error)
|
@@ -7,48 +7,48 @@ module KQueue
|
|
7
7
|
module Flags
|
8
8
|
# Filters
|
9
9
|
if FFI::Platform::IS_FREEBSD
|
10
|
-
EVFILT_READ
|
11
|
-
EVFILT_WRITE
|
12
|
-
EVFILT_AIO
|
13
|
-
EVFILT_VNODE
|
14
|
-
EVFILT_PROC
|
15
|
-
EVFILT_SIGNAL
|
16
|
-
EVFILT_TIMER
|
17
|
-
EVFILT_PROCDESC
|
18
|
-
EVFILT_FS
|
19
|
-
EVFILT_LIO
|
20
|
-
EVFILT_USER
|
21
|
-
EVFILT_SENDFILE
|
22
|
-
EVFILT_SYSCOUNT
|
10
|
+
EVFILT_READ = -1
|
11
|
+
EVFILT_WRITE = -2
|
12
|
+
EVFILT_AIO = -3 # Attached to aio requests
|
13
|
+
EVFILT_VNODE = -4 # Attached to vnodes
|
14
|
+
EVFILT_PROC = -5 # Attached to struct proc
|
15
|
+
EVFILT_SIGNAL = -6 # Attached to struct proc
|
16
|
+
EVFILT_TIMER = -7 # Timers
|
17
|
+
EVFILT_PROCDESC = -8 # Attached to process descriptors
|
18
|
+
EVFILT_FS = -9 # Filesystem events
|
19
|
+
EVFILT_LIO = -10 # Attached to lio requests
|
20
|
+
EVFILT_USER = -11 # User events
|
21
|
+
EVFILT_SENDFILE = -12 # Attached to sendfile requests
|
22
|
+
EVFILT_SYSCOUNT = 12
|
23
23
|
elsif FFI::Platform::IS_NETBSD
|
24
|
-
EVFILT_READ
|
25
|
-
EVFILT_WRITE
|
26
|
-
EVFILT_AIO
|
27
|
-
EVFILT_VNODE
|
28
|
-
EVFILT_PROC
|
29
|
-
EVFILT_SIGNAL
|
30
|
-
EVFILT_TIMER
|
31
|
-
EVFILT_SYSCOUNT
|
24
|
+
EVFILT_READ = 0
|
25
|
+
EVFILT_WRITE = 1
|
26
|
+
EVFILT_AIO = 2 # Attached to aio requests
|
27
|
+
EVFILT_VNODE = 3 # Attached to vnodes
|
28
|
+
EVFILT_PROC = 4 # Attached to struct proc
|
29
|
+
EVFILT_SIGNAL = 5 # Attached to struct proc
|
30
|
+
EVFILT_TIMER = 6 # Arbitrary timer (in ms)
|
31
|
+
EVFILT_SYSCOUNT = 7 # Number of filters
|
32
32
|
elsif FFI::Platform::IS_OPENBSD
|
33
|
-
EVFILT_READ
|
34
|
-
EVFILT_WRITE
|
35
|
-
EVFILT_AIO
|
36
|
-
EVFILT_VNODE
|
37
|
-
EVFILT_PROC
|
38
|
-
EVFILT_SIGNAL
|
39
|
-
EVFILT_TIMER
|
33
|
+
EVFILT_READ = -1
|
34
|
+
EVFILT_WRITE = -2
|
35
|
+
EVFILT_AIO = -3 # Attached to aio requests
|
36
|
+
EVFILT_VNODE = -4 # Attached to vnodes
|
37
|
+
EVFILT_PROC = -5 # Attached to struct proc
|
38
|
+
EVFILT_SIGNAL = -6 # Attached to struct proc
|
39
|
+
EVFILT_TIMER = -7 # Timers
|
40
40
|
else
|
41
|
-
EVFILT_READ
|
42
|
-
EVFILT_WRITE
|
43
|
-
EVFILT_AIO
|
44
|
-
EVFILT_VNODE
|
45
|
-
EVFILT_PROC
|
46
|
-
EVFILT_SIGNAL
|
47
|
-
EVFILT_TIMER
|
48
|
-
EVFILT_MACHPORT
|
49
|
-
EVFILT_FS
|
50
|
-
EVFILT_USER
|
51
|
-
EVFILT_SESSION
|
41
|
+
EVFILT_READ = -1
|
42
|
+
EVFILT_WRITE = -2
|
43
|
+
EVFILT_AIO = -3 # Attached to aio requests
|
44
|
+
EVFILT_VNODE = -4 # Attached to vnodes
|
45
|
+
EVFILT_PROC = -5 # Attached to struct proc
|
46
|
+
EVFILT_SIGNAL = -6 # Attached to struct proc
|
47
|
+
EVFILT_TIMER = -7 # Timers
|
48
|
+
EVFILT_MACHPORT = -8 # Mach portsets
|
49
|
+
EVFILT_FS = -9 # Filesystem events
|
50
|
+
EVFILT_USER = -10 # User events
|
51
|
+
EVFILT_SESSION = -11 # Audit session events
|
52
52
|
end
|
53
53
|
|
54
54
|
|
@@ -97,6 +97,9 @@ module KQueue
|
|
97
97
|
NOTE_TIMER_NSECONDS = 0x00000004 # data is nanoseconds
|
98
98
|
NOTE_TIMER_ABSOLUTE = 0x00000008 # absolute timeout
|
99
99
|
|
100
|
+
# Exception raised when a function fails to find a flag satisfying
|
101
|
+
# its given query.
|
102
|
+
class FlagNotFound < Exception; end
|
100
103
|
|
101
104
|
# Converts a list of flags to the bitmask that the C API expects.
|
102
105
|
#
|
@@ -143,6 +146,7 @@ module KQueue
|
|
143
146
|
next unless c =~ re
|
144
147
|
return c.to_s.sub("#{prefix}_", "").downcase.to_sym if const_get(c) == flag
|
145
148
|
end
|
149
|
+
raise FlagNotFound
|
146
150
|
end
|
147
151
|
end
|
148
152
|
end
|
data/lib/rb-kqueue/queue.rb
CHANGED
@@ -359,7 +359,13 @@ module KQueue
|
|
359
359
|
res = Native.kevent(@fd, nil, 0, eventlist, size, timeout)
|
360
360
|
|
361
361
|
KQueue.handle_error if res < 0
|
362
|
-
(0...res).map
|
362
|
+
(0...res).map do |i|
|
363
|
+
begin
|
364
|
+
KQueue::Event.new(Native::KEvent.new(eventlist[i]), self)
|
365
|
+
rescue KQueue::Event::UnexpectedEvent
|
366
|
+
nil
|
367
|
+
end
|
368
|
+
end.compact
|
363
369
|
end
|
364
370
|
end
|
365
371
|
end
|
data/lib/rb-kqueue/version.rb
CHANGED
data/rb-kqueue.gemspec
CHANGED
@@ -1,8 +1,3 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
1
|
require File.expand_path('../lib/rb-kqueue/version', __FILE__)
|
7
2
|
|
8
3
|
Gem::Specification.new do |gem|
|
@@ -11,23 +6,20 @@ Gem::Specification.new do |gem|
|
|
11
6
|
|
12
7
|
gem.authors = ["Mathieu Arnold", "Nathan Weizenbaum"]
|
13
8
|
gem.email = %q{mat@mat.cc nex342@gmail.com}
|
14
|
-
gem.date = %q{2017-05-16}
|
15
9
|
gem.description = %q{A Ruby wrapper for BSD's kqueue, using FFI}
|
16
10
|
gem.extra_rdoc_files = %w(README.md)
|
17
11
|
gem.licenses = ['MIT']
|
18
12
|
|
19
13
|
gem.files = `git ls-files`.split(/\n/)
|
20
|
-
gem.executables
|
21
|
-
gem.test_files
|
14
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
15
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
22
16
|
|
23
17
|
gem.homepage = %q{http://github.com/mat813/rb-kqueue}
|
24
18
|
gem.rdoc_options = ["--charset=UTF-8"]
|
25
19
|
gem.require_paths = ["lib"]
|
26
|
-
gem.rubygems_version = %q{1.3.5}
|
27
20
|
gem.summary = %q{A Ruby wrapper for BSD's kqueue, using FFI}
|
28
21
|
|
29
22
|
gem.add_runtime_dependency(%q<ffi>, [">= 0.5.0"])
|
30
23
|
gem.add_development_dependency(%q<yard>, [">= 0.4.0"])
|
31
24
|
gem.add_development_dependency(%q<rspec>, [">= 3.3.0"])
|
32
25
|
end
|
33
|
-
|
data/spec/kqueue_queue_spec.rb
CHANGED
@@ -10,16 +10,16 @@ RSpec.describe KQueue::Queue do
|
|
10
10
|
|
11
11
|
context 'file is watched for writes' do
|
12
12
|
before do
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
queue.watch_file file.path, :write do
|
14
|
+
file_touched = !file_touched
|
15
|
+
end
|
16
|
+
queue.process
|
17
17
|
end
|
18
18
|
|
19
19
|
context 'file is written to' do
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
it 'executes the defined block' do
|
21
|
+
expect { file.write 'test' }.to change { file_touched }.from(false).to true
|
22
|
+
end
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rb-kqueue
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mathieu Arnold
|
8
8
|
- Nathan Weizenbaum
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-04-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ffi
|
@@ -62,12 +62,13 @@ extra_rdoc_files:
|
|
62
62
|
files:
|
63
63
|
- ".gitignore"
|
64
64
|
- ".rspec"
|
65
|
+
- ".ruby-gemset"
|
66
|
+
- ".ruby-version"
|
65
67
|
- ".yardopts"
|
66
68
|
- Gemfile
|
67
69
|
- MIT-LICENSE
|
68
70
|
- README.md
|
69
71
|
- Rakefile
|
70
|
-
- VERSION
|
71
72
|
- lib/rb-kqueue.rb
|
72
73
|
- lib/rb-kqueue/event.rb
|
73
74
|
- lib/rb-kqueue/native.rb
|
@@ -88,7 +89,7 @@ homepage: http://github.com/mat813/rb-kqueue
|
|
88
89
|
licenses:
|
89
90
|
- MIT
|
90
91
|
metadata: {}
|
91
|
-
post_install_message:
|
92
|
+
post_install_message:
|
92
93
|
rdoc_options:
|
93
94
|
- "--charset=UTF-8"
|
94
95
|
require_paths:
|
@@ -104,9 +105,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
105
|
- !ruby/object:Gem::Version
|
105
106
|
version: '0'
|
106
107
|
requirements: []
|
107
|
-
|
108
|
-
|
109
|
-
signing_key:
|
108
|
+
rubygems_version: 3.0.9
|
109
|
+
signing_key:
|
110
110
|
specification_version: 4
|
111
111
|
summary: A Ruby wrapper for BSD's kqueue, using FFI
|
112
112
|
test_files:
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.1.0
|