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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5e70a5ef105176bf1d61a80ee9727899de4f703a
4
- data.tar.gz: d7efa5256bd009b19d7cf28d33c784efc293b506
3
+ metadata.gz: 5dc85fe1bb49ec72198087e251a3d2f82236944b
4
+ data.tar.gz: d7b30be75c5360a6916b6d4d7108c4c20971532a
5
5
  SHA512:
6
- metadata.gz: 1bc6cd6aafe8112f3a9dcef83d564b74a048bc7ac67dfb6bbe1abe4a08dccec68832faec1f002c95d35acbd5977a2f533a46eb2a667f8e2ea96946f663eb6ffe
7
- data.tar.gz: 39701fd0ff324763827d156224014eb27893541f55d31611be1a29b048c688f0d582629fcffa4a57918aadac3e26eeb6585c75de474cb335db266d1d610b9b23
6
+ metadata.gz: 243bb0063699a7419ff4f21982351c212702e68181650886efd5f513f54d77d35d8656d54777a1c75b599983a60192d3411187bc05a3639ddeb52d0b8c8328a4
7
+ data.tar.gz: bbec7c970e8f0e0840185b52a8f051d9c12be78327b4b77aeb7fbd71a6bec16fac471cf9bff78ab84ccbad5991e443aa545abda637fe6948bce87e064884092b
data/COPYING CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013, Joel VanderWerf, vjoel@users.sourceforge.net
1
+ Copyright (c) 2013-2014, Joel VanderWerf, vjoel@users.sourceforge.net
2
2
  All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without
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
- require 'object-stream'
6
- @version ||= ObjectStream::VERSION
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
- prj = "object-stream"
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 "commit, tag, and push repo; build and push gem"
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
- tag = "#{prj}-#{version}"
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 #{prj}-#{version}"
42
+ sh "git tag #{tag}"
37
43
  sh "git push"
38
44
  sh "git push --tags"
39
45
 
40
- sh "gem push #{prj}-#{version}.gem"
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
@@ -63,6 +63,8 @@ class ObjectStreamWrapper
63
63
  else
64
64
  obj
65
65
  end
66
+ rescue => ex
67
+ raise StreamError, "cannot convert to expected class: #{obj.inspect}: #{ex}"
66
68
  end
67
69
  private :convert_to_expected
68
70
 
data/lib/object-stream.rb CHANGED
@@ -10,7 +10,7 @@
10
10
  module ObjectStream
11
11
  include Enumerable
12
12
 
13
- VERSION = "0.3"
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
- read_from_stream {|obj| yield obj}
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.3'
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: 2013-07-20 00:00:00.000000000 Z
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
- - test/test-maxbuf.rb
65
- - test/test-outbox.rb
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.0.4
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: