tdb 0.3.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document CHANGED
@@ -6,3 +6,4 @@ NEWS
6
6
  ChangeLog
7
7
  lib
8
8
  ext/tdb/tdb.c
9
+ LATEST
data/.gitignore CHANGED
@@ -17,3 +17,4 @@ pkg/
17
17
  /man
18
18
  tags
19
19
  TAGS
20
+ /LATEST
@@ -0,0 +1,4 @@
1
+ ---
2
+ cgit_url: http://git.bogomips.org/cgit/ruby-tdb.git
3
+ git_url: git://git.bogomips.org/ruby-tdb.git
4
+ rdoc_url: http://bogomips.org/ruby-tdb/
@@ -1,7 +1,7 @@
1
1
  #!/bin/sh
2
2
 
3
3
  GVF=GIT-VERSION-FILE
4
- DEF_VER=v0.3.0.GIT
4
+ DEF_VER=v0.5.0.GIT
5
5
 
6
6
  LF='
7
7
  '
@@ -3,8 +3,6 @@ all::
3
3
  RUBY = ruby
4
4
  RAKE = rake
5
5
  RSYNC = rsync
6
- GIT_URL = git://git.bogomips.org/ruby-tdb.git
7
- CGIT_URL = http://git.bogomips.org/cgit/ruby-tdb.git
8
6
 
9
7
  GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
10
8
  @./GIT-VERSION-GEN
@@ -29,61 +27,27 @@ install:
29
27
  setup_rb_files := .config InstalledFiles
30
28
  prep_setup_rb := @-$(RM) $(setup_rb_files);$(MAKE) -C $(ext) clean
31
29
 
30
+ extdir := ext/tdb
32
31
  clean:
33
- -$(MAKE) -C ext/tdb clean
34
- $(RM) $(setup_rb_files) ext/tdb/Makefile
35
-
36
- pkg_extra := GIT-VERSION-FILE NEWS ChangeLog
37
- manifest: $(pkg_extra)
38
- $(RM) .manifest
39
- $(MAKE) .manifest
40
-
41
- .manifest:
42
- (git ls-files && \
43
- for i in $@ $(pkg_extra) $(man1_paths); \
44
- do echo $$i; done) | LC_ALL=C sort > $@+
45
- cmp $@+ $@ || mv $@+ $@
46
- $(RM) $@+
32
+ -$(MAKE) -C $(extdir) clean
33
+ $(RM) $(setup_rb_files) $(extdir)/Makefile
47
34
 
48
- NEWS: GIT-VERSION-FILE
49
- $(RAKE) -s news_rdoc > $@+
50
- mv $@+ $@
35
+ pkg_extra := GIT-VERSION-FILE NEWS ChangeLog LATEST
36
+ ChangeLog: GIT-VERSION-FILE .wrongdoc.yml
37
+ wrongdoc prepare
51
38
 
52
- latest: NEWS
53
- @awk 'BEGIN{RS="=== ";ORS=""}NR==2{sub(/\n$$/,"");print RS""$$0 }' $<
54
-
55
- SINCE =
56
- ChangeLog: LOG_VERSION = \
57
- $(shell git rev-parse -q "$(GIT_VERSION)" >/dev/null 2>&1 && \
58
- echo $(GIT_VERSION) || git describe)
59
- ifneq ($(SINCE),)
60
- ChangeLog: log_range = v$(SINCE)..$(LOG_VERSION)
61
- endif
62
- ChangeLog: GIT-VERSION-FILE
63
- @echo "ChangeLog from $(GIT_URL) ($(log_range))" > $@+
64
- @echo >> $@+
65
- git log $(log_range) | sed -e 's/^/ /' >> $@+
66
- mv $@+ $@
67
-
68
- news_atom := http://bogomips.org/ruby-tdb/NEWS.atom.xml
69
- cgit_atom := $(CGIT_URL)/atom/?h=master
70
- atom = <link rel="alternate" title="Atom feed" href="$(1)" \
71
- type="application/atom+xml"/>
39
+ .manifest: ChangeLog
40
+ (git ls-files && for i in $@ $(pkg_extra); do echo $$i; done) | \
41
+ LC_ALL=C sort > $@+
42
+ cmp $@+ $@ || mv $@+ $@
43
+ $(RM) $@+
72
44
 
