posix_mq 0.5.1 → 0.6.0

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.
data/lib/posix_mq.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  # -*- encoding: binary -*-
2
2
  class POSIX_MQ
3
3
 
4
- # version of POSIX_MQ, currently 0.5.1
5
- VERSION = '0.5.1'
4
+ # version of POSIX_MQ, currently 0.6.0
5
+ VERSION = '0.6.0'
6
6
 
7
7
  # An analogous Struct to "struct mq_attr" in C.
8
8
  # This may be used in arguments for POSIX_MQ.new and
data/posix_mq.gemspec CHANGED
@@ -1,39 +1,28 @@
1
1
  # -*- encoding: binary -*-
2
-
3
2
  ENV["VERSION"] or abort "VERSION= must be specified"
4
3
  manifest = File.readlines('.manifest').map! { |x| x.chomp! }
5
- test_files = manifest.grep(%r{\Atest/test_.*\.rb\z})
4
+ require 'wrongdoc'
5
+ extend Wrongdoc::Gemspec
6
+ name, summary, title = readme_metadata
6
7
 
7
8
  Gem::Specification.new do |s|
8
9
  s.name = %q{posix_mq}
9
- s.version = ENV["VERSION"]
10
-
10
+ s.version = ENV["VERSION"].dup
11
11
  s.authors = ["Ruby POSIX MQ hackers"]
12
12
  s.date = Time.now.utc.strftime('%Y-%m-%d')
13
- s.description = File.read("README").split(/\n\n/)[1]
13
+ s.description = readme_description
14
14
  s.email = %q{ruby.posix.mq@librelist.com}
15
15
  s.executables = %w(posix-mq-rb)
16
16
  s.extensions = %w(ext/posix_mq/extconf.rb)
