object-stream 0.3 → 0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/COPYING +1 -1
- data/Rakefile +35 -11
- data/lib/object-stream-wrapper.rb +2 -0
- data/lib/object-stream.rb +13 -2
- metadata +29 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5dc85fe1bb49ec72198087e251a3d2f82236944b
|
4
|
+
data.tar.gz: d7b30be75c5360a6916b6d4d7108c4c20971532a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 243bb0063699a7419ff4f21982351c212702e68181650886efd5f513f54d77d35d8656d54777a1c75b599983a60192d3411187bc05a3639ddeb52d0b8c8328a4
|
7
|
+
data.tar.gz: bbec7c970e8f0e0840185b52a8f051d9c12be78327b4b77aeb7fbd71a6bec16fac471cf9bff78ab84ccbad5991e443aa545abda637fe6948bce87e064884092b
|
data/COPYING
CHANGED
data/Rakefile
CHANGED
@@ -1,12 +1,20 @@
|
|
1
1
|
require 'rake'
|
2
2
|
require 'rake/testtask'
|
3
3
|
|
4
|
+
PRJ = "object-stream"
|
5
|
+
|
4
6
|
def version
|
5
|
-
|
6
|
-
|
7
|
+
@version ||= begin
|
8
|
+
require 'object-stream'
|
9
|
+
v = ObjectStream::VERSION
|
10
|
+
warn "ObjectStream::VERSION not a string" unless v.kind_of? String
|
11
|
+
v
|
12
|
+
end
|
7
13
|
end
|
8
14
|
|
9
|
-
|
15
|
+
def tag
|
16
|
+
@tag ||= "#{PRJ}-#{version}"
|
17
|
+
end
|
10
18
|
|
11
19
|
desc "Run tests"
|
12
20
|
Rake::TestTask.new :test do |t|
|
@@ -15,27 +23,43 @@ Rake::TestTask.new :test do |t|
|
|
15
23
|
t.test_files = FileList["test/**/*.rb"]
|
16
24
|
end
|
17
25
|
|
18
|
-
desc "
|
19
|
-
task :release do
|
26
|
+
desc "Commit, tag, and push repo; build and push gem"
|
27
|
+
task :release => "release:is_new_version" do
|
20
28
|
require 'tempfile'
|
21
29
|
|
22
|
-
|
23
|
-
|
24
|
-
sh "gem build #{prj}.gemspec"
|
30
|
+
sh "gem build #{PRJ}.gemspec"
|
25
31
|
|
26
32
|
file = Tempfile.new "template"
|
27
33
|
begin
|
28
34
|
file.puts "release #{version}"
|
29
35
|
file.close
|
30
|
-
sh "git commit -a -v -t #{file.path}"
|
36
|
+
sh "git commit --allow-empty -a -v -t #{file.path}"
|
31
37
|
ensure
|
32
38
|
file.close unless file.closed?
|
33
39
|
file.unlink
|
34
40
|
end
|
35
41
|
|
36
|
-
sh "git tag #{
|
42
|
+
sh "git tag #{tag}"
|
37
43
|
sh "git push"
|
38
44
|
sh "git push --tags"
|
39
45
|
|
40
|
-
sh "gem push #{
|
46
|
+
sh "gem push #{tag}.gem"
|
47
|
+
end
|
48
|
+
|
49
|
+
namespace :release do
|
50
|
+
desc "Diff to latest release"
|
51
|
+
task :diff do
|
52
|
+
latest = `git describe --abbrev=0 --tags --match '#{PRJ}-*'`.chomp
|
53
|
+
sh "git diff #{latest}"
|
54
|
+
end
|
55
|
+
|
56
|
+
desc "Log to latest release"
|
57
|
+
task :log do
|
58
|
+
latest = `git describe --abbrev=0 --tags --match '#{PRJ}-*'`.chomp
|
59
|
+
sh "git log #{latest}.."
|
60
|
+
end
|
61
|
+
|
62
|
+
task :is_new_version do
|
63
|
+
abort "#{tag} exists; update version!" unless `git tag -l #{tag}`.empty?
|
64
|
+
end
|
41
65
|
end
|
data/lib/object-stream.rb
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
module ObjectStream
|
11
11
|
include Enumerable
|
12
12
|
|
13
|
-
VERSION = "0.
|
13
|
+
VERSION = "0.4"
|
14
14
|
|
15
15
|
# The IO through which the stream reads and writes serialized object data.
|
16
16
|
attr_reader :io
|
@@ -33,6 +33,9 @@ module ObjectStream
|
|
33
33
|
# Raised when maxbuf exceeded.
|
34
34
|
class OverflowError < StandardError; end
|
35
35
|
|
36
|
+
# Raised when incoming data is unreadable.
|
37
|
+
class StreamError < StandardError; end
|
38
|
+
|
36
39
|
@stream_class_map =
|
37
40
|
Hash.new {|h,type| raise ArgumentError, "unknown type: #{type.inspect}"}
|
38
41
|
@mutex = Mutex.new
|
@@ -80,13 +83,21 @@ module ObjectStream
|
|
80
83
|
def read
|
81
84
|
if block_given?
|
82
85
|
read_from_inbox {|obj| yield obj}
|
83
|
-
|
86
|
+
checked_read_from_stream {|obj| yield obj}
|
84
87
|
return nil
|
85
88
|
else
|
86
89
|
read_one
|
87
90
|
end
|
88
91
|
end
|
89
92
|
|
93
|
+
def checked_read_from_stream
|
94
|
+
read_from_stream {|obj| yield obj}
|
95
|
+
rescue IOError, SystemCallError, OverflowError
|
96
|
+
raise
|
97
|
+
rescue => ex
|
98
|
+
raise StreamError, "unreadble stream: #{ex}"
|
99
|
+
end
|
100
|
+
|
90
101
|
# Read one object from the stream, blocking if necessary. Returns the object.
|
91
102
|
# Raises EOFError at the end of the stream.
|
92
103
|
def read_one
|
metadata
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: object-stream
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.4'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joel VanderWerf
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: yajl-ruby
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
description: Stream objects over IO using Marshal, JSON, YAML, or Msgpack.
|
@@ -46,27 +46,27 @@ extra_rdoc_files:
|
|
46
46
|
- README.md
|
47
47
|
- COPYING
|
48
48
|
files:
|
49
|
-
- README.md
|
50
49
|
- COPYING
|
50
|
+
- README.md
|
51
51
|
- Rakefile
|
52
|
-
- lib/object-stream-wrapper.rb
|
53
|
-
- lib/object-stream.rb
|
54
52
|
- bench/pipe-socket.rb
|
55
|
-
- examples/read-without-block.rb
|
56
|
-
- examples/socket.rb
|
57
|
-
- examples/pipe.rb
|
58
|
-
- examples/maxbuf.rb
|
59
|
-
- examples/custom-class.rb
|
60
|
-
- examples/udp.rb
|
61
53
|
- examples/basic-usage.rb
|
54
|
+
- examples/custom-class.rb
|
55
|
+
- examples/maxbuf.rb
|
62
56
|
- examples/outbox.rb
|
57
|
+
- examples/pipe.rb
|
58
|
+
- examples/read-without-block.rb
|
63
59
|
- examples/slow-sender.rb
|
64
|
-
-
|
65
|
-
-
|
60
|
+
- examples/socket.rb
|
61
|
+
- examples/udp.rb
|
62
|
+
- lib/object-stream-wrapper.rb
|
63
|
+
- lib/object-stream.rb
|
66
64
|
- test/test-basic.rb
|
67
65
|
- test/test-consume.rb
|
68
|
-
- test/test-inbox.rb
|
69
66
|
- test/test-expect.rb
|
67
|
+
- test/test-inbox.rb
|
68
|
+
- test/test-maxbuf.rb
|
69
|
+
- test/test-outbox.rb
|
70
70
|
- test/test-slow-sender.rb
|
71
71
|
homepage: https://github.com/vjoel/object-stream
|
72
72
|
licenses:
|
@@ -74,37 +74,37 @@ licenses:
|
|
74
74
|
metadata: {}
|
75
75
|
post_install_message:
|
76
76
|
rdoc_options:
|
77
|
-
- --quiet
|
78
|
-
- --line-numbers
|
79
|
-
- --inline-source
|
80
|
-
- --title
|
77
|
+
- "--quiet"
|
78
|
+
- "--line-numbers"
|
79
|
+
- "--inline-source"
|
80
|
+
- "--title"
|
81
81
|
- object-stream
|
82
|
-
- --main
|
82
|
+
- "--main"
|
83
83
|
- README.md
|
84
84
|
require_paths:
|
85
85
|
- lib
|
86
86
|
required_ruby_version: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
|
-
- -
|
88
|
+
- - ">="
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: '0'
|
91
91
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
92
|
requirements:
|
93
|
-
- -
|
93
|
+
- - ">="
|
94
94
|
- !ruby/object:Gem::Version
|
95
95
|
version: '0'
|
96
96
|
requirements: []
|
97
97
|
rubyforge_project:
|
98
|
-
rubygems_version: 2.
|
98
|
+
rubygems_version: 2.2.1
|
99
99
|
signing_key:
|
100
100
|
specification_version: 4
|
101
101
|
summary: Stream objects over IO using Marshal, JSON, YAML, or Msgpack
|
102
102
|
test_files:
|
103
|
-
- test/test-maxbuf.rb
|
104
|
-
- test/test-outbox.rb
|
105
103
|
- test/test-basic.rb
|
104
|
+
- test/test-outbox.rb
|
106
105
|
- test/test-consume.rb
|
106
|
+
- test/test-maxbuf.rb
|
107
107
|
- test/test-inbox.rb
|
108
|
-
- test/test-expect.rb
|
109
108
|
- test/test-slow-sender.rb
|
109
|
+
- test/test-expect.rb
|
110
110
|
has_rdoc:
|