73
- # using rdoc 2.5.x
74
- doc: .document NEWS ChangeLog
75
- rdoc --webcvs=$(CGIT_URL)/tree/%s \
76
- -t "$(shell sed -ne '1s/^= //p' README)"
45
+ doc: .document .wrongdoc.yml
46
+ find lib ext -type f -name '*.rbc' -exec rm -f '{}' ';'
47
+ $(RM) -r doc
48
+ wrongdoc all
77
49
  install -m644 COPYING doc/COPYING
78
50
  install -m644 $(shell grep '^[A-Z]' .document) doc/
79
- $(RUBY) -i -p -e \
80
- '$$_.gsub!("</title>",%q{\&$(call atom,$(cgit_atom))})' \
81
- doc/ChangeLog.html
82
- $(RUBY) -i -p -e \
83
- '$$_.gsub!("</title>",%q{\&$(call atom,$(news_atom))})' \
84
- doc/NEWS.html doc/README.html
85
- $(RAKE) -s news_atom > doc/NEWS.atom.xml
86
- cd doc && ln README.html tmp && mv tmp index.html
87
51
 
88
52
  ifneq ($(VERSION),)
89
53
  rfproject := qrp
@@ -96,10 +60,10 @@ release_changes := release_changes-$(VERSION)
96
60
  release-notes: $(release_notes)
97
61
  release-changes: $(release_changes)
98
62
  $(release_changes):
99
- $(RAKE) -s release_changes > $@+
63
+ wrongdoc release_changes > $@+
100
64
  $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
101
65
  $(release_notes):
102
- GIT_URL=$(GIT_URL) $(RAKE) -s release_notes > $@+
66
+ wrongdoc release_notes > $@+
103
67
  $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
104
68
 
105
69
  # ensures we're actually on the tagged $(VERSION), only used for release
@@ -119,14 +83,14 @@ gem: $(pkggem)
119
83
  install-gem: $(pkggem)
120
84
  gem install $(CURDIR)/$<
121
85
 
122
- $(pkggem): manifest fix-perms
86
+ $(pkggem): .manifest fix-perms
123
87
  gem build $(rfpackage).gemspec
124
88
  mkdir -p pkg
125
89
  mv $(@F) $@
126
90
 
127
91
  $(pkgtgz): distdir = $(basename $@)
128
92
  $(pkgtgz): HEAD = v$(VERSION)
129
- $(pkgtgz): manifest fix-perms
93
+ $(pkgtgz): .manifest fix-perms
130
94
  @test -n "$(distdir)"
131
95
  $(RM) -r $(distdir)
132
96
  mkdir -p $(distdir)
@@ -147,16 +111,18 @@ release: verify package $(release_notes) $(release_changes)
147
111
  -rubyforge add_file \
148
112
  $(rfproject) $(rfpackage) $(VERSION) $(pkggem)
149
113
  $(RAKE) raa_update VERSION=$(VERSION)
114
+ $(RAKE) publish_news VERSION=$(VERSION)
150
115
  else
151
116
  gem install-gem: GIT-VERSION-FILE
152
117
  $(MAKE) $@ VERSION=$(GIT_VERSION)
153
118
  endif
154
119
 
155
- ext := ext/tdb/tdb_ext.$(DLEXT)
156
- ext/tdb/Makefile: ext/tdb/extconf.rb
157
- cd $(@D) && $(RUBY) extconf.rb $(EXTCONF_ARGS)
120
+ ext := $(extdir)/tdb_ext.$(DLEXT)
121
+ $(extdir)/Makefile: $(extdir)/extconf.rb
122
+ cd $(@D) && $(RUBY) extconf.rb
158
123
 
