gonzui 1.2-x86-mswin32-60
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS.txt +9 -0
- data/History.txt +5539 -0
- data/Manifest.txt +115 -0
- data/PostInstall.txt +17 -0
- data/README.rdoc +149 -0
- data/Rakefile +28 -0
- data/bin/gonzui-db +167 -0
- data/bin/gonzui-import +177 -0
- data/bin/gonzui-remove +58 -0
- data/bin/gonzui-search +68 -0
- data/bin/gonzui-server +176 -0
- data/bin/gonzui-update +53 -0
- data/data/gonzui/catalog/catalog.ja +80 -0
- data/data/gonzui/doc/favicon.ico +0 -0
- data/data/gonzui/doc/folder.png +0 -0
- data/data/gonzui/doc/gonzui.css +279 -0
- data/data/gonzui/doc/gonzui.js +111 -0
- data/data/gonzui/doc/text.png +0 -0
- data/data/gonzuirc.sample +29 -0
- data/ext/autopack/autopack.c +88 -0
- data/ext/autopack/extconf.rb +3 -0
- data/ext/delta/delta.c +147 -0
- data/ext/delta/extconf.rb +5 -0
- data/ext/texttokenizer/extconf.rb +5 -0
- data/ext/texttokenizer/texttokenizer.c +93 -0
- data/ext/xmlformatter/extconf.rb +5 -0
- data/ext/xmlformatter/xmlformatter.c +207 -0
- data/lib/gonzui.rb +59 -0
- data/lib/gonzui/apt.rb +193 -0
- data/lib/gonzui/autopack.so +0 -0
- data/lib/gonzui/bdbdbm.rb +118 -0
- data/lib/gonzui/cmdapp.rb +14 -0
- data/lib/gonzui/cmdapp/app.rb +175 -0
- data/lib/gonzui/cmdapp/search.rb +134 -0
- data/lib/gonzui/config.rb +117 -0
- data/lib/gonzui/content.rb +19 -0
- data/lib/gonzui/dbm.rb +673 -0
- data/lib/gonzui/deindexer.rb +162 -0
- data/lib/gonzui/delta.rb +49 -0
- data/lib/gonzui/delta.so +0 -0
- data/lib/gonzui/extractor.rb +347 -0
- data/lib/gonzui/fetcher.rb +309 -0
- data/lib/gonzui/gettext.rb +144 -0
- data/lib/gonzui/importer.rb +84 -0
- data/lib/gonzui/indexer.rb +316 -0
- data/lib/gonzui/info.rb +80 -0
- data/lib/gonzui/license.rb +100 -0
- data/lib/gonzui/logger.rb +48 -0
- data/lib/gonzui/monitor.rb +177 -0
- data/lib/gonzui/progressbar.rb +235 -0
- data/lib/gonzui/remover.rb +38 -0
- data/lib/gonzui/searcher.rb +330 -0
- data/lib/gonzui/searchquery.rb +235 -0
- data/lib/gonzui/searchresult.rb +111 -0
- data/lib/gonzui/texttokenizer.so +0 -0
- data/lib/gonzui/updater.rb +254 -0
- data/lib/gonzui/util.rb +415 -0
- data/lib/gonzui/vcs.rb +128 -0
- data/lib/gonzui/webapp.rb +25 -0
- data/lib/gonzui/webapp/advsearch.rb +123 -0
- data/lib/gonzui/webapp/filehandler.rb +24 -0
- data/lib/gonzui/webapp/jsfeed.rb +61 -0
- data/lib/gonzui/webapp/markup.rb +445 -0
- data/lib/gonzui/webapp/search.rb +269 -0
- data/lib/gonzui/webapp/servlet.rb +319 -0
- data/lib/gonzui/webapp/snippet.rb +155 -0
- data/lib/gonzui/webapp/source.rb +37 -0
- data/lib/gonzui/webapp/stat.rb +137 -0
- data/lib/gonzui/webapp/top.rb +63 -0
- data/lib/gonzui/webapp/uri.rb +140 -0
- data/lib/gonzui/webapp/webrick.rb +48 -0
- data/lib/gonzui/webapp/xmlformatter.so +0 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/makemanifest.rb +21 -0
- data/tasks/extconf.rake +13 -0
- data/tasks/extconf/autopack.rake +43 -0
- data/tasks/extconf/delta.rake +43 -0
- data/tasks/extconf/texttokenizer.rake +43 -0
- data/tasks/extconf/xmlformatter.rake +43 -0
- data/test/_external_tools.rb +13 -0
- data/test/_test-util.rb +142 -0
- data/test/foo/Makefile.foo +66 -0
- data/test/foo/bar.c +5 -0
- data/test/foo/bar.h +6 -0
- data/test/foo/foo.c +25 -0
- data/test/foo/foo.spec +33 -0
- data/test/test_apt.rb +42 -0
- data/test/test_autopack_extn.rb +7 -0
- data/test/test_bdbdbm.rb +79 -0
- data/test/test_cmdapp-app.rb +35 -0
- data/test/test_cmdapp-search.rb +99 -0
- data/test/test_config.rb +28 -0
- data/test/test_content.rb +15 -0
- data/test/test_dbm.rb +171 -0
- data/test/test_deindexer.rb +50 -0
- data/test/test_delta.rb +66 -0
- data/test/test_extractor.rb +78 -0
- data/test/test_fetcher.rb +75 -0
- data/test/test_gettext.rb +50 -0
- data/test/test_gonzui.rb +11 -0
- data/test/test_helper.rb +10 -0
- data/test/test_importer.rb +56 -0
- data/test/test_indexer.rb +37 -0
- data/test/test_info.rb +82 -0
- data/test/test_license.rb +49 -0
- data/test/test_logger.rb +60 -0
- data/test/test_monitor.rb +23 -0
- data/test/test_searcher.rb +37 -0
- data/test/test_searchquery.rb +27 -0
- data/test/test_searchresult.rb +43 -0
- data/test/test_texttokenizer.rb +47 -0
- data/test/test_updater.rb +95 -0
- data/test/test_util.rb +149 -0
- data/test/test_vcs.rb +61 -0
- data/test/test_webapp-markup.rb +42 -0
- data/test/test_webapp-util.rb +19 -0
- data/test/test_webapp-xmlformatter.rb +19 -0
- metadata +292 -0
data/Manifest.txt
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
AUTHORS.txt
|
2
|
+
History.txt
|
3
|
+
Manifest.txt
|
4
|
+
PostInstall.txt
|
5
|
+
README.rdoc
|
6
|
+
Rakefile
|
7
|
+
bin/gonzui-db
|
8
|
+
bin/gonzui-import
|
9
|
+
bin/gonzui-remove
|
10
|
+
bin/gonzui-search
|
11
|
+
bin/gonzui-server
|
12
|
+
bin/gonzui-update
|
13
|
+
data/gonzui/catalog/catalog.ja
|
14
|
+
data/gonzui/doc/favicon.ico
|
15
|
+
data/gonzui/doc/folder.png
|
16
|
+
data/gonzui/doc/gonzui.css
|
17
|
+
data/gonzui/doc/gonzui.js
|
18
|
+
data/gonzui/doc/text.png
|
19
|
+
data/gonzuirc.sample
|
20
|
+
ext/autopack/autopack.c
|
21
|
+
ext/autopack/extconf.rb
|
22
|
+
ext/delta/delta.c
|
23
|
+
ext/delta/extconf.rb
|
24
|
+
ext/texttokenizer/extconf.rb
|
25
|
+
ext/texttokenizer/texttokenizer.c
|
26
|
+
ext/xmlformatter/extconf.rb
|
27
|
+
ext/xmlformatter/xmlformatter.c
|
28
|
+
lib/gonzui.rb
|
29
|
+
lib/gonzui/apt.rb
|
30
|
+
lib/gonzui/bdbdbm.rb
|
31
|
+
lib/gonzui/cmdapp.rb
|
32
|
+
lib/gonzui/cmdapp/app.rb
|
33
|
+
lib/gonzui/cmdapp/search.rb
|
34
|
+
lib/gonzui/config.rb
|
35
|
+
lib/gonzui/content.rb
|
36
|
+
lib/gonzui/dbm.rb
|
37
|
+
lib/gonzui/deindexer.rb
|
38
|
+
lib/gonzui/delta.rb
|
39
|
+
lib/gonzui/extractor.rb
|
40
|
+
lib/gonzui/fetcher.rb
|
41
|
+
lib/gonzui/gettext.rb
|
42
|
+
lib/gonzui/importer.rb
|
43
|
+
lib/gonzui/indexer.rb
|
44
|
+
lib/gonzui/info.rb
|
45
|
+
lib/gonzui/license.rb
|
46
|
+
lib/gonzui/logger.rb
|
47
|
+
lib/gonzui/monitor.rb
|
48
|
+
lib/gonzui/progressbar.rb
|
49
|
+
lib/gonzui/remover.rb
|
50
|
+
lib/gonzui/searcher.rb
|
51
|
+
lib/gonzui/searchquery.rb
|
52
|
+
lib/gonzui/searchresult.rb
|
53
|
+
lib/gonzui/updater.rb
|
54
|
+
lib/gonzui/util.rb
|
55
|
+
lib/gonzui/vcs.rb
|
56
|
+
lib/gonzui/webapp.rb
|
57
|
+
lib/gonzui/webapp/advsearch.rb
|
58
|
+
lib/gonzui/webapp/filehandler.rb
|
59
|
+
lib/gonzui/webapp/jsfeed.rb
|
60
|
+
lib/gonzui/webapp/markup.rb
|
61
|
+
lib/gonzui/webapp/search.rb
|
62
|
+
lib/gonzui/webapp/servlet.rb
|
63
|
+
lib/gonzui/webapp/snippet.rb
|
64
|
+
lib/gonzui/webapp/source.rb
|
65
|
+
lib/gonzui/webapp/stat.rb
|
66
|
+
lib/gonzui/webapp/top.rb
|
67
|
+
lib/gonzui/webapp/uri.rb
|
68
|
+
lib/gonzui/webapp/webrick.rb
|
69
|
+
script/console
|
70
|
+
script/destroy
|
71
|
+
script/generate
|
72
|
+
script/makemanifest.rb
|
73
|
+
tasks/extconf.rake
|
74
|
+
tasks/extconf/autopack.rake
|
75
|
+
tasks/extconf/delta.rake
|
76
|
+
tasks/extconf/texttokenizer.rake
|
77
|
+
tasks/extconf/xmlformatter.rake
|
78
|
+
test/_external_tools.rb
|
79
|
+
test/_test-util.rb
|
80
|
+
test/foo/Makefile.foo
|
81
|
+
test/foo/bar.c
|
82
|
+
test/foo/bar.h
|
83
|
+
test/foo/foo.c
|
84
|
+
test/foo/foo.spec
|
85
|
+
test/test_apt.rb
|
86
|
+
test/test_autopack_extn.rb
|
87
|
+
test/test_bdbdbm.rb
|
88
|
+
test/test_cmdapp-app.rb
|
89
|
+
test/test_cmdapp-search.rb
|
90
|
+
test/test_config.rb
|
91
|
+
test/test_content.rb
|
92
|
+
test/test_dbm.rb
|
93
|
+
test/test_deindexer.rb
|
94
|
+
test/test_delta.rb
|
95
|
+
test/test_extractor.rb
|
96
|
+
test/test_fetcher.rb
|
97
|
+
test/test_gettext.rb
|
98
|
+
test/test_gonzui.rb
|
99
|
+
test/test_helper.rb
|
100
|
+
test/test_importer.rb
|
101
|
+
test/test_indexer.rb
|
102
|
+
test/test_info.rb
|
103
|
+
test/test_license.rb
|
104
|
+
test/test_logger.rb
|
105
|
+
test/test_monitor.rb
|
106
|
+
test/test_searcher.rb
|
107
|
+
test/test_searchquery.rb
|
108
|
+
test/test_searchresult.rb
|
109
|
+
test/test_texttokenizer.rb
|
110
|
+
test/test_updater.rb
|
111
|
+
test/test_util.rb
|
112
|
+
test/test_vcs.rb
|
113
|
+
test/test_webapp-markup.rb
|
114
|
+
test/test_webapp-util.rb
|
115
|
+
test/test_webapp-xmlformatter.rb
|
data/PostInstall.txt
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
Welcome to gonzui!
|
2
|
+
|
3
|
+
First, you need to install Berkley DB 4.7 and
|
4
|
+
bdb for ruby (http://raa.ruby-lang.org/project/bdb/).
|
5
|
+
If you use Ubuntu linux, only type following commands.
|
6
|
+
$ sudo apt-get install libdb-dev
|
7
|
+
$ sudo apt-get install libdb-ruby1.8
|
8
|
+
|
9
|
+
First step:
|
10
|
+
$ mkdir gonzui
|
11
|
+
$ cd gonzui
|
12
|
+
$ gonzui-import path/to/project
|
13
|
+
$ gonzui-server
|
14
|
+
Access to http://localhost:46984/ and enjoy!
|
15
|
+
|
16
|
+
More information:
|
17
|
+
See README.rdoc
|
data/README.rdoc
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
= gonzui
|
2
|
+
|
3
|
+
* http://gonzui.sourceforge.net/index.html.en
|
4
|
+
* Gem version
|
5
|
+
* http://github.com/mallowlabs/gonzui
|
6
|
+
|
7
|
+
== DESCRIPTION:
|
8
|
+
|
9
|
+
gonzui is a source code search engine for accelerating open source software development. In the open source software development, programmers frequently refer to source codes written by others. Our goal is to help programmers develop programs effectively by creating a source code search engine that covers vast quantities of open source codes available on the Internet.
|
10
|
+
|
11
|
+
== FEATURES/PROBLEMS:
|
12
|
+
|
13
|
+
* Windows is not supported now.
|
14
|
+
|
15
|
+
== SYNOPSIS:
|
16
|
+
|
17
|
+
=== Basic Usage
|
18
|
+
|
19
|
+
First, You need to import source codes into an index. For example,
|
20
|
+
if you want to import the source codes of wget-1.9.1.tar.gz,
|
21
|
+
run the following command.
|
22
|
+
|
23
|
+
% gonzui-import wget-1.9.1.tar.gz
|
24
|
+
|
25
|
+
or if your system has apt-get and it's configured correctly,
|
26
|
+
|
27
|
+
% gonzui-import --apt wget
|
28
|
+
|
29
|
+
Then, you can run gonzui-server that works as a web-based search engine.
|
30
|
+
|
31
|
+
% gonzui-server
|
32
|
+
|
33
|
+
Finally, you can access the search engine with your browser.
|
34
|
+
The URL is http://localhost:46984/.
|
35
|
+
|
36
|
+
=== Import through version control systems
|
37
|
+
|
38
|
+
Currently, gonzui supports import from CVS and Subversion, Git's repositories.
|
39
|
+
For example, if you want to import source codes that can be obtained by the following command,
|
40
|
+
|
41
|
+
% cvs -d :pserver:anonymous@cvs.ruby-lang.org:/src co ruby
|
42
|
+
|
43
|
+
you can just run gonzui-import as follows.
|
44
|
+
|
45
|
+
% gonzui-import --cvs :pserver:anonymous@cvs.ruby-lang.org:/src ruby
|
46
|
+
|
47
|
+
In short, you can replace "cvs -d X co Y" with "gonzui-import --cvs X Y".
|
48
|
+
|
49
|
+
For Subversion, if you want to import source codes that can be obtained by the following command,
|
50
|
+
|
51
|
+
% svn co http://svn.edgewall.com/repos/trac/trunk trac
|
52
|
+
|
53
|
+
you can just run gonzui-import as follows.
|
54
|
+
|
55
|
+
% gonzui-import --svn http://svn.edgewall.com/repos/trac/trunk trac
|
56
|
+
|
57
|
+
In short, you can replace "svn co X Y" with "gonzui-import --svn X Y".
|
58
|
+
|
59
|
+
You can update the gonzui's index by gonzui-update command to reflect changes as described bellow.
|
60
|
+
|
61
|
+
Currently, gonzui doesn't support revisions and tags of CVS and Subversion.
|
62
|
+
|
63
|
+
=== Incremental Update
|
64
|
+
|
65
|
+
gonzui-update is a tool for doing incremental update of the existing indices.
|
66
|
+
For example, if you build an index by importing /somewhere/foo by the following command:
|
67
|
+
|
68
|
+
% gonzui-import /somewhere/foo
|
69
|
+
|
70
|
+
and then, you want to update the existing index for reflecting
|
71
|
+
recent changes (addition, deletion, and update of files) in /somewhere/foo,
|
72
|
+
you can just run gonzui-update like:
|
73
|
+
|
74
|
+
% gonzui-update
|
75
|
+
|
76
|
+
Since the index includes the location of /somewhere/foo,
|
77
|
+
you don't have to give any parameters to gonzui-update command.
|
78
|
+
If the existing index contains two or more packages,
|
79
|
+
all packages are supposed to be updated.
|
80
|
+
If /somewhere/foo is disappeared,
|
81
|
+
gonzui-update prints an warning like "source disappeared".
|
82
|
+
|
83
|
+
=== Other Usage
|
84
|
+
|
85
|
+
Command-line-based search tool is also available mainly for debug purposes.
|
86
|
+
To find locations of ``main'' function, run gonzui-search as follows.
|
87
|
+
|
88
|
+
% gonzui-search main
|
89
|
+
|
90
|
+
You can inspect gonzui's index using gonzui-db command.
|
91
|
+
To obtain the list of packages in the index, run gonzui-db as follows.
|
92
|
+
|
93
|
+
% gonzui-db --list
|
94
|
+
|
95
|
+
To remove wget-1.9.1, run gonzui-remove as follows.
|
96
|
+
|
97
|
+
% gonzui-remove wget-1.9.1
|
98
|
+
|
99
|
+
For further information on usage, try --help option of each command.
|
100
|
+
|
101
|
+
== REQUIREMENTS:
|
102
|
+
* Ruby 1.8.2+
|
103
|
+
* bdb 4.2+ (Berkeley DB)
|
104
|
+
$ sudo apt-get install libdb-dev
|
105
|
+
|
106
|
+
=== Ruby Libraries
|
107
|
+
* langscan 1.2+
|
108
|
+
$ sudo gem install langscan
|
109
|
+
* bdb for Ruby 0.5.2+
|
110
|
+
$ sudo apt-get install libdb-ruby1.8
|
111
|
+
|
112
|
+
== Optional Software
|
113
|
+
The following software is not required but useful.
|
114
|
+
* Archive Handling
|
115
|
+
* tar (.tar.*)
|
116
|
+
* gunzip (.tar.gz)
|
117
|
+
* bunzip2 (.tar.bz2)
|
118
|
+
* uncompress (.tar.Z)
|
119
|
+
* unzip (.zip)
|
120
|
+
* lha (.lzh)
|
121
|
+
* rpm, rpmbuild (.src.rpm)
|
122
|
+
* Source Code Fetcher
|
123
|
+
* apt-get (gonzui-import --apt)
|
124
|
+
* You need "dpkg-dev" package to fetch sources.
|
125
|
+
* Version Control Systems
|
126
|
+
* cvs (gonzui-import --cvs)
|
127
|
+
* svn (gonzui-import --svn)
|
128
|
+
* git (gonzui-import --git)
|
129
|
+
|
130
|
+
== INSTALL:
|
131
|
+
|
132
|
+
$ sudo gem install gonzui
|
133
|
+
|
134
|
+
If you use Ubuntu, add following path to $PATH
|
135
|
+
/usr/lib/gems/1.8/bin
|
136
|
+
|
137
|
+
== LICENSE:
|
138
|
+
Copyright (C) 2004-2005 Satoru Takabayashi <satoru@namazu.org>
|
139
|
+
|
140
|
+
All rights reserved.
|
141
|
+
|
142
|
+
This is free software with ABSOLUTELY NO WARRANTY.
|
143
|
+
|
144
|
+
You can redistribute it and/or modify it under the terms of
|
145
|
+
the GNU General Public License version 2.
|
146
|
+
|
147
|
+
== AUTHORS:
|
148
|
+
see 'AUTHORS.txt'
|
149
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
gem 'hoe', '>= 2.1.0'
|
3
|
+
require 'hoe'
|
4
|
+
require 'fileutils'
|
5
|
+
require './lib/gonzui'
|
6
|
+
|
7
|
+
Hoe.plugin :newgem
|
8
|
+
# Hoe.plugin :website
|
9
|
+
# Hoe.plugin :cucumberfeatures
|
10
|
+
|
11
|
+
# Generate all the Rake tasks
|
12
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
13
|
+
$hoe = Hoe.spec 'gonzui' do
|
14
|
+
self.developer 'mallowlabs', 'mallowlabs@gmail.com'
|
15
|
+
self.post_install_message = File.read('PostInstall.txt')
|
16
|
+
self.rubyforge_name = self.name # TODO this is default value
|
17
|
+
self.extra_deps = [['langscan','>= 1.2']] #['bdb', '>= 0.5.2']
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
require 'newgem/tasks'
|
22
|
+
Dir['tasks/**/*.rake'].each { |t| load t }
|
23
|
+
|
24
|
+
# TODO - want other tests/tasks run by default? Add them to the list
|
25
|
+
# remove_task :default
|
26
|
+
# task :default => [:spec, :features]
|
27
|
+
|
28
|
+
|
data/bin/gonzui-db
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# gonzui-db - a tool to inspect a gonzui DB
|
4
|
+
#
|
5
|
+
# Copyright (C) 2004-2005 Satoru Takabayashi <satoru@namazu.org>
|
6
|
+
# All rights reserved.
|
7
|
+
# This is free software with ABSOLUTELY NO WARRANTY.
|
8
|
+
#
|
9
|
+
# You can redistribute it and/or modify it under the terms of
|
10
|
+
# the GNU General Public License version 2.
|
11
|
+
#
|
12
|
+
|
13
|
+
# %LOADPATH%
|
14
|
+
require 'getoptlong'
|
15
|
+
require 'gonzui'
|
16
|
+
require 'gonzui/cmdapp'
|
17
|
+
|
18
|
+
include Gonzui
|
19
|
+
include Gonzui::Util
|
20
|
+
|
21
|
+
class GonzuiDB < CommandLineApplication
|
22
|
+
def command_list_files(package_names)
|
23
|
+
seen = {}
|
24
|
+
DBM.open(@config, true) {|dbm|
|
25
|
+
dbm.each_package_name {|package_name|
|
26
|
+
if package_names.empty? or package_names.find {|p| p == package_name }
|
27
|
+
seen[package_name] = true
|
28
|
+
package_id = dbm.get_package_id(package_name)
|
29
|
+
path_ids = dbm.get_path_ids(package_id)
|
30
|
+
path_ids.each {|path_id|
|
31
|
+
path = dbm.get_path(path_id)
|
32
|
+
printf("%s\n", path)
|
33
|
+
}
|
34
|
+
end
|
35
|
+
}
|
36
|
+
}
|
37
|
+
package_names.each {|package_name|
|
38
|
+
wprintf("%s: package not found", package_name) unless seen[package_name]
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
def command_list_packages(patterns)
|
43
|
+
DBM.open(@config, true) {|dbm|
|
44
|
+
dbm.each_package_name {|package_name|
|
45
|
+
if patterns.empty? or patterns.find {|p| /#{p}/.match(package_name) }
|
46
|
+
printf("%s\n", package_name)
|
47
|
+
end
|
48
|
+
}
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
def command_list_words(unused)
|
53
|
+
DBM.open(@config, true) {|dbm|
|
54
|
+
dbm.each_word {|word|
|
55
|
+
printf("%s\n", word)
|
56
|
+
}
|
57
|
+
}
|
58
|
+
end
|
59
|
+
|
60
|
+
def each_matching_db(db_names)
|
61
|
+
raise ArgmentError.new("block not given") unless block_given?
|
62
|
+
seen = {}
|
63
|
+
DBM.open(@config, true) {|dbm|
|
64
|
+
dbm.each_db_name {|db_name|
|
65
|
+
if db_names.empty? or db_names.find {|x| x == db_name }
|
66
|
+
seen[db_name] = true
|
67
|
+
db = dbm.send(db_name)
|
68
|
+
yield(db)
|
69
|
+
end
|
70
|
+
}
|
71
|
+
}
|
72
|
+
db_names.each {|db_name|
|
73
|
+
wprintf("%s: db not found", db_name) unless seen[db_name]
|
74
|
+
}
|
75
|
+
end
|
76
|
+
|
77
|
+
def command_list_keys(db_names)
|
78
|
+
each_matching_db(db_names) {|db|
|
79
|
+
db.each {|key, value|
|
80
|
+
printf("%s\n", key.inspect)
|
81
|
+
}
|
82
|
+
}
|
83
|
+
end
|
84
|
+
|
85
|
+
def command_retrieve(paths)
|
86
|
+
path = paths.first
|
87
|
+
DBM.open(@config, true) {|dbm|
|
88
|
+
path_id = dbm.get_path_id(path)
|
89
|
+
if path_id
|
90
|
+
print dbm.get_content(path_id)
|
91
|
+
else
|
92
|
+
eprintf("%s: not found", path)
|
93
|
+
end
|
94
|
+
}
|
95
|
+
end
|
96
|
+
|
97
|
+
def command_dump(db_names)
|
98
|
+
each_matching_db(db_names) {|db|
|
99
|
+
db.each {|key, value|
|
100
|
+
printf("%s\t%s\n", key.inspect, value.inspect)
|
101
|
+
}
|
102
|
+
}
|
103
|
+
end
|
104
|
+
|
105
|
+
def command_verify(unsed)
|
106
|
+
DBM.open(@config, true) {|dbm|
|
107
|
+
begin
|
108
|
+
dbm.consistent?
|
109
|
+
rescue AssertionFailed => e
|
110
|
+
eprintf("DB is broken. You need to rebuild it.\n\n%s\n%s\n",
|
111
|
+
e.to_s,
|
112
|
+
e.backtrace.join("\n")
|
113
|
+
)
|
114
|
+
end
|
115
|
+
}
|
116
|
+
end
|
117
|
+
|
118
|
+
def do_show_usage
|
119
|
+
puts "Usage: #{program_name} [OPTION]..."
|
120
|
+
puts " -l, --list [PATTERN]... list packages"
|
121
|
+
puts " -L, --list-files [PACKAGE]... list files owend by package(s)"
|
122
|
+
puts " -w, --list-words list words"
|
123
|
+
puts " -k, --list-keys [DBNAME]... list keys in database(s) (for test)"
|
124
|
+
puts " --dump [DBNAME]... dump contents of database(s) (for test)"
|
125
|
+
puts " -r, --retrieve PATH retrieve the file of PATH"
|
126
|
+
puts " --verify verify DB integrity"
|
127
|
+
end
|
128
|
+
|
129
|
+
def do_get_option_table
|
130
|
+
[
|
131
|
+
['--list', '-l', GetoptLong::NO_ARGUMENT],
|
132
|
+
['--list-files', '-L', GetoptLong::NO_ARGUMENT],
|
133
|
+
['--list-words', '-w', GetoptLong::NO_ARGUMENT],
|
134
|
+
['--list-keys', '-k', GetoptLong::NO_ARGUMENT],
|
135
|
+
['--dump', GetoptLong::NO_ARGUMENT],
|
136
|
+
['--retrieve', '-r', GetoptLong::NO_ARGUMENT],
|
137
|
+
['--verify', GetoptLong::NO_ARGUMENT],
|
138
|
+
]
|
139
|
+
end
|
140
|
+
|
141
|
+
def do_process_options(options)
|
142
|
+
tasks = []
|
143
|
+
tasks.push(:command_list_files) if options['list-files']
|
144
|
+
tasks.push(:command_list_packages) if options['list']
|
145
|
+
tasks.push(:command_list_words) if options['list-words']
|
146
|
+
tasks.push(:command_list_keys) if options['list-keys']
|
147
|
+
tasks.push(:command_retrieve) if options['retrieve']
|
148
|
+
tasks.push(:command_dump) if options['dump']
|
149
|
+
tasks.push(:command_verify) if options['verify']
|
150
|
+
raise "cannot combine tasks" if tasks.length > 1
|
151
|
+
task = tasks.first
|
152
|
+
|
153
|
+
if task == nil or (task == :retrieve and ARGV.length != 1)
|
154
|
+
show_usage
|
155
|
+
end
|
156
|
+
@task = task
|
157
|
+
@parameters = ARGV
|
158
|
+
end
|
159
|
+
|
160
|
+
def do_start
|
161
|
+
parse_options()
|
162
|
+
ensure_db_directory_available
|
163
|
+
send(@task, @parameters)
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
GonzuiDB.start
|