17
-
18
- s.extra_rdoc_files = File.readlines('.document').map! do |x|
19
- x.chomp!
20
- if File.directory?(x)
21
- manifest.grep(%r{\A#{x}/})
22
- elsif File.file?(x)
23
- x
24
- else
25
- nil
26
- end
27
- end.flatten.compact
28
-
17
+ s.extra_rdoc_files = extra_rdoc_files(manifest)
29
18
  s.files = manifest
30
- s.homepage = %q{http://bogomips.org/ruby_posix_mq/}
31
- s.summary = %q{POSIX Message Queues for Ruby}
32
- s.rdoc_options = [ "-Na", "-t", "posix_mq - #{s.summary}" ]
19
+ s.homepage = Wrongdoc.config[:rdoc_url]
20
+ s.summary = summary
21
+ s.rdoc_options = rdoc_options
33
22
  s.require_paths = %w(lib)
34
23
  s.rubyforge_project = %q{qrp}
35
-
36
- s.test_files = test_files
24
+ s.test_files = manifest.grep(%r{\Atest/test_.*\.rb\z})
25
+ s.add_development_dependency(%q<wrongdoc>, "~> 1.0")
37
26
 
38
27
  # s.licenses = %w(LGPLv3) # accessor not compatible with older RubyGems
39
28
  end
@@ -3,15 +3,13 @@ require 'test/unit'
3
3
  require 'posix_mq'
4
4
  require 'thread'
5
5
  require 'fcntl'
6
- require 'set'
7
6
  $stderr.sync = $stdout.sync = true
8
7
 
9
8
  class Test_POSIX_MQ < Test::Unit::TestCase
10
- METHODS = Set.new(POSIX_MQ.instance_methods.map { |x| x.to_sym })
11
9
 
12
- METHODS.include?(:to_io) or
10
+ POSIX_MQ.method_defined?(:to_io) or
13
11
  warn "POSIX_MQ#to_io not supported on this platform: #{RUBY_PLATFORM}"
14
- METHODS.include?(:notify) or
12
+ POSIX_MQ.method_defined?(:notify) or
15
13
  warn "POSIX_MQ#notify not supported on this platform: #{RUBY_PLATFORM}"
16
14
 
17
15
  def setup
@@ -27,6 +25,13 @@ class Test_POSIX_MQ < Test::Unit::TestCase
27
25
  assert @mq.closed?
28
26
  end
29
27
 
28
+ def test_gc
29
+ assert_nothing_raised do
30
+ 2025.times { POSIX_MQ.new(@path, :rw) }
31
+ 2025.times { @mq = POSIX_MQ.new(@path, :rw); @mq.to_io }
32
+ end
33
+ end unless defined?RUBY_ENGINE && RUBY_ENGINE == "rbx"
34
+
30
35
  def test_name_clobber_proof
31
36
  @mq = POSIX_MQ.new(@path, :rw)
32
37
  tmp = @mq.name
@@ -44,14 +49,40 @@ class Test_POSIX_MQ < Test::Unit::TestCase
44
49
  assert_equal @mq.object_id, clone.object_id
45
50
  end
46
51
 
47
- def test_timed_receive
52
+ def test_timed_receive_float
48
53
  interval = 0.01
49
54
  @mq = POSIX_MQ.new(@path, :rw)
50
55
  assert ! @mq.nonblock?
51
56
  t0 = Time.now
52
57
  assert_raises(Errno::ETIMEDOUT) { @mq.receive "", interval }
53
58
  elapsed = Time.now - t0
54
- assert elapsed > interval
59
+ assert elapsed > interval, elapsed.inspect
60
+ assert elapsed < 0.02, elapsed.inspect
61
+ end
62
+
63
+ def test_timed_receive_divmod
64
+ interval = Object.new
65
+ def interval.divmod(num)
66
+ num == 1 ? [ 0, 0.01 ] : nil
67
+ end
68
+ @mq = POSIX_MQ.new(@path, :rw)
69
+ assert ! @mq.nonblock?
70
+ t0 = Time.now
71
+ assert_raises(Errno::ETIMEDOUT) { @mq.receive "", interval }
72
+ elapsed = Time.now - t0
73
+ assert elapsed >= 0.01, elapsed.inspect
74
+ assert elapsed <= 0.02, elapsed.inspect
75
+ end
76
+
77
+ def test_timed_receive_fixnum
78
+ interval = 1
79
+ @mq = POSIX_MQ.new(@path, :rw)
80
+ assert ! @mq.nonblock?
81
+ t0 = Time.now
82
+ assert_raises(Errno::ETIMEDOUT) { @mq.receive "", interval }
83
+ elapsed = Time.now - t0
84
+ assert elapsed >= interval, elapsed.inspect
85
+ assert elapsed < 1.10, elapsed.inspect
55
86
  end
56
87
 
57
88
  def test_timed_send
@@ -155,7 +186,7 @@ class Test_POSIX_MQ < Test::Unit::TestCase
155
186
  @mq = POSIX_MQ.new @path, IO::CREAT|IO::RDWR, 0666
156
187
  assert @mq.to_io.kind_of?(IO)
157
188
  assert_nothing_raised { IO.select([@mq], nil, nil, 0) }
158
- end if METHODS.include?(:to_io)
189
+ end if POSIX_MQ.method_defined?(:to_io)
159
190
 
160
191
  def test_notify
161
192
  rd, wr = IO.pipe
@@ -224,7 +255,7 @@ class Test_POSIX_MQ < Test::Unit::TestCase
224
255
  def test_new_sym_w
225
256
  @mq = POSIX_MQ.new @path, :w
226
257
  assert_equal IO::WRONLY, @mq.to_io.fcntl(Fcntl::F_GETFL)
227
- end if METHODS.include?(:to_io)
258
+ end if POSIX_MQ.method_defined?(:to_io)
228
259
 
229
260
  def test_new_sym_r
230
261
  @mq = POSIX_MQ.new @path, :w
@@ -232,7 +263,7 @@ class Test_POSIX_MQ < Test::Unit::TestCase
232
263
  assert_nothing_raised { mq = POSIX_MQ.new @path, :r }
233
264
  assert_equal IO::RDONLY, mq.to_io.fcntl(Fcntl::F_GETFL)
234
265
  assert_nil mq.close
235
- end if METHODS.include?(:to_io)
266
+ end if POSIX_MQ.method_defined?(:to_io)
236
267
 
237
268
  def test_new_path_only
238
269
  @mq = POSIX_MQ.new @path, :w
@@ -240,12 +271,12 @@ class Test_POSIX_MQ < Test::Unit::TestCase
240
271
  assert_nothing_raised { mq = POSIX_MQ.new @path }
241
272
  assert_equal IO::RDONLY, mq.to_io.fcntl(Fcntl::F_GETFL)
242
273
  assert_nil mq.close
243
- end if METHODS.include?(:to_io)
274
+ end if POSIX_MQ.method_defined?(:to_io)
244
275
 
245
276
  def test_new_sym_wr
246
277
  @mq = POSIX_MQ.new @path, :rw
247
278
  assert_equal IO::RDWR, @mq.to_io.fcntl(Fcntl::F_GETFL)
248
- end if METHODS.include?(:to_io)
279
+ end if POSIX_MQ.method_defined?(:to_io)
249
280
 
250
281
  def test_new_attr
251
282
  mq_attr = POSIX_MQ::Attr.new(IO::NONBLOCK, 1, 1, 0)
@@ -280,7 +311,7 @@ class Test_POSIX_MQ < Test::Unit::TestCase
280
311
  assert_nothing_raised { @mq.notify { |mq| q << "hi" } }
281
312
  assert_nothing_raised { Process.waitpid2(fork { @mq << "bye" }) }
282
313
  assert_equal "hi", q.pop
283
- end if METHODS.include?(:notify)
314
+ end if POSIX_MQ.method_defined?(:notify)
284
315
 
285
316
  def test_notify_thread
286
317
  q = Queue.new
@@ -290,5 +321,19 @@ class Test_POSIX_MQ < Test::Unit::TestCase
290
321
  x = q.pop
291
322
  assert x.instance_of?(Thread)
292
323
  assert Thread.current != x
293
- end if METHODS.include?(:notify)
324
+ end if POSIX_MQ.method_defined?(:notify)
325
+
326
+ def test_bad_open_mode
327
+ assert_raises(ArgumentError) { mq = POSIX_MQ.new(@path, "rw") }
328
+ end
329
+
330
+ def test_bad_open_attr
331
+ assert_raises(TypeError) { POSIX_MQ.new(@path, :rw, 0666, [0, 1, 1, 0]) }
332
+ end
333
+
334
+ def test_bad_setattr
335
+ @mq = POSIX_MQ.new @path, IO::CREAT|IO::WRONLY, 0666
336
+ assert_raises(TypeError) { @mq.attr = {} }
337
+ assert_raises(TypeError) { @mq.attr = Struct.new(:a,:b,:c,:d).new }
338
+ end
294
339
  end
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: posix_mq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ hash: 7
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 6
9
+ - 0
10
+ version: 0.6.0
5
11
  platform: ruby
6
12
  authors:
7
13
  - Ruby POSIX MQ hackers
@@ -9,10 +15,24 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2010-05-09 00:00:00 +00:00
18
+ date: 2010-12-25 00:00:00 +00:00
13
19
  default_executable:
14
- dependencies: []
15
-
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: wrongdoc
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 15
30
+ segments:
31
+ - 1
32
+ - 0
33
+ version: "1.0"
34
+ type: :development
35
+ version_requirements: *id001
16
36
  description: |-
17
37
  POSIX message queues allow local processes to exchange data in the form
18
38
  of messages. This API is distinct from that provided by System V
@@ -29,10 +49,12 @@ extra_rdoc_files:
29
49
  - ChangeLog
30
50
  - lib/posix_mq.rb
31
51
  - ext/posix_mq/posix_mq.c
52
+ - LATEST
32
53
  files:
33
54
  - .document
34
55
  - .gitignore
35
56
  - .manifest
57
+ - .wrongdoc.yml
36
58
  - COPYING
37
59
  - ChangeLog
38
60
  - Documentation/.gitignore
@@ -41,6 +63,7 @@ files:
41
63
  - GIT-VERSION-FILE
42
64
  - GIT-VERSION-GEN
43
65
  - GNUmakefile
66
+ - LATEST
44
67
  - LICENSE
45
68
  - NEWS
46
69
  - README
@@ -49,7 +72,6 @@ files:
49
72
  - ext/posix_mq/extconf.rb
50
73
  - ext/posix_mq/posix_mq.c
51
74
  - lib/posix_mq.rb
52
- - local.mk.sample
53
75
  - man/man1/posix-mq-rb.1
54
76
  - posix_mq.gemspec
55
77
  - setup.rb
@@ -60,27 +82,34 @@ licenses: []
60
82
 
61
83
  post_install_message:
62
84
  rdoc_options:
63
- - -Na
64
85
  - -t
65
86
  - posix_mq - POSIX Message Queues for Ruby
87
+ - -W
88
+ - http://git.bogomips.org/cgit/ruby_posix_mq.git/tree/%s
66
89
  require_paths:
67
90
  - lib
68
91
  required_ruby_version: !ruby/object:Gem::Requirement
92
+ none: false
69
93
  requirements:
70
94
  - - ">="
71
95
  - !ruby/object:Gem::Version
96
+ hash: 3
97
+ segments:
98
+ - 0
72
99
  version: "0"
73
- version:
74
100
  required_rubygems_version: !ruby/object:Gem::Requirement
101
+ none: false
75
102
  requirements:
76
103
  - - ">="
77
104
  - !ruby/object:Gem::Version
105
+ hash: 3
106
+ segments:
107
+ - 0
78
108
  version: "0"
79
- version:
80
109
  requirements: []
81
110
 
82
111
  rubyforge_project: qrp
83
- rubygems_version: 1.3.5
112
+ rubygems_version: 1.3.7
84
113
  signing_key:
85
114
  specification_version: 3
86
115
  summary: POSIX Message Queues for Ruby
data/local.mk.sample DELETED
@@ -1,70 +0,0 @@
1
- # this is a sample local.mk file, feel free to modify it for your needs
2
- # GNUmakefile will source local.mk in the top-level source tree
3
- # if it is present.
4
- #
5
- # This is depends on a bunch of GNU-isms from bash, touch.
6
-
7
- RSYNC = rsync
8
- DLEXT := so
9
- gems :=
10
-
11
- # Avoid loading rubygems to speed up tests because gmake is
12
- # fork+exec heavy with Ruby.
13
- prefix = $(HOME)
14
- ifeq ($(r19),)
15
- RUBY := $(prefix)/bin/ruby
16
- gem_paths := $(addprefix $(prefix)/lib/ruby/gems/1.8/gems/,$(gems))
17
- else
18
- prefix := $(prefix)/ruby-1.9
19
- export PATH := $(prefix)/bin:$(PATH)
20
- RUBY := $(prefix)/bin/ruby --disable-gems
21
- gem_paths := $(addprefix $(prefix)/lib/ruby/gems/1.9.1/gems/,$(gems))
22
- endif
23
-
24
- ifdef gem_paths
25
- sp :=
26
- sp +=
27
- export RUBYLIB := $(subst $(sp),:,$(addsuffix /lib,$(gem_paths)))
28
- endif
29
-
30
- # pipefail is THE reason to use bash (v3+) or never revisions of ksh93
31
- # SHELL := /bin/bash -e -o pipefail
32
- SHELL := /bin/ksh93 -e -o pipefail
33
-
34
- # trace execution of tests
35
- # TRACER = strace -f -o $(t_pfx).strace -s 100000
36
- TRACER = /usr/bin/time -v -o $(t_pfx).time
37
-
38
- full-test: test-18 test-19
39
- test-18:
40
- $(MAKE) test 2>&1 | sed -e 's!^!1.8 !'
41
- test-19:
42
- $(MAKE) test r19=t 2>&1 | sed -e 's!^!1.9 !'
43
-
44
- latest: NEWS
45
- @awk 'BEGIN{RS="=== ";ORS=""}NR==2{sub(/\n$$/,"");print RS""$$0 }' $<
46
-
47
- # publishes docs to http://bogomips.org/ruby_posix_mq/
48
- publish_doc:
49
- -git set-file-times
50
- $(RM) -r doc ChangeLog NEWS
51
- $(MAKE) doc LOG_VERSION=$(shell git tag -l | tail -1)
52
- $(MAKE) -s latest > doc/LATEST
53
- find doc/images doc/js -type f | \
54
- TZ=UTC xargs touch -d '1970-01-01 00:00:00' doc/rdoc.css
55
- $(MAKE) doc_gz
56
- chmod 644 $$(find doc -type f)
57
- $(RSYNC) -av doc/ dcvr:/srv/bogomips/ruby_posix_mq/
58
- git ls-files | xargs touch
59
-
60
- # Create gzip variants of the same timestamp as the original so nginx
61
- # "gzip_static on" can serve the gzipped versions directly.
62
- doc_gz: docs = $(shell find doc -type f ! -regex '^.*\.\(gif\|jpg\|png\|gz\)$$')
63
- doc_gz:
64
- touch doc/NEWS.atom.xml -d "$$(awk 'NR==1{print $$4,$$5,$$6}' NEWS)"
65
- for i in $(docs); do \
66
- gzip --rsyncable -9 < $$i > $$i.gz; touch -r $$i $$i.gz; done
67
-
68
- # launches any of the following shells with RUBYLIB set
69
- irb sh bash ksh:
70
- $@