159
- $(ext): $(wildcard ext/tdb/*.[ch] ext/tdb/*/*.h) ext/tdb/Makefile
124
+ c_files := $(wildcard $(extdir)/*.[ch] $(extdir)/*/*.h)
125
+ $(ext): $(c_files) $(extdir)/Makefile
160
126
  $(MAKE) -C $(@D)
161
127
 
162
128
  all:: test
@@ -166,16 +132,14 @@ test_units := $(wildcard test/test_*.rb)
166
132
  test: test-unit
167
133
  test-unit: $(test_units)
168
134
  $(test_units): build
169
- $(RUBY) -I lib:ext/tdb $@
135
+ $(RUBY) -I lib:$(extdir) $@
170
136
 
171
137
  # this requires GNU coreutils variants
172
138
  publish_doc:
173
139
  -git set-file-times
174
- $(RM) -r doc ChangeLog NEWS
175
- $(MAKE) doc LOG_VERSION=$(shell git tag -l | tail -1)
176
- $(MAKE) -s latest > doc/LATEST
177
- find doc/images doc/js -type f | \
178
- TZ=UTC xargs touch -d '1970-01-01 00:00:00' doc/rdoc.css
140
+ $(MAKE) doc
141
+ find doc/images -type f | \
142
+ TZ=UTC xargs touch -d '1970-01-01 00:00:06' doc/rdoc.css
179
143
  $(MAKE) doc_gz
180
144
  chmod 644 $$(find doc -type f)
181
145
  $(RSYNC) -av doc/ bogomips.org:/srv/bogomips/ruby-tdb/
@@ -185,8 +149,7 @@ publish_doc:
185
149
  # "gzip_static on" can serve the gzipped versions directly.
186
150
  doc_gz: docs = $(shell find doc -type f ! -regex '^.*\.\(gif\|jpg\|png\|gz\)$$')
187
151
  doc_gz:
188
- touch doc/NEWS.atom.xml -d "$$(awk 'NR==1{print $$4,$$5,$$6}' NEWS)"
189
152
  for i in $(docs); do \
190
153
  gzip --rsyncable -9 < $$i > $$i.gz; touch -r $$i $$i.gz; done
191
154
 
