gonzui 1.2
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/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/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/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/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 +291 -0
data/test/test_dbm.rb
ADDED
@@ -0,0 +1,171 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
3
|
+
require '_external_tools.rb'
|
4
|
+
require '_test-util'
|
5
|
+
|
6
|
+
class DBMTest < Test::Unit::TestCase
|
7
|
+
include TestUtil
|
8
|
+
|
9
|
+
def test_dbm_create
|
10
|
+
config = Gonzui::Config.new
|
11
|
+
remove_db(config)
|
12
|
+
dbm = Gonzui::DBM.open(config)
|
13
|
+
assert(dbm.is_a?(Gonzui::AbstractDBM))
|
14
|
+
dbm.close
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_dbm_create_with_block
|
18
|
+
config = Gonzui::Config.new
|
19
|
+
remove_db(config)
|
20
|
+
Gonzui::DBM.open(config) {|dbm|
|
21
|
+
assert(dbm.is_a?(Gonzui::AbstractDBM))
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
def _test_consistent_p(dbm)
|
26
|
+
assert(dbm.consistent?)
|
27
|
+
end
|
28
|
+
|
29
|
+
def _test_content_info(dbm)
|
30
|
+
dbm.each_package_name {|package_name|
|
31
|
+
package_id = dbm.get_package_id(package_name)
|
32
|
+
assert(package_id)
|
33
|
+
path_ids = dbm.get_path_ids(package_id)
|
34
|
+
path_ids.each {|path_id|
|
35
|
+
stat = dbm.get_content_info(path_id)
|
36
|
+
assert(stat.is_a?(Gonzui::ContentInfo))
|
37
|
+
content = dbm.get_content(path_id)
|
38
|
+
assert_equal(stat.size, content.length)
|
39
|
+
assert(stat.itime >= stat.mtime)
|
40
|
+
assert((Time.now.to_i - stat.itime) < 600) # within 10 minutes
|
41
|
+
}
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
def _test_each_foo(dbm)
|
46
|
+
dbm.each_package_name {|package_name|
|
47
|
+
assert_equal(FOO_PACKAGE, package_name)
|
48
|
+
}
|
49
|
+
|
50
|
+
dbm.each_db_name {|db_name|
|
51
|
+
assert(db_name.is_a?(String))
|
52
|
+
assert(dbm.respond_to?(db_name))
|
53
|
+
}
|
54
|
+
end
|
55
|
+
|
56
|
+
def _test_get_foo(dbm)
|
57
|
+
make_dist_tree
|
58
|
+
package_id = dbm.get_package_id(FOO_PACKAGE)
|
59
|
+
dbm.get_path_ids(package_id).each {|path_id|
|
60
|
+
path = dbm.get_path(path_id)
|
61
|
+
assert(FOO_FILES.include?(File.basename(path)))
|
62
|
+
assert_equal(path_id, dbm.get_path_id(path))
|
63
|
+
content = dbm.get_content(path_id)
|
64
|
+
content = File.read(File.join(File.dirname(__FILE__), "foo", path))
|
65
|
+
assert_equal(content, content)
|
66
|
+
dbm.get_word_ids(path_id).each {|word_id|
|
67
|
+
FOO_SYMBOLS.include?(dbm.get_word(word_id))
|
68
|
+
}
|
69
|
+
assert_equal(0, package_id)
|
70
|
+
assert_equal(FOO_PACKAGE, dbm.get_package_name(package_id))
|
71
|
+
}
|
72
|
+
end
|
73
|
+
|
74
|
+
def _test_foo_find(dbm)
|
75
|
+
found_types = []
|
76
|
+
[:find_all, :find_all_by_regexp, :find_all_by_prefix].each {|search_method|
|
77
|
+
FOO_SYMBOLS.each {|word|
|
78
|
+
tuples = dbm.send(search_method, word)
|
79
|
+
assert(tuples.is_a?(Array))
|
80
|
+
assert_equal(false, tuples.empty?)
|
81
|
+
tuples.each {|info|
|
82
|
+
type = dbm.get_type(info.type_id)
|
83
|
+
assert(type.is_a?(Symbol))
|
84
|
+
found_types.push(type)
|
85
|
+
|
86
|
+
assert(info.is_a?(Gonzui::WordInfo))
|
87
|
+
if search_method == :find_all
|
88
|
+
assert_equal(word, dbm.get_word(info.word_id))
|
89
|
+
else
|
90
|
+
assert(dbm.get_word(info.word_id).index(word))
|
91
|
+
end
|
92
|
+
assert(info.byteno.is_a?(Fixnum))
|
93
|
+
assert(info.lineno.is_a?(Fixnum))
|
94
|
+
assert(info.type_id.is_a?(Fixnum))
|
95
|
+
assert(info.path_id.is_a?(Fixnum))
|
96
|
+
path = dbm.get_path(info.path_id)
|
97
|
+
assert(FOO_FILES.include?(File.basename(path)))
|
98
|
+
}
|
99
|
+
}
|
100
|
+
[:fundef, :funcall, :fundecl].each {|type|
|
101
|
+
assert(found_types.include?(type))
|
102
|
+
}
|
103
|
+
assert(dbm.send(search_method, "__not_existing_word__").empty?)
|
104
|
+
}
|
105
|
+
end
|
106
|
+
|
107
|
+
def _test_digest(dbm)
|
108
|
+
path_id = dbm.get_path_id(File.join(FOO_PACKAGE, "foo.c"))
|
109
|
+
content = dbm.get_content(path_id)
|
110
|
+
digest = dbm.get_digest(path_id)
|
111
|
+
digest.each {|info|
|
112
|
+
assert(info.is_a?(Gonzui::DigestInfo))
|
113
|
+
word = content[info.byteno, info.length]
|
114
|
+
if word
|
115
|
+
assert_equal(word.length, info.length)
|
116
|
+
assert_equal(word, content[info.byteno, info.length])
|
117
|
+
end
|
118
|
+
}
|
119
|
+
end
|
120
|
+
|
121
|
+
def _test_close(dbm)
|
122
|
+
begin
|
123
|
+
dbm.close
|
124
|
+
dbm.close
|
125
|
+
assert(false)
|
126
|
+
rescue Gonzui::DBMError => e
|
127
|
+
assert(true)
|
128
|
+
end
|
129
|
+
|
130
|
+
begin
|
131
|
+
dbm.get_npackages
|
132
|
+
assert(false)
|
133
|
+
rescue BDB::Fatal => e # closed DB
|
134
|
+
assert(true)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
def test_bdb
|
139
|
+
tmp = "test.#{$$}.db"
|
140
|
+
db = BDB::Btree.open(tmp, nil, BDB::CREATE, 0644,
|
141
|
+
"set_flags" => BDB::DUPSORT)
|
142
|
+
db["foo"] = "1"
|
143
|
+
db["foo"] = "2"
|
144
|
+
assert_equal(2, db.duplicates("foo").length)
|
145
|
+
|
146
|
+
# The assert failed with Ruby BDB 0.5.1 or older due to
|
147
|
+
# BDB::Btree#duplicates's bug. The bug was fixed in BDB
|
148
|
+
# 0.5.2.
|
149
|
+
assert_equal(0, db.duplicates("f").length)
|
150
|
+
assert_equal(0, db.duplicates("").length)
|
151
|
+
db.close
|
152
|
+
File.unlink(tmp)
|
153
|
+
end
|
154
|
+
|
155
|
+
def test_dbm_operations
|
156
|
+
config = Gonzui::Config.new
|
157
|
+
remove_db(config)
|
158
|
+
|
159
|
+
make_archives
|
160
|
+
add_package(config)
|
161
|
+
|
162
|
+
dbm = Gonzui::DBM.open(config)
|
163
|
+
_test_content_info(dbm)
|
164
|
+
_test_each_foo(dbm)
|
165
|
+
_test_get_foo(dbm)
|
166
|
+
_test_foo_find(dbm)
|
167
|
+
_test_digest(dbm)
|
168
|
+
_test_close(dbm)
|
169
|
+
remove_db(config)
|
170
|
+
end
|
171
|
+
end if (ARC_)
|
@@ -0,0 +1,50 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
3
|
+
require '_external_tools.rb'
|
4
|
+
require '_test-util'
|
5
|
+
|
6
|
+
class DeindexerTest < Test::Unit::TestCase
|
7
|
+
include TestUtil
|
8
|
+
|
9
|
+
def setup
|
10
|
+
@dbm = nil
|
11
|
+
@config = Gonzui::Config.new
|
12
|
+
end
|
13
|
+
def teardown
|
14
|
+
unless @dbm.nil?
|
15
|
+
@dbm.close rescue nil
|
16
|
+
end
|
17
|
+
@dbm = nil
|
18
|
+
remove_db(@config)
|
19
|
+
end
|
20
|
+
|
21
|
+
def _test_removed_clearly?(dbm)
|
22
|
+
exclude_dbs = [
|
23
|
+
:seq, :stat, :type_typeid, :typeid_type, :version,
|
24
|
+
]
|
25
|
+
dbm.each_db_name {|db_name|
|
26
|
+
next if exclude_dbs.include?(db_name.intern)
|
27
|
+
assert(dbm.send(db_name).empty?)
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_deindex
|
32
|
+
remove_db(@config)
|
33
|
+
make_db(@config)
|
34
|
+
dbm = Gonzui::DBM.open(@config)
|
35
|
+
@dbm = dbm
|
36
|
+
|
37
|
+
package_id = dbm.get_package_id(FOO_PACKAGE)
|
38
|
+
assert_equal(0, package_id)
|
39
|
+
dbm.get_path_ids(package_id).each {|path_id|
|
40
|
+
normalized_path = dbm.get_path(path_id)
|
41
|
+
deindexer = Gonzui::Deindexer.new(@config, dbm, normalized_path)
|
42
|
+
deindexer.deindex
|
43
|
+
}
|
44
|
+
assert(!dbm.has_package?(FOO_PACKAGE))
|
45
|
+
assert_equal(0, dbm.get_ncontents)
|
46
|
+
assert_equal(0, dbm.get_nwords)
|
47
|
+
assert(dbm.consistent?)
|
48
|
+
_test_removed_clearly?(dbm)
|
49
|
+
end
|
50
|
+
end if (ARC_)
|
data/test/test_delta.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
3
|
+
require '_test-util'
|
4
|
+
|
5
|
+
class DeltaDumperTest < Test::Unit::TestCase
|
6
|
+
include Gonzui::DeltaDumper
|
7
|
+
|
8
|
+
def test_fixnums
|
9
|
+
list = [
|
10
|
+
[[1,2,3,4,5,6], [1,1,1,1,1,1]],
|
11
|
+
[[0,0,0,0,0,0], [0,0,0,0,0,0]],
|
12
|
+
[[1,1,2,3,5,8], [1,0,1,1,2,3]],
|
13
|
+
]
|
14
|
+
list.each {|original, encoded|
|
15
|
+
tmp = original.dup
|
16
|
+
assert_equal(encoded, encode_fixnums(tmp))
|
17
|
+
assert_equal(original, decode_fixnums(tmp))
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_fixnums_with_broken_data
|
22
|
+
broken_data = [
|
23
|
+
nil,
|
24
|
+
"",
|
25
|
+
[1,2,nil,3],
|
26
|
+
[1,2,3,2,1]
|
27
|
+
]
|
28
|
+
broken_data.each {|list|
|
29
|
+
begin
|
30
|
+
encode_fixnums(list)
|
31
|
+
assert_not_reached
|
32
|
+
rescue ArgumentError, TypeError => e
|
33
|
+
end
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_tuples
|
38
|
+
list = [
|
39
|
+
[[1,2,3,4,5,6], [1,2,2,2,2,2], 2, 2],
|
40
|
+
[[1,2,3,4,5,6], [1,2,2,4,2,6], 1, 2],
|
41
|
+
]
|
42
|
+
list.each {|original, encoded, dsize, usize|
|
43
|
+
tmp = original.dup
|
44
|
+
assert_equal(encoded, encode_tuples(tmp, dsize, usize))
|
45
|
+
assert_equal(original, decode_tuples(tmp, dsize, usize))
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_tuples_with_broken_data
|
50
|
+
broken_data = [
|
51
|
+
[nil, 2, 2],
|
52
|
+
[[1,2,3,4,5], 2, 2],
|
53
|
+
[[1,2,3,4,5,6], 3, 2],
|
54
|
+
[[1,2,nil,4,5,6], 2, 2],
|
55
|
+
[[1,2,3,3,2,1], 2, 2]
|
56
|
+
]
|
57
|
+
broken_data.each {|list, dsize, usize|
|
58
|
+
begin
|
59
|
+
encode_tuples(list, dsize, usize)
|
60
|
+
assert_not_reached
|
61
|
+
rescue ArgumentError, TypeError => e
|
62
|
+
end
|
63
|
+
}
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
@@ -0,0 +1,78 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
3
|
+
require '_external_tools.rb'
|
4
|
+
require '_test-util'
|
5
|
+
|
6
|
+
class ExtractorTest < Test::Unit::TestCase
|
7
|
+
include TestUtil
|
8
|
+
|
9
|
+
include Gonzui::Util
|
10
|
+
|
11
|
+
def test_supported_archive
|
12
|
+
supported_files = {}
|
13
|
+
supported_files["foo.zip"] = ".zip" if command_exist?("unzip")
|
14
|
+
supported_files["foo.tar.gz"] = ".tar.gz" if
|
15
|
+
command_exist?("tar") and command_exist?("gunzip")
|
16
|
+
supported_files["foo.tar.bz2"] = ".tar.bz2" if
|
17
|
+
command_exist?("tar") and command_exist?("bunzip2")
|
18
|
+
supported_files["foo.src.rpm"] = ".src.rpm" if
|
19
|
+
command_exist?("rpm2cpio") and command_exist?("cpio")
|
20
|
+
|
21
|
+
supported_files.each {|file_name, extname|
|
22
|
+
assert_equal(extname, Gonzui::Extractor.get_archive_extname(file_name))
|
23
|
+
assert(Gonzui::Extractor.supported_file?(file_name))
|
24
|
+
assert_equal(file_name,
|
25
|
+
Gonzui::Extractor.suppress_archive_extname(file_name) + extname)
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_unsupported_archive
|
30
|
+
unsupported_files = {
|
31
|
+
"foo.rpm" => ".rpm",
|
32
|
+
}
|
33
|
+
unsupported_files.each {|file_name, extname|
|
34
|
+
assert_equal(nil, Gonzui::Extractor.get_archive_extname(file_name))
|
35
|
+
assert_equal(false, Gonzui::Extractor.supported_file?(file_name))
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
def _test_extract(file_name)
|
40
|
+
config = Gonzui::Config.new
|
41
|
+
extractor = Gonzui::Extractor.new(config, file_name)
|
42
|
+
directory = extractor.extract
|
43
|
+
assert(File.directory?(directory))
|
44
|
+
package_name = File.basename(directory)
|
45
|
+
source_url = URI.from_path(directory)
|
46
|
+
fetcher = Gonzui::Fetcher.new(config, source_url)
|
47
|
+
relative_paths = fetcher.collect
|
48
|
+
FOO_FILES.each {|base_name|
|
49
|
+
assert(relative_paths.include?(base_name))
|
50
|
+
}
|
51
|
+
|
52
|
+
assert(File.directory?(extractor.temporary_directory))
|
53
|
+
extractor.clean
|
54
|
+
assert_equal(false, File.directory?(extractor.temporary_directory))
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_extract
|
58
|
+
make_archives
|
59
|
+
|
60
|
+
good_archives = [
|
61
|
+
"foo-0.1.tar.gz",
|
62
|
+
"foo-0.1.tar.bz2",
|
63
|
+
"foo-0.1.zip",
|
64
|
+
"foo-0.1-1.src.rpm",
|
65
|
+
].map {|x| File.join("foo", x) }
|
66
|
+
good_archives = good_archives.find_all {|x| File.file?(x) }
|
67
|
+
|
68
|
+
poor_archives = [
|
69
|
+
"foo-0.1p.tar.gz",
|
70
|
+
"foo-0.1p.tar.bz2",
|
71
|
+
"foo-0.1p.zip",
|
72
|
+
].map {|x| File.join("foo", x) }
|
73
|
+
poor_archives = poor_archives.find_all {|x| File.file?(x) }
|
74
|
+
|
75
|
+
good_archives.each {|file_name| _test_extract(file_name) }
|
76
|
+
poor_archives.each {|file_name| _test_extract(file_name) }
|
77
|
+
end
|
78
|
+
end if (ARC_)
|
@@ -0,0 +1,75 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
3
|
+
require '_external_tools'
|
4
|
+
require '_test-util'
|
5
|
+
|
6
|
+
class FetcherTest < Test::Unit::TestCase
|
7
|
+
include Gonzui::Util
|
8
|
+
include TestUtil
|
9
|
+
|
10
|
+
def teardown
|
11
|
+
remove_db(Gonzui::Config.new)
|
12
|
+
end
|
13
|
+
|
14
|
+
def validate_foo_files(fetcher, paths)
|
15
|
+
paths.each {|path|
|
16
|
+
FOO_FILES.include?(File.basename(path))
|
17
|
+
content = fetcher.fetch(path)
|
18
|
+
tmp = File.read(File.join(File.dirname(__FILE__),
|
19
|
+
"foo", FOO_PACKAGE, path))
|
20
|
+
assert_equal(tmp, content.text)
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_file
|
25
|
+
config = Gonzui::Config.new
|
26
|
+
make_dist_tree
|
27
|
+
uri = URI.parse(sprintf("file://%s/foo/%s",
|
28
|
+
File.expand_path(File.dirname(__FILE__)), # Dir.pwd
|
29
|
+
FOO_PACKAGE))
|
30
|
+
fetcher = Gonzui::Fetcher.new(config, uri)
|
31
|
+
paths = fetcher.collect
|
32
|
+
assert_equal(false, paths.empty?)
|
33
|
+
validate_foo_files(fetcher, paths)
|
34
|
+
fetcher.finish
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_http
|
38
|
+
config = Gonzui::Config.new
|
39
|
+
uri = URI.parse("http://gonzui.sourceforge.net/archives/gonzui-0.1.tar.gz")
|
40
|
+
fetcher = Gonzui::Fetcher.new(config, uri)
|
41
|
+
paths = fetcher.collect
|
42
|
+
assert_equal(false, paths.empty?)
|
43
|
+
paths.each {|path|
|
44
|
+
content = fetcher.fetch(path)
|
45
|
+
assert(content.text.is_a?(String))
|
46
|
+
}
|
47
|
+
fetcher.finish
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_cvs
|
51
|
+
config = Gonzui::Config.new
|
52
|
+
config.quiet = true
|
53
|
+
remove_db(config)
|
54
|
+
make_cvs
|
55
|
+
uri = URI.for_cvs(cvsroot, "foo")
|
56
|
+
fetcher = Gonzui::Fetcher.new(config, uri)
|
57
|
+
paths = fetcher.collect
|
58
|
+
assert_equal(false, paths.empty?)
|
59
|
+
validate_foo_files(fetcher, paths)
|
60
|
+
remove_cvs
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_svn
|
64
|
+
config = Gonzui::Config.new
|
65
|
+
config.quiet = true
|
66
|
+
remove_db(config)
|
67
|
+
make_svn
|
68
|
+
uri = URI.for_svn("file://" + svnroot, "foo")
|
69
|
+
fetcher = Gonzui::Fetcher.new(config, uri)
|
70
|
+
paths = fetcher.collect
|
71
|
+
assert_equal(false, paths.empty?)
|
72
|
+
validate_foo_files(fetcher, paths)
|
73
|
+
remove_svn
|
74
|
+
end
|
75
|
+
end if (ARC_ && CVS_ && SVN_)
|
@@ -0,0 +1,50 @@
|
|
1
|
+
#! /usr/bin/env ruby -Ku
|
2
|
+
# -*- coding: utf-8-unix -*-
|
3
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
4
|
+
require '_test-util'
|
5
|
+
|
6
|
+
class GetTextTest < Test::Unit::TestCase
|
7
|
+
include Gonzui::GetText
|
8
|
+
|
9
|
+
CATALOG_FILE_NAME = "catalog.ja"
|
10
|
+
CATALOG = {
|
11
|
+
"hello" => "こんにちは"
|
12
|
+
}
|
13
|
+
|
14
|
+
def make_catalog
|
15
|
+
File.open(CATALOG_FILE_NAME, "w") {|f|
|
16
|
+
f.puts "{"
|
17
|
+
CATALOG.each {|key, value|
|
18
|
+
f.printf(' "%s" => "%s",', key, value)
|
19
|
+
f.puts
|
20
|
+
}
|
21
|
+
f.puts "}"
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
def remove_catalog
|
26
|
+
File.unlink(CATALOG_FILE_NAME)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_gettext
|
30
|
+
make_catalog
|
31
|
+
assert_equal("hello", _("hello"))
|
32
|
+
catalog_repository = Gonzui::CatalogRepository.new(".")
|
33
|
+
catalog = catalog_repository.choose("ja")
|
34
|
+
assert_equal(catalog, load_catalog("catalog.ja"))
|
35
|
+
set_catalog(catalog)
|
36
|
+
assert_equal("こんにちは", _("hello"))
|
37
|
+
|
38
|
+
remove_catalog
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_validator
|
42
|
+
validator = Gonzui::CatalogValidator.new(__FILE__, CATALOG)
|
43
|
+
validator.validate
|
44
|
+
assert_equal(true, validator.ok?)
|
45
|
+
|
46
|
+
validator = Gonzui::CatalogValidator.new(__FILE__, {})
|
47
|
+
validator.validate
|
48
|
+
assert_equal(false, validator.ok?)
|
49
|
+
end
|
50
|
+
end
|