obuf 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+ - 1.9.3
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source :rubygems
2
+ gemspec
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ === 1.0.2 / 2011-08-02
2
+
3
+ * Fix the bug that caused marshaling errors when an index was requested with Obuf#[] that was out of bounds
4
+
5
+
1
6
  === 1.0.1 / 2011-08-02
2
7
 
3
8
  * Fix the bug that was failing Obuf in Ruby 1.8.7 since Mutex is not loaded by default
data/Rakefile CHANGED
@@ -1,15 +1,31 @@
1
1
  # -*- ruby -*-
2
-
3
2
  require 'rubygems'
4
- require 'hoe'
3
+ require 'jeweler'
4
+ require './lib/obuf'
5
+
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.version = Obuf::VERSION
8
+ gem.name = "obuf"
9
+ gem.summary = "Ruby disk-backed object buffer"
10
+ gem.description = "Stores marshaled temporary objects on-disk in a simple Enumerable"
11
+ gem.email = "me@julik.nl"
12
+ gem.homepage = "http://github.com/julik/obuf"
13
+ gem.authors = ["Julik Tarkhanov"]
14
+ gem.license = 'MIT'
15
+
16
+ gem.add_development_dependency "jeweler"
17
+ gem.add_development_dependency "rake"
18
+ gem.add_development_dependency "flexmock", "~>0.8"
19
+ end
5
20
 
6
- Hoe.spec 'obuf' do | p |
7
- p.developer('Julik Tarkhanov', 'me@julik.nl')
21
+ Jeweler::RubygemsDotOrgTasks.new
8
22
 
9
- p.readme_file = 'README.rdoc'
10
- p.extra_rdoc_files = FileList['*.rdoc'] + FileList['*.txt']
11
- p.extra_dev_deps = {"flexmock" => "~> 0.8"}
12
- p.clean_globs = File.read(File.dirname(__FILE__) + "/.gitignore").split(/\s/).to_a
23
+ require 'rake/testtask'
24
+ desc "Run all tests"
25
+ Rake::TestTask.new("test") do |t|
26
+ t.libs << "test"
27
+ t.pattern = 'test/**/test_*.rb'
28
+ t.verbose = true
13
29
  end
14
30
 
15
- # vim: syntax=ruby
31
+ task :default => [ :test ]
data/lib/obuf.rb CHANGED
@@ -19,7 +19,7 @@ require "thread" # required for ruby 18
19
19
  #
20
20
  # Both reading and writing aim to be threadsafe
21
21
  class Obuf
22
- VERSION = "1.0.1"
22
+ VERSION = "1.0.2"
23
23
 
24
24
  include Enumerable
25
25
 
@@ -113,6 +113,10 @@ class Obuf
113
113
  def recover_object_from(io)
114
114
  # Up to the tab is the amount of bytes to read
115
115
  demarshal_bytes = io.gets("\t").to_i
116
+
117
+ # When at end of IO return nil
118
+ return nil if demarshal_bytes == 0
119
+
116
120
  blob = io.read(demarshal_bytes)
117
121
  demarshal_object(blob)
118
122
  end
data/obuf.gemspec ADDED
@@ -0,0 +1,74 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "obuf"
8
+ s.version = "1.0.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Julik Tarkhanov"]
12
+ s.date = "2012-01-10"
13
+ s.description = "Stores marshaled temporary objects on-disk in a simple Enumerable"
14
+ s.email = "me@julik.nl"
15
+ s.extra_rdoc_files = [
16
+ "README.rdoc"
17
+ ]
18
+ s.files = [
19
+ ".autotest",
20
+ ".travis.yml",
21
+ "Gemfile",
22
+ "History.txt",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "lib/obuf.rb",
26
+ "obuf.gemspec",
27
+ "test/test_obuf.rb"
28
+ ]
29
+ s.homepage = "http://github.com/julik/obuf"
30
+ s.licenses = ["MIT"]
31
+ s.require_paths = ["lib"]
32
+ s.rubygems_version = "1.8.11"
33
+ s.summary = "Ruby disk-backed object buffer"
34
+
35
+ if s.respond_to? :specification_version then
36
+ s.specification_version = 3
37
+
38
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
39
+ s.add_runtime_dependency(%q<obuf>, [">= 0"])
40
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
41
+ s.add_development_dependency(%q<rake>, [">= 0"])
42
+ s.add_development_dependency(%q<flexmock>, ["~> 0.8"])
43
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
44
+ s.add_development_dependency(%q<rake>, [">= 0"])
45
+ s.add_development_dependency(%q<flexmock>, ["~> 0.8"])
46
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
47
+ s.add_development_dependency(%q<rake>, [">= 0"])
48
+ s.add_development_dependency(%q<flexmock>, ["~> 0.8"])
49
+ else
50
+ s.add_dependency(%q<obuf>, [">= 0"])
51
+ s.add_dependency(%q<jeweler>, [">= 0"])
52
+ s.add_dependency(%q<rake>, [">= 0"])
53
+ s.add_dependency(%q<flexmock>, ["~> 0.8"])
54
+ s.add_dependency(%q<jeweler>, [">= 0"])
55
+ s.add_dependency(%q<rake>, [">= 0"])
56
+ s.add_dependency(%q<flexmock>, ["~> 0.8"])
57
+ s.add_dependency(%q<jeweler>, [">= 0"])
58
+ s.add_dependency(%q<rake>, [">= 0"])
59
+ s.add_dependency(%q<flexmock>, ["~> 0.8"])
60
+ end
61
+ else
62
+ s.add_dependency(%q<obuf>, [">= 0"])
63
+ s.add_dependency(%q<jeweler>, [">= 0"])
64
+ s.add_dependency(%q<rake>, [">= 0"])
65
+ s.add_dependency(%q<flexmock>, ["~> 0.8"])
66
+ s.add_dependency(%q<jeweler>, [">= 0"])
67
+ s.add_dependency(%q<rake>, [">= 0"])
68
+ s.add_dependency(%q<flexmock>, ["~> 0.8"])
69
+ s.add_dependency(%q<jeweler>, [">= 0"])
70
+ s.add_dependency(%q<rake>, [">= 0"])
71
+ s.add_dependency(%q<flexmock>, ["~> 0.8"])
72
+ end
73
+ end
74
+
data/test/test_obuf.rb CHANGED
@@ -73,6 +73,26 @@ class TestObuf < Test::Unit::TestCase
73
73
  assert_equal "E\r\nWow!", a[4]
74
74
  end
75
75
 
76
+ def test_random_access
77
+ a = Obuf.new
78
+ letters = ("A".."Z").map{|e| "#{e}\r\nWow!"}.to_a
79
+ letters.map(&a.method(:push))
80
+
81
+ assert_equal "B\r\nWow!", a[1]
82
+ assert_equal "E\r\nWow!", a[4]
83
+ end
84
+
85
+ def test_random_access_out_of_bounds
86
+ a = Obuf.new
87
+ letters = ("A".."Z").map{|e| "#{e}\r\nWow!"}.to_a
88
+ letters.map(&a.method(:push))
89
+ assert_equal nil, a[27]
90
+
91
+ b = Obuf.new
92
+ assert_nil b[0]
93
+ assert_nil b[-1]
94
+ end
95
+
76
96
  def test_clear_calls_close_on_buffer
77
97
  io = Tempfile.new("testing")
78
98
  flexmock(io).should_receive(:close!).once
metadata CHANGED
@@ -1,108 +1,165 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: obuf
3
- version: !ruby/object:Gem::Version
4
- hash: 21
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.2
5
5
  prerelease:
6
- segments:
7
- - 1
8
- - 0
9
- - 1
10
- version: 1.0.1
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Julik Tarkhanov
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-11-20 00:00:00 +01:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2012-01-10 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: obuf
16
+ requirement: &10090570 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *10090570
25
+ - !ruby/object:Gem::Dependency
26
+ name: jeweler
27
+ requirement: &10089860 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *10089860
36
+ - !ruby/object:Gem::Dependency
37
+ name: rake
38
+ requirement: &10089550 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *10089550
47
+ - !ruby/object:Gem::Dependency
22
48
  name: flexmock
49
+ requirement: &10089250 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '0.8'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *10089250
58
+ - !ruby/object:Gem::Dependency
59
+ name: jeweler
60
+ requirement: &10088960 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *10088960
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: &10088620 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
23
78
  prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