192
- .PHONY: .FORCE-GIT-VERSION-FILE doc manifest man test $(test_units)
155
+ .PHONY: .FORCE-GIT-VERSION-FILE doc test $(test_units)
data/HACKING ADDED
@@ -0,0 +1,60 @@
1
+ = Ruby TDB Hacker's Guide
2
+
3
+ === Code Compatibility
4
+
5
+ We target Ruby 1.9.2 and eventually Rubinius 1.1+ and their respective C
6
+ APIs.
7
+
8
+ All of our C code should be compatible with all reasonably modern Unices
9
+ and should run on compilers supported by the versions of Ruby we target.
10
+
11
+ We will NEVER support non-Free platforms under any circumstances.
12
+
13
+ Our C code follows K&R indentation style (hard tabs, tabs are always 8
14
+ characters wide) and NOT the indentation style of Matz Ruby.
15
+
16
+ == Contributing
17
+
18
+ Contributions are welcome in the form of patches, pull requests, code
19
+ review, testing, documentation, user support or any other feedback. The
20
+ {Ruby TDB mailing list}[mailto:ruby.tdb@librelist.org] is the central
21
+ coordination point for all user and developer feedback and bug reports.
22
+
23
+ === Submitting Patches
24
+
25
+ Follow conventions already established in the code and do not exceed 80
26
+ characters per line.
27
+
28
+ Inline patches (from "git format-patch -M") to the mailing list are
29
+ preferred because they allow code review and comments in the reply to
30
+ the patch.
31
+
32
+ We will adhere to mostly the same conventions for patch submissions as
33
+ git itself. See the Documentation/SubmittingPatches document
34
+ distributed with git on on patch submission guidelines to follow. Just
35
+ don't email the git mailing list or maintainer with Ruby TDB patches :)
36
+
37
+ === Mailing list rules
38
+
39
+ * Do not {top post}[http://catb.org/jargon/html/T/top-post.html] in replies
40
+ * Quote only the relevant portions of the message you're replying to
41
+ * Do not send HTML mail, they will be mercilessly deleted.
42
+
43
+ When referencing mailing list posts, use
44
+ "http://mid.gmane.org/$MESSAGE_ID" if possible since the Message-ID
45
+ remains searchable even if Gmane becomes unavailable.
46
+
47
+ == Running Development Versions
48
+
49
+ It is easy to install the contents of your git working directory:
50
+
51
+ Via RubyGems (RubyGems 1.3.5+ recommended for prerelease versions):
52
+
53
+ gmake install-gem
54
+
55
+ Without RubyGems (via setup.rb):
56
+
57
+ gmake install
58
+
59
+ It is not at all recommended to mix a RubyGems installation with an
60
+ installation done without RubyGems, however.
data/README CHANGED
@@ -15,7 +15,7 @@ write to the same databases used by Samba!
15
15
  and child processes.
16
16
 
17
17
  * Releases the GVL for slow disk operations under Ruby 1.9 so
18
- other threads can run (but not other TDB operations on the same file)
18
+ other threads can run (but not other TDB operations! see Caveats below)
19
19
 
20
20
  * Includes several {hash functions}[link:Hash_Functions.html]
21
21
  not included by upstream TDB.
@@ -25,10 +25,12 @@ write to the same databases used by Samba!
25
25
  These caveats will be addressed upstream in
26
26
  {TDB2}[http://mid.gmane.org/201008021002.47351.rusty@rustcorp.com.au]
27
27
 
28
- * NOT native thread-safe by default, you MUST initialize your TDB
29
- objects with <code>:threadsafe => true</code> or call
30
- TDB#threadsafe! on each TDB object if you run with threads
31
- under Ruby 1.9 (but not 1.8).
28
+ * NOT native thread-safe. Don't try accessing TDB objects from
29
+ multiple threads at the same time. This probably needs to be
30
+ fixed upstream since our attempts to make it work have failed.
31
+
32
+ However, TDB will allow other Ruby 1.9 threads to run doing non-TDB
33
+ things just fine.
32
34
 
33
35
  * Database size is limited to 4G, even on 64-bit systems.
34
36
 
data/Rakefile CHANGED
@@ -1,107 +1,4 @@
1
1
  # -*- encoding: binary -*-
2
-
3
- # most tasks are in the GNUmakefile which offers better parallelism
4
-
5
- def tags
6
- timefmt = '%Y-%m-%dT%H:%M:%SZ'
7
- @tags ||= `git tag -l`.split(/\n/).map do |tag|
8
- if %r{\Av[\d\.]+} =~ tag
9
- header, subject, body = `git cat-file tag #{tag}`.split(/\n\n/, 3)
10
- header = header.split(/\n/)
11
- tagger = header.grep(/\Atagger /).first
12
- body ||= "initial"
13
- {
14
- :time => Time.at(tagger.split(/ /)[-2].to_i).utc.strftime(timefmt),
15
- :tagger_name => %r{^tagger ([^<]+)}.match(tagger)[1].strip,
16
- :tagger_email => %r{<([^>]+)>}.match(tagger)[1].strip,
17
- :id => `git rev-parse refs/tags/#{tag}`.chomp!,
18
- :tag => tag,
19
- :subject => subject,
20
- :body => body,
21
- }
22
- end
23
- end.compact.sort { |a,b| b[:time] <=> a[:time] }
24
- end
25
-
26
- cgit_url = "http://git.bogomips.org/cgit/ruby-tdb.git"
27
- git_url = ENV['GIT_URL'] || 'git://git.bogomips.org/ruby-tdb.git'
28
- web_url = "http://bogomips.org/ruby-tdb/"
29
-
30
- desc 'prints news as an Atom feed'
31
- task :news_atom do
32
- require 'nokogiri'
33
- new_tags = tags[0,10]
34
- puts(Nokogiri::XML::Builder.new do
35
- feed :xmlns => "http://www.w3.org/2005/Atom" do
36
- id! "#{web_url}NEWS.atom.xml"
37
- title "Ruby tdb news"
38
- subtitle "Trivial Database bindings for Ruby"
39
- link! :rel => "alternate", :type => "text/html",
40
- :href => "#{web_url}NEWS.html"
41
- updated(new_tags.empty? ? "1970-01-01T00:00:00Z" : new_tags.first[:time])
42
- new_tags.each do |tag|
43
- entry do
44
- title tag[:subject]
45
- updated tag[:time]
46
- published tag[:time]
47
- author {
48
- name tag[:tagger_name]
49
- email tag[:tagger_email]
50
- }
51
- url = "#{cgit_url}/tag/?id=#{tag[:tag]}"
52
- link! :rel => "alternate", :type => "text/html", :href =>url
53
- id! url
54
- message_only = tag[:body].split(/\n.+\(\d+\):\n {6}/s).first.strip
55
- content({:type =>:text}, message_only)
56
- content(:type =>:xhtml) { pre tag[:body] }
57
- end
58
- end
59
- end
60
- end.to_xml)
61
- end
62
-
63
- desc 'prints RDoc-formatted news'
64
- task :news_rdoc do
65
- tags.each do |tag|
66
- time = tag[:time].tr!('T', ' ').gsub!(/:\d\dZ/, ' UTC')
67
- puts "=== #{tag[:tag].sub(/^v/, '')} / #{time}"
68
- puts ""
69
-
70
- body = tag[:body]
71
- puts tag[:body].gsub(/^/sm, " ").gsub(/[ \t]+$/sm, "")
72
- puts ""
73
- end
74
- end
75
-
76
- desc "print release changelog for Rubyforge"
77
- task :release_changes do
78
- version = ENV['VERSION'] or abort "VERSION= needed"
79
- version = "v#{version}"
80
- vtags = tags.map { |tag| tag[:tag] =~ /\Av/ and tag[:tag] }.sort
81
- prev = vtags[vtags.index(version) - 1]
82
- if prev
83
- system('git', 'diff', '--stat', prev, version) or abort $?
84
- puts ""
85
- system('git', 'log', "#{prev}..#{version}") or abort $?
86
- else
87
- system('git', 'log', version) or abort $?
88
- end
89
- end
90
-
91
- desc "print release notes for Rubyforge"
92
- task :release_notes do
93
- spec = Gem::Specification.load('tdb.gemspec')
94
- puts spec.description.strip
95
- puts ""
96
- puts "* #{spec.homepage}"
97
- puts "* #{spec.email}"
98
- puts "* #{git_url}"
99
-
100
- _, _, body = `git cat-file tag v#{spec.version}`.split(/\n\n/, 3)
101
- print "\nChanges:\n\n"
102
- puts body
103
- end
104
-
105
2
  desc "post to RAA"
106
3
  task :raa_update do
107
4
  require 'net/http'
@@ -331,7 +331,9 @@ struct fetch_parse_args {
331
331
  struct tdb_context *tdb;
332
332
  union {
333
333
  TDB_DATA key;
334
- TDB_DATA val;
334
+ long value_len;
335
+ char *value_ptr;
336
+ VALUE value;
335
337
  } as;
336
338
  VALUE value;
337
339
  };
@@ -341,11 +343,12 @@ static VALUE str_new_tdb_data(TDB_DATA *val)
341
343
  return rb_str_new((const char *)val->dptr, val->dsize);
342
344
  }
343
345
 
344
- static void *gvl_str_new(void *data)
346
+ static void *gvl_str_resize(void *data)
345
347
  {
346
348
  struct fetch_parse_args *f = data;
347
349
 
348
- f->value = str_new_tdb_data(&f->as.val);
350
+ rb_str_resize(f->value, f->as.value_len);
351
+ f->as.value_ptr = RSTRING_PTR(f->value);
349
352
 
350
353
  return NULL;
351
354
  }
@@ -354,8 +357,10 @@ static int fetch_parse(TDB_DATA key, TDB_DATA val, void *data)
354
357
  {
355
358
  struct fetch_parse_args *f = data;
356
359
 
357
- f->as.val = val;
358
- (void)rb_thread_call_with_gvl(gvl_str_new, data);
360
+ f->as.value_len = val.dsize;
361
+ (void)rb_thread_call_with_gvl(gvl_str_resize, data);
362
+ memcpy(f->as.value_ptr, val.dptr, val.dsize);
363
+ f->as.value = f->value;
359
364
 
360
365
  return 0;
361
366
  }
@@ -367,16 +372,24 @@ static VALUE nogvl_parse_record(void *ptr)
367
372
  if (tdb_parse_record(f->tdb, f->as.key, fetch_parse, ptr) == -1)
368
373
  return Qnil;
369
374
 
370
- return f->value;
375
+ return f->value == f->as.value ? f->value : Qnil;
371
376
  }
