Commit a1f63edd authored by Nicholas Guriev's avatar Nicholas Guriev

Remove ruby-bdb dependency

parent 3cd86ca1
dhelp (0.6.22) unstable; urgency=medium
* QA upload.
* Remove ruby-bdb dependency (closes: #791770)
- Migrate to a module from the standard library.
- Update tests.
* Replace perl-modules dependency with just perl.
-- Nicholas Guriev <guriev-ns@ya.ru> Wed, 26 Apr 2017 13:08:42 +0300
dhelp (0.6.21+nmu7) unstable; urgency=medium
* Non-maintainer upload.
......
......@@ -7,9 +7,9 @@ Build-Depends: debhelper (>= 5), cdbs (>= 0.4.23-1.1),
ruby-gettext
Package: dhelp
Depends: perl-modules, libtemplate-perl, libhtml-parser-perl,
Depends: perl, libtemplate-perl, libhtml-parser-perl,
liburi-perl, liblocale-gettext-perl, libdata-page-perl,
ruby | ruby-interpreter, ruby-bdb, ruby-debian, ruby-gettext,
ruby | ruby-interpreter, ruby-debian, ruby-gettext,
doc-base, swish++, pstotext, poppler-utils, ucf (>= 0.8),
${misc:Depends}
Recommends: www-browser | html2text
......
......@@ -2,7 +2,7 @@ require 'dhelp'
path = ARGV.shift || Dhelp::DOC_DIR_DATABASE
puts "Opening #{path}"
ddd = Dhelp::DocDirDatabase.open(BDB::RDONLY, path)
ddd = Dhelp::DocDirDatabase.open(DBM::READER, path)
ddd.each do |dir, doc_id, title|
puts "#{dir} -> #{doc_id} (#{title})"
end
......@@ -18,7 +18,7 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
=end
require 'bdb'
require 'dbm'
require 'pathname'
require 'fileutils'
......@@ -239,23 +239,18 @@ module Dhelp
# Database for doc-base directories. It contains base directories associated
# with the corresponding doc-base doc id and the document title.
class DocDirDatabase < BDB::Hash
def self.open(flags = BDB::RDONLY,
class DocDirDatabase < DBM
def self.open(flags = DBM::READER,
name = DOC_DIR_DATABASE,
options = {},
mode = 0644)
default_options = {"ffactor" => 8,
"nelem" => 1,
"cachesize" => 5000,
"hash" => nil,
"lorder" => 0}
super(name, nil, flags, mode, default_options.merge(options))
super(name, mode, flags)
end
# Traverse entire BD, passing directory, doc_id and title of each item to
# the block
def each
super do |k,v|
each_pair do |k,v|
value = DocDirDatabaseValue.new(v)
yield DocDirDatabaseKey.new(k).dir, value.doc_id, value.title
end
......@@ -266,19 +261,19 @@ module Dhelp
def add(dir, doc_id, title)
key = DocDirDatabaseKey.new(:dir => dir)
value = DocDirDatabaseValue.new(:doc_id => doc_id, :title => title)
put(key.to_raw_data, value.to_raw_data)
self[key.to_raw_data] = value.to_raw_data
end
def include?(dir)
key = DocDirDatabaseKey.new(:dir => dir)
return super(key.to_raw_data)
return has_key?(key.to_raw_data)
end
# Returns an array with two elements, doc_id and title, for the registered
# doc-base document in the given directory
def info_for_path(dir)
key = DocDirDatabaseKey.new(:dir => dir)
raw_value = get(key.to_raw_data)
raw_value = self[key.to_raw_data]
if raw_value.nil?
raise KeyNotFoundError, "Can't find information for path #{dir}"
end
......@@ -448,10 +443,11 @@ module Dhelp
# Registers a list of doc-base documents as part of Dhelp
def _register_docs(doc_list, user_opts={})
register_opts = {:regenerate_index => false}.merge(user_opts)
open_flag = register_opts[:regenerate_index] ? (BDB::CREATE|
BDB::TRUNCATE) :
BDB::CREATE
doc_dir_db = DocDirDatabase.open(open_flag, @doc_dir_database)
if register_opts[:regenerate_index]
doc_dir_db = DocDirDatabase.open(DBM::NEWDB, @doc_dir_database)
else
doc_dir_db = DocDirDatabase.open(DBM::WRCREAT, @doc_dir_database)
end
index_paths = []
doc_list.each do |doc|
doc.formats.each do |format|
......
require 'test/unit'
require 'dhelp'
require 'fileutils'
require 'set'
class TC_DhelpDocumentPool < Test::Unit::TestCase
......@@ -57,7 +58,7 @@ class TC_DhelpDocumentPool < Test::Unit::TestCase
doc.formats.find {|f| f.format.downcase == 'html'}.index
# Register document, see if the containing directory is added
@pool.register(doc)
ddd = Dhelp::DocDirDatabase.open(BDB::RDONLY, TEST_DOC_DIR_DATABASE)
ddd = Dhelp::DocDirDatabase.open(DBM::READER, TEST_DOC_DIR_DATABASE)
assert_equal doc_id, ddd.info_for_path(File.dirname(index_file)).first
ddd.close
end
......@@ -84,7 +85,7 @@ class TC_DhelpDocumentPool < Test::Unit::TestCase
def test_doc_base_dirs
@pool.register(doc_base_document('docbook-xsl-doc-html'))
dddbh1 = Dhelp::DocDirDatabase.open(BDB::RDONLY, TEST_DOC_DIR_DATABASE)
dddbh1 = Dhelp::DocDirDatabase.open(DBM::READER, TEST_DOC_DIR_DATABASE)
assert dddbh1.include?('test/share-doc/docbook-xsl-doc-html/doc'),
"The docbook-xsl-doc-html directory should be registered"
assert !dddbh1.include?('test/share-doc/pica/manual.html'),
......@@ -92,7 +93,7 @@ class TC_DhelpDocumentPool < Test::Unit::TestCase
dddbh1.close
@pool.register(doc_base_document('pica-manual'))
dddbh2 = Dhelp::DocDirDatabase.open(BDB::RDONLY, TEST_DOC_DIR_DATABASE)
dddbh2 = Dhelp::DocDirDatabase.open(DBM::READER, TEST_DOC_DIR_DATABASE)
assert dddbh2.include?('test/share-doc/docbook-xsl-doc-html/doc'),
"The docbook-xsl-doc-html directory should still be registered"
assert dddbh2.include?('test/share-doc/pica/manual.html'),
......@@ -141,7 +142,7 @@ class TC_DhelpDocumentPool < Test::Unit::TestCase
# 5) Rebuild, check that the directory database doesn't include the deleted
# document
tmp_pool.rebuild
doc_dir_db = Dhelp::DocDirDatabase.open(BDB::RDONLY, dddb)
doc_dir_db = Dhelp::DocDirDatabase.open(DBM::READER, dddb)
assert !doc_dir_db.include?('test/tmp/share-doc/dir-test-1/manual.html'),
"The directory for dir-test-1 should NOT exist"
assert doc_dir_db.include?('test/tmp/share-doc/dir-test-2/manual.html'),
......@@ -155,7 +156,7 @@ class TC_DhelpDocumentPool < Test::Unit::TestCase
def test_register_dirs
doc = Dhelp::DocBaseDocument.new('test/doc-base/ghc6-users-guide')
@pool.register(doc)
ddd = Dhelp::DocDirDatabase.open(BDB::RDONLY, TEST_DOC_DIR_DATABASE)
ddd = Dhelp::DocDirDatabase.open(DBM::READER, TEST_DOC_DIR_DATABASE)
assert ddd.include?('test/share-doc/ghc6-doc/html/libraries'),
"Docdir should include the libraries subdir"
assert ddd.include?('test/share-doc/ghc6-doc/html'),
......@@ -165,7 +166,7 @@ class TC_DhelpDocumentPool < Test::Unit::TestCase
def teardown
@pool = nil
@doc_base_id_set = nil
FileUtils.rm_f TEST_DOC_DIR_DATABASE
FileUtils.rm_f Dir.glob("#{TEST_DOC_DIR_DATABASE}.*")
FileUtils.rm_f TEST_INDEX_FILE
FileUtils.rm_f TEST_PENDING_FILE
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment