tdb 0.5.0 → 0.6.1

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/pkg.mk ADDED
@@ -0,0 +1,175 @@
1
+ RUBY = ruby
2
+ RAKE = rake
3
+ RSYNC = rsync
4
+ WRONGDOC = wrongdoc
5
+
6
+ GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
7
+ @./GIT-VERSION-GEN
8
+ -include GIT-VERSION-FILE
9
+ -include local.mk
10
+ DLEXT := $(shell $(RUBY) -rrbconfig -e 'puts RbConfig::CONFIG["DLEXT"]')
11
+ RUBY_VERSION := $(shell $(RUBY) -e 'puts RUBY_VERSION')
12
+ RUBY_ENGINE := $(shell $(RUBY) -e 'puts((RUBY_ENGINE rescue "ruby"))')
13
+ lib := lib
14
+
15
+ ifeq ($(shell test -f script/isolate_for_tests && echo t),t)
16
+ isolate_libs := tmp/isolate/$(RUBY_ENGINE)-$(RUBY_VERSION)/isolate.mk
17
+ $(isolate_libs): script/isolate_for_tests
18
+ @$(RUBY) script/isolate_for_tests
19
+ -include $(isolate_libs)
20
+ lib := $(lib):$(ISOLATE_LIBS)
21
+ endif
22
+
23
+ ext := $(firstword $(wildcard ext/*))
24
+ ifneq ($(ext),)
25
+ ext_pfx := tmp/ext/$(RUBY_ENGINE)-$(RUBY_VERSION)
26
+ ext_h := $(wildcard $(ext)/*/*.h $(ext)/*.h)
27
+ ext_src := $(wildcard $(ext)/*.c $(ext_h))
28
+ ext_pfx_src := $(addprefix $(ext_pfx)/,$(ext_src))
29
+ ext_d := $(ext_pfx)/$(ext)/.d
30
+ $(ext)/extconf.rb: $(wildcard $(ext)/*.h)
31
+ @>> $@
32
+ $(ext_d):
33
+ @mkdir -p $(@D)
34
+ @> $@
35
+ $(ext_pfx)/$(ext)/%: $(ext)/% $(ext_d)
36
+ install -m 644 $< $@
37
+ $(ext_pfx)/$(ext)/Makefile: $(ext)/extconf.rb $(ext_d) $(ext_h)
38
+ $(RM) -f $(@D)/*.o
39
+ cd $(@D) && $(RUBY) $(CURDIR)/$(ext)/extconf.rb
40
+ ext_sfx := _ext.$(DLEXT)
41
+ ext_dl := $(ext_pfx)/$(ext)/$(notdir $(ext)_ext.$(DLEXT))
42
+ $(ext_dl): $(ext_src) $(ext_pfx_src) $(ext_pfx)/$(ext)/Makefile
43
+ @echo $^ == $@
44
+ $(MAKE) -C $(@D)
45
+ lib := $(lib):$(ext_pfx)/$(ext)
46
+ build: $(ext_dl)
47
+ else
48
+ build:
49
+ endif
50
+
51
+ pkg_extra += GIT-VERSION-FILE NEWS ChangeLog LATEST
52
+ ChangeLog: GIT-VERSION-FILE .wrongdoc.yml
53
+ $(WRONGDOC) prepare
54
+ NEWS LATEST: ChangeLog
55
+
56
+ manifest:
57
+ $(RM) .manifest
58
+ $(MAKE) .manifest
59
+
60
+ .manifest: $(pkg_extra)
61
+ (git ls-files && for i in $@ $(pkg_extra); do echo $$i; done) | \
62
+ LC_ALL=C sort > $@+
63
+ cmp $@+ $@ || mv $@+ $@
64
+ $(RM) $@+
65
+
66
+ doc:: .document .wrongdoc.yml $(pkg_extra)
67
+ -find lib -type f -name '*.rbc' -exec rm -f '{}' ';'
68
+ -find ext -type f -name '*.rbc' -exec rm -f '{}' ';'
69
+ $(RM) -r doc
70
+ $(WRONGDOC) all
71
+ install -m644 COPYING doc/COPYING
72
+ install -m644 $(shell LC_ALL=C grep '^[A-Z]' .document) doc/
73
+
74
+ ifneq ($(VERSION),)
75
+ pkggem := pkg/$(rfpackage)-$(VERSION).gem
76
+ pkgtgz := pkg/$(rfpackage)-$(VERSION).tgz
77
+ release_notes := release_notes-$(VERSION)
78
+ release_changes := release_changes-$(VERSION)
79
+
80
+ release-notes: $(release_notes)
81
+ release-changes: $(release_changes)
82
+ $(release_changes):
83
+ $(WRONGDOC) release_changes > $@+
84
+ $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
85
+ $(release_notes):
86
+ $(WRONGDOC) release_notes > $@+
87
+ $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
88
+
89
+ # ensures we're actually on the tagged $(VERSION), only used for release
90
+ verify:
91
+ test x"$(shell umask)" = x0022
92
+ git rev-parse --verify refs/tags/v$(VERSION)^{}
93
+ git diff-index --quiet HEAD^0
94
+ test $$(git rev-parse --verify HEAD^0) = \
95
+ $$(git rev-parse --verify refs/tags/v$(VERSION)^{})
96
+
97
+ fix-perms:
98
+ -git ls-tree -r HEAD | awk '/^100644 / {print $$NF}' | xargs chmod 644
99
+ -git ls-tree -r HEAD | awk '/^100755 / {print $$NF}' | xargs chmod 755
100
+
101
+ gem: $(pkggem)
102
+
103
+ install-gem: $(pkggem)
104
+ gem install $(CURDIR)/$<
105
+
106
+ $(pkggem): manifest fix-perms
107
+ gem build $(rfpackage).gemspec
108
+ mkdir -p pkg
109
+ mv $(@F) $@
110
+
111
+ $(pkgtgz): distdir = $(basename $@)
112
+ $(pkgtgz): HEAD = v$(VERSION)
113
+ $(pkgtgz): manifest fix-perms
114
+ @test -n "$(distdir)"
115
+ $(RM) -r $(distdir)
116
+ mkdir -p $(distdir)
117
+ tar cf - $$(cat .manifest) | (cd $(distdir) && tar xf -)
118
+ cd pkg && tar cf - $(basename $(@F)) | gzip -9 > $(@F)+
119
+ mv $@+ $@
120
+
121
+ package: $(pkgtgz) $(pkggem)
122
+
123
+ test-release:: verify package $(release_notes) $(release_changes)
124
+ # make tgz release on RubyForge
125
+ @echo rubyforge add_release -f \
126
+ -n $(release_notes) -a $(release_changes) \
127
+ $(rfproject) $(rfpackage) $(VERSION) $(pkgtgz)
128
+ @echo gem push $(pkggem)
129
+ @echo rubyforge add_file \
130
+ $(rfproject) $(rfpackage) $(VERSION) $(pkggem)
131
+ release:: verify package $(release_notes) $(release_changes)
132
+ # make tgz release on RubyForge
133
+ rubyforge add_release -f -n $(release_notes) -a $(release_changes) \
134
+ $(rfproject) $(rfpackage) $(VERSION) $(pkgtgz)
135
+ # push gem to RubyGems.org
136
+ gem push $(pkggem)
137
+ # in case of gem downloads from RubyForge releases page
138
+ rubyforge add_file \
139
+ $(rfproject) $(rfpackage) $(VERSION) $(pkggem)
140
+ else
141
+ gem install-gem: GIT-VERSION-FILE
142
+ $(MAKE) $@ VERSION=$(GIT_VERSION)
143
+ endif
144
+
145
+ all:: test
146
+ test_units := $(wildcard test/test_*.rb)
147
+ test: test-unit
148
+ test-unit: $(test_units)
149
+ $(test_units): build
150
+ $(RUBY) -I $(lib) $@ $(RUBY_TEST_OPTS)
151
+
152
+ # this requires GNU coreutils variants
153
+ ifneq ($(RSYNC_DEST),)
154
+ publish_doc:
155
+ -git set-file-times
156
+ $(MAKE) doc
157
+ find doc/images -type f | \
158
+ TZ=UTC xargs touch -d '1970-01-01 00:00:06' doc/rdoc.css
159
+ $(MAKE) doc_gz
160
+ $(RSYNC) -av doc/ $(RSYNC_DEST)/
161
+ git ls-files | xargs touch
162
+ endif
163
+
164
+ # Create gzip variants of the same timestamp as the original so nginx
165
+ # "gzip_static on" can serve the gzipped versions directly.
166
+ doc_gz: docs = $(shell find doc -type f ! -regex '^.*\.\(gif\|jpg\|png\|gz\)$$')
167
+ doc_gz:
168
+ for i in $(docs); do \
169
+ gzip --rsyncable -9 < $$i > $$i.gz; touch -r $$i $$i.gz; done
170
+ check-warnings:
171
+ @(for i in $$(git ls-files '*.rb'| grep -v '^setup\.rb$$'); \
172
+ do $(RUBY) -d -W2 -c $$i; done) | grep -v '^Syntax OK$$' || :
173
+
174
+ .PHONY: all .FORCE-GIT-VERSION-FILE doc test $(test_units) manifest
175
+ .PHONY: check-warnings
@@ -7,21 +7,17 @@ name, summary, title = readme_metadata
7
7
  Gem::Specification.new do |s|
8
8
  s.name = %q{tdb}
9
9
  s.version = ENV["VERSION"].dup
10
-
11
10
  s.homepage = 'http://bogomips.org/ruby-tdb/'
12
11
  s.authors = ["Ruby tdb hackers"]
13
- s.date = Time.now.utc.strftime('%Y-%m-%d')
14
12
  s.description = readme_description
15
13
  s.email = %q{ruby.tdb@librelist.org}
16
14
  s.extra_rdoc_files = extra_rdoc_files(manifest)
17
15
  s.files = manifest
18
16
  s.rdoc_options = rdoc_options
19
- s.require_paths = %w(lib ext)
20
17
  s.rubyforge_project = %q{qrp}
21
18
  s.summary = summary
22
19
  s.test_files = Dir['test/test_*.rb']
23
20
  s.extensions = %w(ext/tdb/extconf.rb)
24
- s.add_development_dependency('wrongdoc', '~> 1.3')
25
-
26
- # s.license = %w(LGPL) # disabled for compatibility with older RubyGems
21
+ s.add_development_dependency('wrongdoc', '~> 1.6.2')
22
+ s.licenses = %w(LGPLv2.1+)
27
23
  end
@@ -16,6 +16,10 @@ class TestTdb < Test::Unit::TestCase
16
16
  @tdb.close if @tdb && ! @tdb.closed?
17
17
  end
18
18
 
19
+ def test_create_file_null_byte_in_path
20
+ assert_raises(ArgumentError) { TDB.new("hello.tdb\0") }
21
+ end
22
+
19
23
  def test_create_file
20
24
  assert_nothing_raised do
21
25
  @tmp = Tempfile.new('tdb')
@@ -188,8 +192,9 @@ class TestTdb < Test::Unit::TestCase
188
192
  def test_alternate_hashes
189
193
  results = {}
190
194
  expect = TDB::HASHES.to_a.map { |k,v| [ k.to_s, v.to_s ] }.sort
191
- %w(default jenkins_lookup3 djb2 djb3 fnv1a
192
- murmur1 murmur1_aligned murmur2 murmur2a murmur2_aligned).each do |h|
195
+ %w(default siphash24 jenkins_lookup3 djb2 djb3 fnv1a
196
+ murmur1 murmur1_aligned murmur2 murmur2a murmur2_aligned
197
+ murmur3a murmur3f).each do |h|
193
198
  assert_nothing_raised do
194
199
  tdb = TDB.new(nil, :hash => h.to_sym)
195
200
  TDB::HASHES.each do |k,v|
@@ -275,6 +280,23 @@ class TestTdb < Test::Unit::TestCase
275
280
  assert ! @tdb.include?("hello")
276
281
  end
277
282
 
283
+ def test_fork
284
+ @tmp = Tempfile.new('tdb')
285
+ File.unlink(@tmp.path)
286
+ @tdb = TDB.new(@tmp.path)
287
+ @tdb["hello"] = "world"
288
+ pid = fork do
289
+ assert_equal "world", @tdb["hello"]
290
+ @tdb["hello"] = "WORLD"
291
+ @tdb["#$$"] = "NO"
292
+ exit 0
293
+ end
294
+ _, status = Process.waitpid2(pid)
295
+ assert status.success?, status.inspect
296
+ assert_equal "WORLD", @tdb["hello"]
297
+ assert_equal "NO", @tdb[pid.to_s]
298
+ end
299
+
278
300
  def test_fetch_reuse_buf
279
301
  assert_nothing_raised do
280
302
  @tmp = Tempfile.new('tdb')
@@ -12,4 +12,34 @@ class TestHashFunctions < Test::Unit::TestCase
12
12
  assert_kind_of Integer, __send__("tdb_hash_#{name}", "hello")
13
13
  end
14
14
  end
15
+
16
+ def test_distro_sequential
17
+ TDB::HASHES.each do |name,_|
18
+ next if :default == name
19
+ m = method "tdb_hash_#{name}"
20
+ tmp = Hash.new { |h,k| h[k] = 0 }
21
+ (1..100000).each do |s|
22
+ tmp[m.call(s.to_s) % 7] += 1
23
+ end
24
+ assert_equal 7, tmp.size
25
+ tmp.each_value do |v|
26
+ assert_in_delta 100000/7.0, v, 1000
27
+ end
28
+ end
29
+ end
30
+
31
+ def test_distro_random
32
+ TDB::HASHES.each do |name,_|
33
+ next if :default == name
34
+ m = method "tdb_hash_#{name}"
35
+ tmp = Hash.new { |h,k| h[k] = 0 }
36
+ 100000.times do
37
+ tmp[m.call(rand.to_s) % 7] += 1
38
+ end
39
+ assert_equal 7, tmp.size
40
+ tmp.each_value do |v|
41
+ assert_in_delta 100000/7.0, v, 1000
42
+ end
43
+ end
44
+ end
15
45
  end
@@ -81,6 +81,7 @@ class Test_TDB_MT < Test::Unit::TestCase
81
81
  m += [ :include?, :member? ]
82
82
  m.sort!
83
83
  unwrapped = ( (m - mt) | (mt - m)).uniq
84
+ unwrapped -= [ :initialize ]
84
85
  assert unwrapped.empty?, "unwrapped methods: #{unwrapped.inspect}"
85
86
  @tdb = TDB.new(nil)
86
87
  respond_to?(:refute_match) and
metadata CHANGED
@@ -1,49 +1,44 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: tdb
3
- version: !ruby/object:Gem::Version
4
- hash: 11
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 5
9
- - 0
10
- version: 0.5.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.6.1
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Ruby tdb hackers
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-01-17 00:00:00 +00:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2014-02-10 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: wrongdoc
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
18
+ requirements:
27
19
  - - ~>
28
- - !ruby/object:Gem::Version
29
- hash: 9
30
- segments:
31
- - 1
32
- - 3
33
- version: "1.3"
20
+ - !ruby/object:Gem::Version
21
+ version: 1.6.2
34
22
  type: :development
35
- version_requirements: *id001
36
- description: |-
37
- TDB is much like other DBM implementations, except it allows concurrent
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 1.6.2
30
+ description: ! 'TDB is much like other DBM implementations, except it allows concurrent
31
+
38
32
  writer processes. TDB was initially developed for Samba, but is used by
33
+
39
34
  other projects as well. These Ruby bindings allow Ruby apps to read and
40
- write to the same databases used by Samba!
35
+
36
+ write to the same databases used by Samba!'
41
37
  email: ruby.tdb@librelist.org
42
38
  executables: []
43
-
44
- extensions:
39
+ extensions:
45
40
  - ext/tdb/extconf.rb
46
- extra_rdoc_files:
41
+ extra_rdoc_files:
47
42
  - LICENSE
48
43
  - README
49
44
  - Hash_Functions
@@ -54,7 +49,7 @@ extra_rdoc_files:
54
49
  - lib/tdb/mt.rb
55
50
  - ext/tdb/tdb.c
56
51
  - LATEST
57
- files:
52
+ files:
58
53
  - .document
59
54
  - .gitignore
60
55
  - .manifest
@@ -79,54 +74,48 @@ files:
79
74
  - ext/tdb/lookup3.c
80
75
  - ext/tdb/murmur1.c
81
76
  - ext/tdb/murmur2.c
77
+ - ext/tdb/murmur3.c
82
78
  - ext/tdb/rbtdb.h
79
+ - ext/tdb/siphash24.c
83
80
  - ext/tdb/tdb.c
84
81
  - lib/tdb.rb
85
82
  - lib/tdb/mt.rb
83
+ - pkg.mk
86
84
  - setup.rb
87
85
  - tdb.gemspec
88
86
  - test/test_tdb.rb
89
87
  - test/test_tdb_hash_functions.rb
90
88
  - test/test_tdb_mt.rb
91
- has_rdoc: true
92
89
  homepage: http://bogomips.org/ruby-tdb/
93
- licenses: []
94
-
90
+ licenses:
91
+ - LGPLv2.1+
95
92
  post_install_message:
96
- rdoc_options:
93
+ rdoc_options:
97
94
  - -t
98
95
  - tdb - Trivial Database bindings for Ruby
99
96
  - -W
100
- - http://git.bogomips.org/cgit/ruby-tdb.git/tree/%s
101
- require_paths:
97
+ - http://bogomips.org/ruby-tdb.git/tree/%s
98
+ require_paths:
102
99
  - lib
103
- - ext
104
- required_ruby_version: !ruby/object:Gem::Requirement
100
+ required_ruby_version: !ruby/object:Gem::Requirement
105
101
  none: false
106
- requirements:
107
- - - ">="
108
- - !ruby/object:Gem::Version
109
- hash: 3
110
- segments:
111
- - 0
112
- version: "0"
113
- required_rubygems_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ! '>='
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
107
  none: false
115
- requirements:
116
- - - ">="
117
- - !ruby/object:Gem::Version
118
- hash: 3
119
- segments:
120
- - 0
121
- version: "0"
108
+ requirements:
109
+ - - ! '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
122
112
  requirements: []
123
-
124
113
  rubyforge_project: qrp
125
- rubygems_version: 1.3.7
114
+ rubygems_version: 1.8.23
126
115
  signing_key:
127
116
  specification_version: 3
128
117
  summary: Trivial Database bindings for Ruby
129
- test_files:
118
+ test_files:
130
119
  - test/test_tdb_mt.rb
131
120
  - test/test_tdb_hash_functions.rb
132
121
  - test/test_tdb.rb