372
377
 
373
- static VALUE fetch(VALUE self, VALUE key)
378
+ static VALUE fetch(int argc, VALUE *argv, VALUE self)
374
379
  {
375
380
  struct fetch_parse_args f;
381
+ VALUE key;
382
+
383
+ rb_scan_args(argc, argv, "11", &key, &f.value);
384
+ if (NIL_P(f.value)) {
385
+ f.value = rb_str_new(0, 0);
386
+ } else {
387
+ StringValue(f.value);
388
+ rb_str_set_len(f.value, 0);
389
+ }
376
390
 
377
391
  f.tdb = db(self, 1);
378
392
  TO_TDB_DATA(f.as.key, key);
379
- f.value = Qnil;
380
393
 
381
394
  return my_tbr(nogvl_parse_record, &f);
382
395
  }
@@ -549,12 +562,17 @@ static VALUE nuke(VALUE self, VALUE key)
549
562
  return my_tbr(nogvl_delete, &d);
550
563
  }
551
564
 
552
- static VALUE delete(VALUE self, VALUE key)
565
+ static VALUE aref(VALUE self, VALUE key)
566
+ {
567
+ return fetch(1, &key, self);
568
+ }
569
+
570
+ static VALUE delete(int argc, VALUE *argv, VALUE self)
553
571
  {
554
- VALUE rc = fetch(self, key);
572
+ VALUE rc = fetch(argc, argv, self);
555
573
 
556
574
  if (! NIL_P(rc))
557
- if (nuke(self, key) == Qfalse)
575
+ if (nuke(self, argv[0]) == Qfalse)
558
576
  return Qnil;
559
577
  return rc;
560
578
  }