79
+ version_requirements: *10088620
80
+ - !ruby/object:Gem::Dependency
81
+ name: flexmock
82
+ requirement: &10088250 !ruby/object:Gem::Requirement
25
83
  none: false
26
- requirements:
84
+ requirements:
27
85
  - - ~>
28
- - !ruby/object:Gem::Version
29
- hash: 27
30
- segments:
31
- - 0
32
- - 8
33
- version: "0.8"
86
+ - !ruby/object:Gem::Version
87
+ version: '0.8'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *10088250
91
+ - !ruby/object:Gem::Dependency
92
+ name: jeweler
93
+ requirement: &10087870 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
34
99
  type: :development
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- name: hoe
38
100
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
101
+ version_requirements: *10087870
102
+ - !ruby/object:Gem::Dependency
103
+ name: rake
104
+ requirement: &10087280 !ruby/object:Gem::Requirement
40
105
  none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- hash: 35
45
- segments:
46
- - 2
47
- - 9
48
- - 4
49
- version: 2.9.4
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
50
110
  type: :development
51
- version_requirements: *id002
52
- description: A simple Ruby object buffer. Use this if you need to temporarily store alot of serializable Ruby objects.
53
- email:
54
- - me@julik.nl
111
+ prerelease: false
112
+ version_requirements: *10087280
113
+ - !ruby/object:Gem::Dependency
114
+ name: flexmock
115
+ requirement: &10086930 !ruby/object:Gem::Requirement
116
+ none: false
117
+ requirements:
118
+ - - ~>
119
+ - !ruby/object:Gem::Version
120
+ version: '0.8'
121
+ type: :development
122
+ prerelease: false
123
+ version_requirements: *10086930
124
+ description: Stores marshaled temporary objects on-disk in a simple Enumerable
125
+ email: me@julik.nl
55
126
  executables: []
56
-
57
127
  extensions: []
58
-
59
- extra_rdoc_files:
60
- - History.txt
61
- - Manifest.txt
128
+ extra_rdoc_files:
62
129
  - README.rdoc
63
- files:
130
+ files:
64
131
  - .autotest
132
+ - .travis.yml
133
+ - Gemfile
65
134
  - History.txt
66
- - Manifest.txt
67
135
  - README.rdoc
68
136
  - Rakefile
69
137
  - lib/obuf.rb
138
+ - obuf.gemspec
70
139
  - test/test_obuf.rb
71
- - .gemtest
72
- has_rdoc: true
73
140
  homepage: http://github.com/julik/obuf
74
- licenses: []
75
-
141
+ licenses:
142
+ - MIT
76
143
  post_install_message:
77
- rdoc_options:
78
- - --main
79
- - README.rdoc
80
- require_paths:
144
+ rdoc_options: []
145
+ require_paths:
81
146
  - lib
82
- required_ruby_version: !ruby/object:Gem::Requirement
147
+ required_ruby_version: !ruby/object:Gem::Requirement
83
148
  none: false
84
- requirements:
85
- - - ">="
86
- - !ruby/object:Gem::Version
87
- hash: 3
88
- segments:
89
- - 0
90
- version: "0"
91
- required_rubygems_version: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ! '>='
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
154
  none: false
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- hash: 3
97
- segments:
98
- - 0
99
- version: "0"
155
+ requirements:
156
+ - - ! '>='
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
100
159
  requirements: []
101
-
102
- rubyforge_project: obuf
103
- rubygems_version: 1.6.2
160
+ rubyforge_project:
161
+ rubygems_version: 1.8.11
104
162
  signing_key:
105
163
  specification_version: 3
106
- summary: A simple Ruby object buffer
107
- test_files:
108
- - test/test_obuf.rb
164
+ summary: Ruby disk-backed object buffer
165
+ test_files: []
data/.gemtest DELETED
File without changes
data/Manifest.txt DELETED
@@ -1,7 +0,0 @@
1
- .autotest
2
- History.txt
3
- Manifest.txt
4
- README.rdoc
5
- Rakefile
6
- lib/obuf.rb
7
- test/test_obuf.rb