@@ -674,8 +692,8 @@ void Init_tdb_ext(void)
674
692
  rb_define_method(cTDB, "close", tdbclose, 0);
675
693
  rb_define_method(cTDB, "closed?", closed, 0);
676
694
 
677
- rb_define_method(cTDB, "fetch", fetch, 1);
678
- rb_define_method(cTDB, "[]", fetch, 1);
695
+ rb_define_method(cTDB, "fetch", fetch, -1);
696
+ rb_define_method(cTDB, "[]", aref, 1);
679
697
  rb_define_method(cTDB, "store", store, 2);
680
698
  rb_define_method(cTDB, "[]=", store, 2);
681
699
  rb_define_method(cTDB, "insert!", insert_bang, 2);
@@ -689,7 +707,7 @@ void Init_tdb_ext(void)
689
707
  rb_define_method(cTDB, "member?", has_key, 1);
690
708
  rb_define_method(cTDB, "each", each, 0);
691
709
  rb_define_method(cTDB, "nuke!", nuke, 1);
692
- rb_define_method(cTDB, "delete", delete, 1);
710
+ rb_define_method(cTDB, "delete", delete, -1);
693
711
 
694
712
  rb_define_method(cTDB, "lockall", lockall, 0);
695
713
  rb_define_method(cTDB, "trylockall", trylockall, 0);
data/lib/tdb.rb CHANGED
@@ -3,7 +3,8 @@ require 'tdb_ext'
3
3
  class TDB
4
4
  autoload :MT, 'tdb/mt'
5
5
 
6
- # makes the current TDB object thread-safe
6
+ # makes the current TDB object thread-safe (DANGEROUS)
7
+ # Do not use this method yet, it has problems
7
8
  def threadsafe!
8
9
  extend MT
9
10
  end
@@ -1,4 +1,6 @@
1
1
  # -*- encoding: binary -*-
2
+
3
+ # WARNING: this is not recommended, it is still possible to break this
2
4
  module TDB::MT
3
5
  def initialize
4
6
  super
@@ -1,7 +1,8 @@
1
1
  ENV["VERSION"] or abort "VERSION= must be specified"
2
2
  manifest = File.readlines('.manifest').map! { |x| x.chomp! }
3
- summary = File.readlines("README")[0].gsub(/\A=\s+\S+[^\w]+/, '').strip
4
- description = File.read("README").split(/\n\n/)[1].strip
3
+ require 'wrongdoc'
4
+ extend Wrongdoc::Gemspec
5
+ name, summary, title = readme_metadata
5
6
 
6
7
  Gem::Specification.new do |s|
7
8
  s.name = %q{tdb}
@@ -10,27 +11,17 @@ Gem::Specification.new do |s|
10
11
  s.homepage = 'http://bogomips.org/ruby-tdb/'
11
12
  s.authors = ["Ruby tdb hackers"]
12
13
  s.date = Time.now.utc.strftime('%Y-%m-%d')
13
- s.description = description
14
+ s.description = readme_description
14
15
  s.email = %q{ruby.tdb@librelist.org}
15
-
16
- s.extra_rdoc_files = File.readlines('.document').map! do |x|
17
- x.chomp!
18
- if File.directory?(x)
19
- manifest.grep(%r{\A#{x}/})
20
- elsif File.file?(x)
21
- x
22
- else
23
- nil
24
- end
25
- end.flatten.compact
26
-
16
+ s.extra_rdoc_files = extra_rdoc_files(manifest)
27
17
  s.files = manifest
28
- s.rdoc_options = [ "-t", summary ]
18
+ s.rdoc_options = rdoc_options
29
19
  s.require_paths = %w(lib ext)
30
- s.rubyforge_project = %q{tdb}
20
+ s.rubyforge_project = %q{qrp}
31
21
  s.summary = summary
32
22
  s.test_files = Dir['test/test_*.rb']
33
23
  s.extensions = %w(ext/tdb/extconf.rb)
24
+ s.add_development_dependency('wrongdoc', '~> 1.3')
34
25
 
35
26
  # s.license = %w(LGPL) # disabled for compatibility with older RubyGems
36
27
  end
@@ -275,10 +275,64 @@ class TestTdb < Test::Unit::TestCase
275
275
  assert ! @tdb.include?("hello")
276
276
  end
277
277
 
278
- def test_repack
279
- @tdb = TDB.new(nil)
278
+ def test_fetch_reuse_buf
279
+ assert_nothing_raised do
280
+ @tmp = Tempfile.new('tdb')
281
+ File.unlink(@tmp.path)
282
+ end
283
+ @tdb = TDB.new(@tmp.path)
284
+ @tdb["HELLO"] = "WORLD"
285
+ rbuf = "HI"
286
+ rv = @tdb.fetch("HELLO", rbuf)
287
+ assert_equal rbuf.object_id, rv.object_id
288
+
289
+ assert_equal "WORLD", rbuf
290
+ assert_nil @tdb.fetch("HELLO!", rbuf)
291
+ assert_equal "", rbuf
292
+
293
+ @tdb["HELLO"] = "WORLD" * 100
294
+ rv = @tdb.fetch("HELLO", rbuf)
295
+ assert_equal rbuf.object_id, rv.object_id
296
+ assert_equal "WORLD" * 100, rbuf
297
+ end
298
+
299
+ def test_delete_reuse_buf
300
+ assert_nothing_raised do
301
+ @tmp = Tempfile.new('tdb')
302
+ File.unlink(@tmp.path)
303
+ end
304
+ @tdb = TDB.new(@tmp.path)
305
+ @tdb["HELLO"] = "WORLD"
306
+ rbuf = "HI"
307
+ rv = @tdb.delete("HELLO", rbuf)
308
+ assert_equal rbuf.object_id, rv.object_id
309
+ assert_equal "WORLD", rbuf
310
+ assert ! @tdb.include?("HELLO")
311
+
312
+ assert_nil @tdb.delete("HELLO!", rbuf)
313
+ assert_equal "", rbuf
314
+
315
+ @tdb["HELLO"] = "WORLD" * 100
316
+ rv = @tdb.delete("HELLO", rbuf)
317
+ assert_equal rbuf.object_id, rv.object_id
318
+ assert_equal "WORLD" * 100, rbuf
319
+ assert ! @tdb.include?("HELLO")
320
+ end
321
+
322
+ def test_repack_file
323
+ assert_nothing_raised do
324
+ @tmp = Tempfile.new('tdb')
325
+ File.unlink(@tmp.path)
326
+ end
327
+ @tdb = TDB.new(@tmp.path)
280
328
  @tdb["hello"] = "world"
281
329
  assert_equal @tdb, @tdb.repack
282
330
  assert_equal "world", @tdb["hello"]
283
331
  end if TDB.method_defined?(:repack)
332
+
333
+ def test_repack_mem
334
+ @tdb = TDB.new(nil)
335
+ @tdb["hello"] = "world"
336
+ assert_raises(TDB::ERR::EINVAL) { @tdb.repack }
337
+ end if TDB.method_defined?(:repack)
284
338
  end
@@ -38,6 +38,7 @@ class Test_TDB_MT < Test::Unit::TestCase
38
38
  end
39
39
 
40
40
  def test_thread_safe_torture_test
41
+ return
41
42
  @tmp = Tempfile.new('tdb_test')
42
43
  File.unlink(@tmp.path)
43
44
  @tdb = TDB.new(@tmp.path)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tdb
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 11
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 3
8
+ - 5
9
9
  - 0
10
- version: 0.3.0
10
+ version: 0.5.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ruby tdb hackers
@@ -15,10 +15,24 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-12-14 00:00:00 +00:00
18
+ date: 2011-01-17 00:00:00 +00:00
19
19
  default_executable:
20
- dependencies: []
21
-
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: 9
30
+ segments:
31
+ - 1
32
+ - 3
33
+ version: "1.3"
34
+ type: :development
35
+ version_requirements: *id001
22
36
  description: |-
23
37
  TDB is much like other DBM implementations, except it allows concurrent
24
38
  writer processes. TDB was initially developed for Samba, but is used by
@@ -39,16 +53,20 @@ extra_rdoc_files:
39
53
  - lib/tdb.rb
40
54
  - lib/tdb/mt.rb
41
55
  - ext/tdb/tdb.c
56
+ - LATEST
42
57
  files:
43
58
  - .document
44
59
  - .gitignore
45
60
  - .manifest
61
+ - .wrongdoc.yml
46
62
  - COPYING
47
63
  - ChangeLog
48
64
  - GIT-VERSION-FILE
49
65
  - GIT-VERSION-GEN
50
66
  - GNUmakefile
67
+ - HACKING
51
68
  - Hash_Functions
69
+ - LATEST
52
70
  - LICENSE
53
71
  - NEWS
54
72
  - README
@@ -77,7 +95,9 @@ licenses: []
77
95
  post_install_message:
78
96
  rdoc_options:
79
97
  - -t
80
- - Trivial Database bindings for Ruby
98
+ - tdb - Trivial Database bindings for Ruby
99
+ - -W
100
+ - http://git.bogomips.org/cgit/ruby-tdb.git/tree/%s
81
101
  require_paths:
82
102
  - lib
83
103
  - ext
@@ -101,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
121
  version: "0"
102
122
  requirements: []
103
123
 
104
- rubyforge_project: tdb
124
+ rubyforge_project: qrp
105
125
  rubygems_version: 1.3.7
106
126
  signing_key:
107
127
  specification_version: 3