bitclust-core 0.5.4 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +42 -0
- data/data/bitclust/template.lillia/library +18 -28
- data/data/bitclust/template.offline/library +18 -30
- data/data/bitclust/template/library +18 -30
- data/lib/bitclust/database.rb +1 -1
- data/lib/bitclust/libraryentry.rb +8 -0
- data/lib/bitclust/nameutils.rb +5 -3
- data/lib/bitclust/rrdparser.rb +5 -5
- data/lib/bitclust/runner.rb +15 -10
- data/lib/bitclust/screen.rb +23 -0
- data/lib/bitclust/subcommand.rb +4 -727
- data/lib/bitclust/subcommands/init_command.rb +49 -0
- data/lib/bitclust/subcommands/list_command.rb +68 -0
- data/lib/bitclust/subcommands/lookup_command.rb +176 -0
- data/lib/bitclust/subcommands/property_command.rb +74 -0
- data/lib/bitclust/subcommands/query_command.rb +34 -0
- data/lib/bitclust/subcommands/server_command.rb +218 -0
- data/lib/bitclust/subcommands/setup_command.rb +123 -0
- data/lib/bitclust/subcommands/update_command.rb +65 -0
- data/lib/bitclust/version.rb +1 -1
- data/test/test_bitclust.rb +2 -2
- data/test/test_entry.rb +1 -1
- data/test/test_methodsignature.rb +5 -7
- data/test/test_nameutils.rb +307 -243
- data/test/test_runner.rb +8 -8
- metadata +87 -75
- data/test/test_subcommand.rb +0 -12
@@ -0,0 +1,123 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'erb'
|
3
|
+
require 'find'
|
4
|
+
require 'pp'
|
5
|
+
require 'optparse'
|
6
|
+
require 'yaml'
|
7
|
+
|
8
|
+
require 'bitclust'
|
9
|
+
require 'bitclust/subcommand'
|
10
|
+
|
11
|
+
module BitClust::Subcommands
|
12
|
+
class SetupCommand < BitClust::Subcommand
|
13
|
+
|
14
|
+
REPOSITORY_PATH = "http://jp.rubyist.net/svn/rurema/doctree/trunk"
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
@prepare = nil
|
18
|
+
@cleanup = nil
|
19
|
+
@versions = ["1.8.7", "1.9.3"]
|
20
|
+
@parser = OptionParser.new {|opt|
|
21
|
+
opt.banner = "Usage: #{File.basename($0, '.*')} setup [options]"
|
22
|
+
opt.on('--prepare', 'Prepare config file and checkout repository. Do not create database.') {
|
23
|
+
@prepare = true
|
24
|
+
}
|
25
|
+
opt.on('--cleanup', 'Cleanup datebase before create database.') {
|
26
|
+
@cleanup = true
|
27
|
+
}
|
28
|
+
opt.on('--versions=V1,V2,...', "Specify versions. [#{@versions.join(',')}]") {|versions|
|
29
|
+
@versions = versions.split(",")
|
30
|
+
}
|
31
|
+
opt.on('--help', 'Prints this message and quit.') {
|
32
|
+
puts opt.help
|
33
|
+
exit 0
|
34
|
+
}
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
def exec(db, argv)
|
39
|
+
prepare
|
40
|
+
return if @prepare
|
41
|
+
@config[:versions].each do |version|
|
42
|
+
puts "Generating database for Ruby#{version}..."
|
43
|
+
prefix = "#{@config[:database_prefix]}-#{version}"
|
44
|
+
FileUtils.rm_rf(prefix) if @cleanup
|
45
|
+
init_argv = ["version=#{version}", "encoding=#{@config[:encoding]}"]
|
46
|
+
db = BitClust::MethodDatabase.new(prefix)
|
47
|
+
InitCommand.new.exec(db, init_argv)
|
48
|
+
update_method_database(prefix, ["--stdlibtree=#{@config[:stdlibtree]}"])
|
49
|
+
argv = Pathname(@config[:capi_src]).children.select(&:file?).map{|v| v.realpath.to_s }
|
50
|
+
update_function_database(prefix, argv)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def prepare
|
57
|
+
home_directory = Pathname(ENV["HOME"])
|
58
|
+
config_dir = home_directory + ".bitclust"
|
59
|
+
config_dir.mkpath
|
60
|
+
config_path = config_dir + "config"
|
61
|
+
rubydoc_dir = config_dir + "rubydoc"
|
62
|
+
@config = {
|
63
|
+
:database_prefix => (config_dir + "db").to_s,
|
64
|
+
:encoding => "utf-8",
|
65
|
+
:versions => @versions,
|
66
|
+
:default_version => @versions.max,
|
67
|
+
:stdlibtree => (rubydoc_dir + "refm/api/src").to_s,
|
68
|
+
:capi_src => (rubydoc_dir + "refm/capi/src/").to_s,
|
69
|
+
:baseurl => "http://localhost:10080",
|
70
|
+
:port => "10080",
|
71
|
+
:pid_file => "/tmp/bitclust.pid",
|
72
|
+
}
|
73
|
+
if config_path.exist?
|
74
|
+
@config = YAML.load_file(config_path)
|
75
|
+
unless @config[:versions].sort == @versions.sort
|
76
|
+
print("overwrite config file? > [y/N]")
|
77
|
+
if /\Ay\z/i =~ $stdin.gets.chomp
|
78
|
+
@config[:versions] = @versions
|
79
|
+
@config[:default_version] = @versions.max
|
80
|
+
generate_config(config_path, @config)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
else
|
84
|
+
generate_config(config_path, @config)
|
85
|
+
end
|
86
|
+
checkout(rubydoc_dir)
|
87
|
+
end
|
88
|
+
|
89
|
+
def generate_config(path, config)
|
90
|
+
path.open("w+", 0644) do |file|
|
91
|
+
file.puts config.to_yaml
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def checkout(rubydoc_dir)
|
96
|
+
case RUBY_PLATFORM
|
97
|
+
when /mswin(?!ce)|mingw|cygwin|bccwin/
|
98
|
+
cmd = "svn help > NUL 2> NUL"
|
99
|
+
else
|
100
|
+
cmd = "svn help > /dev/null 2> /dev/null"
|
101
|
+
end
|
102
|
+
unless system(cmd)
|
103
|
+
warn "svn command is not found. Please install Subversion."
|
104
|
+
exit 1
|
105
|
+
end
|
106
|
+
system("svn", "co", REPOSITORY_PATH, rubydoc_dir.to_s)
|
107
|
+
end
|
108
|
+
|
109
|
+
def update_method_database(prefix, argv)
|
110
|
+
db = BitClust::MethodDatabase.new(prefix)
|
111
|
+
cmd = UpdateCommand.new
|
112
|
+
cmd.parse(argv)
|
113
|
+
cmd.exec(db, argv)
|
114
|
+
end
|
115
|
+
|
116
|
+
def update_function_database(prefix, argv)
|
117
|
+
db = BitClust::FunctionDatabase.new(prefix)
|
118
|
+
cmd = UpdateCommand.new
|
119
|
+
cmd.parse(argv)
|
120
|
+
cmd.exec(db, argv)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'erb'
|
3
|
+
require 'find'
|
4
|
+
require 'pp'
|
5
|
+
require 'optparse'
|
6
|
+
require 'yaml'
|
7
|
+
|
8
|
+
require 'bitclust'
|
9
|
+
require 'bitclust/subcommand'
|
10
|
+
|
11
|
+
module BitClust::Subcommands
|
12
|
+
class UpdateCommand < BitClust::Subcommand
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
@root = nil
|
16
|
+
@library = nil
|
17
|
+
@parser = OptionParser.new {|opt|
|
18
|
+
opt.banner = "Usage: #{File.basename($0, '.*')} update [<file>...]"
|
19
|
+
opt.on('--stdlibtree=ROOT', 'Process stdlib source directory tree.') {|path|
|
20
|
+
@root = path
|
21
|
+
}
|
22
|
+
opt.on('--library-name=NAME', 'Use NAME for library name in file mode.') {|name|
|
23
|
+
@library = name
|
24
|
+
}
|
25
|
+
opt.on('--help', 'Prints this message and quit.') {
|
26
|
+
puts opt.help
|
27
|
+
exit 0
|
28
|
+
}
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
def parse(argv)
|
33
|
+
super
|
34
|
+
if not @root and argv.empty?
|
35
|
+
error "no input file given"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def exec(db, argv)
|
40
|
+
db.transaction {
|
41
|
+
if @root
|
42
|
+
db.update_by_stdlibtree @root
|
43
|
+
end
|
44
|
+
argv.each do |path|
|
45
|
+
db.update_by_file path, @library || guess_library_name(path)
|
46
|
+
end
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def guess_library_name(path)
|
53
|
+
if %r<(\A|/)src/> =~ path
|
54
|
+
path.sub(%r<.*(\A|/)src/>, '').sub(/\.rd\z/, '')
|
55
|
+
else
|
56
|
+
path
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def get_c_filename(path)
|
61
|
+
File.basename(path, '.rd')
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|
data/lib/bitclust/version.rb
CHANGED
data/test/test_bitclust.rb
CHANGED
@@ -34,9 +34,9 @@ HERE
|
|
34
34
|
db = BitClust::FunctionDatabase.new(@tmpdir)
|
35
35
|
cmd = case command
|
36
36
|
when "lookup"
|
37
|
-
BitClust::LookupCommand.new
|
37
|
+
BitClust::Subcommands::LookupCommand.new
|
38
38
|
when "list"
|
39
|
-
BitClust::ListCommand.new
|
39
|
+
BitClust::Subcommands::ListCommand.new
|
40
40
|
else
|
41
41
|
raise "must not happen! command=#{command}"
|
42
42
|
end
|
data/test/test_entry.rb
CHANGED
@@ -38,7 +38,7 @@ HERE
|
|
38
38
|
assert_equal('Hoge', @lib.fetch_class("HogeHoge").realname)
|
39
39
|
end
|
40
40
|
|
41
|
-
def
|
41
|
+
def test_error_class?
|
42
42
|
assert(!@lib.fetch_class("Hoge").error_class?)
|
43
43
|
assert(@lib.fetch_class("Err").error_class?)
|
44
44
|
assert(!@lib.fetch_class("HogeHoge").error_class?)
|
@@ -3,12 +3,10 @@ require 'bitclust/methodsignature'
|
|
3
3
|
|
4
4
|
class TestMethodSignature < Test::Unit::TestCase
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
assert_equal friendly_string, BitClust::MethodSignature.parse(method_signature).friendly_string
|
12
|
-
end
|
6
|
+
data("special var" => ["$_ -> String | nil", "--- $_ -> String | nil"],
|
7
|
+
"backquote" => ["`command` -> String", "--- `(command) -> String"])
|
8
|
+
def test_friendlyname(data)
|
9
|
+
friendly_string, method_signature = data
|
10
|
+
assert_equal(friendly_string, BitClust::MethodSignature.parse(method_signature).friendly_string)
|
13
11
|
end
|
14
12
|
end
|
data/test/test_nameutils.rb
CHANGED
@@ -5,179 +5,210 @@ class TestNameUtils < Test::Unit::TestCase
|
|
5
5
|
|
6
6
|
include BitClust::NameUtils
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
8
|
+
data("_builtin" => [true, "_builtin"],
|
9
|
+
"fileutils" => [true, "fileutils"],
|
10
|
+
"socket" => [true, "socket"],
|
11
|
+
"open-uri" => [true, "open-uri"],
|
12
|
+
"net/http" => [true, "net/http"],
|
13
|
+
"racc/cparse" => [true, "racc/cparse"],
|
14
|
+
"test/unit/testcase" => [true, "test/unit/testcase"],
|
15
|
+
"empty string" => [false, ""],
|
16
|
+
"following space" => [false, "fileutils "],
|
17
|
+
"leading space" => [false, " fileutils"],
|
18
|
+
"split by space" => [false, "file utils"],
|
19
|
+
"following new line" => [false, "fileutils\n"],
|
20
|
+
"folowing tab" => [false, "fileutils\t"],
|
21
|
+
"with extension .rb" => [false, "fileutils.rb"],
|
22
|
+
"CamelCase with extension .rb" => [false, "English.rb"],
|
23
|
+
"with extension .so" => [false, "socket.so"],
|
24
|
+
"sub library with extension .rb" => [false, "net/http.rb"],
|
25
|
+
"sub library with extension .so" => [false, "racc/cparse.so"])
|
26
|
+
def test_libname?(data)
|
27
|
+
expected, target = data
|
28
|
+
assert_equal(expected, libname?(target))
|
27
29
|
end
|
28
30
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
31
|
+
data("_builtin" => ["_builtin", "_builtin"],
|
32
|
+
"fileutils" => ["fileutils", "fileutils"],
|
33
|
+
"socket" => ["socket", "socket"],
|
34
|
+
"English" => ["English", "English"],
|
35
|
+
"open-uri" => ["open=2duri", "open-uri"],
|
36
|
+
"net/http" => ["net.http", "net/http"],
|
37
|
+
"racc/cparse" => ["racc.cparse", "racc/cparse"],
|
38
|
+
"test/unit/testcase" => ["test.unit.testcase", "test/unit/testcase"])
|
39
|
+
def test_libname2id(data)
|
40
|
+
expected, target = data
|
41
|
+
assert_equal(expected, libname2id(target))
|
38
42
|
end
|
39
43
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
44
|
+
data("_builtin" => ["_builtin", "_builtin"],
|
45
|
+
"fileutils" => ["fileutils", "fileutils"],
|
46
|
+
"socket" => ["socket", "socket"],
|
47
|
+
"English" => ["English", "English"],
|
48
|
+
"open=2duri" => ["open-uri", "open=2duri"],
|
49
|
+
"net.http" => ["net/http", "net.http"],
|
50
|
+
"racc.cparse" => ["racc/cparse", "racc.cparse"],
|
51
|
+
"test.unit.testcase" => ["test/unit/testcase", "test.unit.testcase"])
|
52
|
+
def test_libid2name(data)
|
53
|
+
expected, target = data
|
54
|
+
assert_equal(expected, libid2name(target))
|
49
55
|
end
|
50
56
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
57
|
+
data("fatal" => [true, "fatal"],
|
58
|
+
"Array" => [true, "Array"],
|
59
|
+
"String" => [true, "String"],
|
60
|
+
"Net::HTTP" => [true, "Net::HTTP"],
|
61
|
+
"Test::Unit::TestCase" => [true, "Test::Unit::TestCase"],
|
62
|
+
"ARGF.class" => [true, "ARGF.class"],
|
63
|
+
"empty string" => [false, ""],
|
64
|
+
"following space" => [false, "Array "],
|
65
|
+
"leading space" => [false, " Array"],
|
66
|
+
"split by space" => [false, "Test Case"],
|
67
|
+
"following new line" => [false, "TestCase\n"],
|
68
|
+
"leading tab" => [false, "\tTestCase"],
|
69
|
+
"small case" => [false, "string"],
|
70
|
+
"camelCase" => [false, "stringScanner"],
|
71
|
+
"libname" => [false, "net/http"],
|
72
|
+
"libid" => [false, "net.http"],
|
73
|
+
"libname with '-'" => [false, "open-uri"])
|
74
|
+
def test_classname?(data)
|
75
|
+
expected, target = data
|
76
|
+
assert_equal(expected, classname?(target))
|
68
77
|
end
|
69
78
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
79
|
+
data("Array" => ["Array", "Array"],
|
80
|
+
"String" => ["String", "String"],
|
81
|
+
"Net::HTTP" => ["Net=HTTP", "Net::HTTP"],
|
82
|
+
"Test::Unit::TestCase" => ["Test=Unit=TestCase", "Test::Unit::TestCase"],
|
83
|
+
"ARGF.class" => ["ARGF.class", "ARGF.class"])
|
84
|
+
def test_classname2id(data)
|
85
|
+
expected, target = data
|
86
|
+
assert_equal(expected, classname2id(target))
|
75
87
|
end
|
76
88
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
89
|
+
data("Array" => ["Array", "Array"],
|
90
|
+
"String" => ["String", "String"],
|
91
|
+
"Net=HTTP" => ["Net::HTTP", "Net=HTTP"],
|
92
|
+
"Test=Unit=TestCase" => ["Test::Unit::TestCase", "Test=Unit=TestCase"],
|
93
|
+
"ARGF.class" => ["ARGF.class", "ARGF.class"])
|
94
|
+
def test_classid2name(data)
|
95
|
+
expected, target = data
|
96
|
+
assert_equal(expected, classid2name(target))
|
82
97
|
end
|
83
98
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
99
|
+
data("String#index" => [true, "String#index"],
|
100
|
+
"CGI#accept" => [true, "CGI#accept"],
|
101
|
+
"Net::HTTP#ca_path" => [true, "Net::HTTP#ca_path"],
|
102
|
+
"FileUtils.#cp" => [true, "FileUtils.#cp"],
|
103
|
+
"ARGF.class#path" => [true, "ARGF.class#path"],
|
104
|
+
"ARGF.class" => [false, "ARGF.class"])
|
105
|
+
def test_method_spec?(data)
|
106
|
+
expected, target = data
|
107
|
+
assert_equal(expected, method_spec?(target))
|
89
108
|
end
|
90
109
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
110
|
+
data("String/i.index._builtin" => ["String#index", "String/i.index._builtin"],
|
111
|
+
"CGI/i.accept.cgi" => ["CGI#accept", "CGI/i.accept.cgi"],
|
112
|
+
"Net=HTTP/i.ca_path.net.http" => ["Net::HTTP#ca_path", "Net=HTTP/i.ca_path.net.http"],
|
113
|
+
"FileUtils/m.cp.fileutils" => ["FileUtils.#cp", "FileUtils/m.cp.fileutils"],
|
114
|
+
"ARGF.class/i.filename.ARGF" => ["ARGF.class#filename", "ARGF.class/i.filename.ARGF"])
|
115
|
+
def test_methodid2spec(data)
|
116
|
+
expected, target = data
|
117
|
+
assert_equal(expected, methodid2specstring(target))
|
96
118
|
end
|
97
119
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
120
|
+
data("String/i.index._builtin" => ["_builtin", "String/i.index._builtin"],
|
121
|
+
"CGI/i.accept.cgi" => ["cgi", "CGI/i.accept.cgi"],
|
122
|
+
"Net=HTTP/i.ca_path.net.http" => ["net.http", "Net=HTTP/i.ca_path.net.http"],
|
123
|
+
"OpenURI/m.open.open=2duri" => ["open=2duri", "OpenURI/m.open.open=2duri"])
|
124
|
+
def test_methodid2libid(data)
|
125
|
+
expected, target = data
|
126
|
+
assert_equal(expected, methodid2libid(target))
|
103
127
|
end
|
104
128
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
129
|
+
data("String/i.index._builtin" => ["String", "String/i.index._builtin"],
|
130
|
+
"CGI/i.accept.cgi" => ["CGI", "CGI/i.accept.cgi"],
|
131
|
+
"Net=HTTP/i.ca_path.net.http" => ["Net=HTTP", "Net=HTTP/i.ca_path.net.http"])
|
132
|
+
def test_methodid2classid(data)
|
133
|
+
expected, target = data
|
134
|
+
assert_equal(expected, methodid2classid(target))
|
109
135
|
end
|
110
136
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
137
|
+
data("String/i.index._builtin" => [:instance_method, "String/i.index._builtin"],
|
138
|
+
"CGI/i.accept.cgi" => [:instance_method, "CGI/i.accept.cgi"],
|
139
|
+
"Net=HTTP/i.ca_path.net.http" => [:instance_method, "Net=HTTP/i.ca_path.net.http"],
|
140
|
+
"String/s.new._builtin" => [:singleton_method, "String/s.new._builtin"])
|
141
|
+
def test_methodid2typename(data)
|
142
|
+
expected, target = data
|
143
|
+
assert_equal(expected, methodid2typename(target))
|
116
144
|
end
|
117
145
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
146
|
+
data("String/i.index._builtin" => ["index", "String/i.index._builtin"],
|
147
|
+
"CGI/i.accept.cgi" => ["accept", "CGI/i.accept.cgi"],
|
148
|
+
"Net=HTTP/i.ca_path.net.http" => ["ca_path", "Net=HTTP/i.ca_path.net.http"])
|
149
|
+
def test_methodid2mname(data)
|
150
|
+
expected, target = data
|
151
|
+
assert_equal(expected, methodid2mname(target))
|
122
152
|
end
|
123
153
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
154
|
+
data("index" => [true, "index"],
|
155
|
+
"accept" => [true, "accept"],
|
156
|
+
"get" => [true, "get"],
|
157
|
+
"Array" => [true, "Array"],
|
158
|
+
"getIndex" => [true, "getIndex"],
|
159
|
+
"PROXY" => [true, "PROXY"],
|
160
|
+
"HTTP_PROXY" => [true, "HTTP_PROXY"],
|
161
|
+
"gsub!" => [true, "gsub!"],
|
162
|
+
"empty? " => [true, "empty?"],
|
163
|
+
"instance_eval" => [true, "instance_eval"],
|
164
|
+
"__send" => [true, "__send"],
|
165
|
+
"__send__" => [true, "__send__"],
|
166
|
+
"__send!" => [true, "__send!"],
|
167
|
+
"+" => [true, "+"],
|
168
|
+
"-" => [true, "-"],
|
169
|
+
"*" => [true, "*"],
|
170
|
+
"/" => [true, "/"],
|
171
|
+
"&" => [true, "&"],
|
172
|
+
"|" => [true, "|"],
|
173
|
+
"^" => [true, "^"],
|
174
|
+
"`" => [true, "`"],
|
175
|
+
">>" => [true, ">>"],
|
176
|
+
"<<" => [true, "<<"],
|
177
|
+
"+@" => [true, "+@"],
|
178
|
+
"-@" => [true, "-@"],
|
179
|
+
"!" => [true, "!"],
|
180
|
+
"!@" => [true, "!@"],
|
181
|
+
"~" => [true, "~"],
|
182
|
+
"**" => [true, "**"],
|
183
|
+
"<" => [true, "<"],
|
184
|
+
">" => [true, ">"],
|
185
|
+
"<=" => [true, "<="],
|
186
|
+
">=" => [true, ">="],
|
187
|
+
"==" => [true, "=="],
|
188
|
+
"===" => [true, "==="],
|
189
|
+
"=~" => [true, "=~"],
|
190
|
+
"[]" => [true, "[]"],
|
191
|
+
"[]=" => [true, "[]="],
|
192
|
+
"" => [false, ""],
|
193
|
+
"!=" => [true, "!="],
|
194
|
+
"!~" => [true, "!~"],
|
195
|
+
"&&" => [false, "&&"],
|
196
|
+
"||" => [false, "||"],
|
197
|
+
"++" => [false, "++"],
|
198
|
+
">>>" => [false, ">>>"],
|
199
|
+
"***" => [false, "***"],
|
200
|
+
"====" => [false, "===="],
|
201
|
+
"#accept" => [false, "#accept"],
|
202
|
+
".new" => [false, ".new"],
|
203
|
+
".#cp" => [false, ".#cp"],
|
204
|
+
"$gvar" => [false, "$gvar"],
|
205
|
+
"CGI#accept" => [false, "CGI#accept"],
|
206
|
+
"String.new" => [false, "String.new"],
|
207
|
+
"Net::HTTP.get" => [false, "Net::HTTP.get"],
|
208
|
+
"Net::HTTP.new" => [false, "Net::HTTP.new"])
|
209
|
+
def test_methodname?(data)
|
210
|
+
expected, target = data
|
211
|
+
assert_equal(expected, methodname?(target))
|
181
212
|
end
|
182
213
|
|
183
214
|
def test_build_method_id
|
@@ -191,134 +222,167 @@ class TestNameUtils < Test::Unit::TestCase
|
|
191
222
|
# split_method_id("String/i.index._builtin")
|
192
223
|
#end
|
193
224
|
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
225
|
+
data(:instance_method => [true, :instance_method],
|
226
|
+
:singleton_method => [true, :singleton_method],
|
227
|
+
:module_function => [true, :module_function],
|
228
|
+
:constant => [true, :constant],
|
229
|
+
:special_variable => [true, :special_variable],
|
230
|
+
:instance_eval => [false, :instance_eval],
|
231
|
+
:instance => [false, :instance],
|
232
|
+
:singleton => [false, :singleton],
|
233
|
+
"i" => [false, "i"],
|
234
|
+
"s" => [false, "s"],
|
235
|
+
:i => [false, :i],
|
236
|
+
:s => [false, :s])
|
237
|
+
def test_typename?(data)
|
238
|
+
expected, target = data
|
239
|
+
assert_equal(expected, typename?(target))
|
207
240
|
end
|
208
241
|
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
242
|
+
data do
|
243
|
+
data_set = {}
|
244
|
+
typemarks = [".", "#", ".#", "$", "::"]
|
245
|
+
typemarks.each do |mark|
|
246
|
+
data_set[mark] = [true, mark]
|
247
|
+
end
|
215
248
|
#marks = (0..255).map {|a| (0..255).map {|b| a.chr + b.chr } }.flatten
|
216
249
|
marks = (0..127).map {|a| (0..127).map {|b| a.chr + b.chr } }.flatten
|
217
|
-
(marks -
|
218
|
-
|
250
|
+
(marks - typemarks).each do |m|
|
251
|
+
data_set[m] = [false, m]
|
219
252
|
end
|
253
|
+
data_set
|
254
|
+
end
|
255
|
+
def test_typemark?(data)
|
256
|
+
expected, target = data
|
257
|
+
assert_equal(expected, typemark?(target))
|
220
258
|
end
|
221
259
|
|
222
|
-
|
260
|
+
data do
|
261
|
+
data_set = {}
|
223
262
|
typechars = %w( i s m c v )
|
224
|
-
typechars.each do |
|
225
|
-
|
263
|
+
typechars.each do |char|
|
264
|
+
data_set[char] = [true, char]
|
226
265
|
end
|
227
|
-
((0..255).map {|b| b.chr } - typechars).each do |
|
228
|
-
|
266
|
+
((0..255).map {|b| b.chr } - typechars).each do |char|
|
267
|
+
data_set[char] = [false, char]
|
229
268
|
end
|
269
|
+
data_set
|
270
|
+
end
|
271
|
+
def test_typechar?(data)
|
272
|
+
expected, target = data
|
273
|
+
assert_equal(expected, typechar?(target))
|
230
274
|
end
|
231
275
|
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
276
|
+
data(:singleton_method => ["s", :singleton_method],
|
277
|
+
:instance_method => ["i", :instance_method],
|
278
|
+
:module_function => ["m", :module_function],
|
279
|
+
:constant => ["c", :constant],
|
280
|
+
:special_variable => ["v", :special_variable])
|
281
|
+
def test_typename2char(data)
|
282
|
+
expected, target = data
|
283
|
+
assert_equal(expected, typename2char(target))
|
238
284
|
end
|
239
285
|
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
286
|
+
data("s" => [:singleton_method, "s"],
|
287
|
+
"i" => [:instance_method, "i"],
|
288
|
+
"m" => [:module_function, "m"],
|
289
|
+
"c" => [:constant, "c"],
|
290
|
+
"v" => [:special_variable, "v"])
|
291
|
+
def test_typechar2name(data)
|
292
|
+
expected, target = data
|
293
|
+
assert_equal(expected, typechar2name(target))
|
246
294
|
end
|
247
295
|
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
296
|
+
data("." => ["s", "."],
|
297
|
+
"#" => ["i", "#"],
|
298
|
+
".#" => ["m", ".#"],
|
299
|
+
"::" => ["c", "::"],
|
300
|
+
"$" => ["v", "$"])
|
301
|
+
def test_typemark2char(data)
|
302
|
+
expected, target = data
|
303
|
+
assert_equal(expected, typemark2char(target))
|
254
304
|
end
|
255
305
|
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
306
|
+
data("s" => [".", "s"],
|
307
|
+
"i" => ["#", "i"],
|
308
|
+
"m" => [".#", "m"],
|
309
|
+
"c" => ["::", "c"],
|
310
|
+
"v" => ["$", "v"])
|
311
|
+
def test_typechar2mark(data)
|
312
|
+
expected, target = data
|
313
|
+
assert_equal(expected, typechar2mark(target))
|
262
314
|
end
|
263
315
|
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
316
|
+
data("Array" => ["Array", "Array"],
|
317
|
+
"String" => ["String", "String"],
|
318
|
+
"index" => ["index", "index"],
|
319
|
+
"*" => ["=2a", "*"],
|
320
|
+
"**" => ["=2a=2a", "**"],
|
321
|
+
"open-uri" => ["open=2duri", "open-uri"],
|
322
|
+
"net.http" => ["net=2ehttp", "net.http"])
|
323
|
+
def test_encodename_url(data)
|
324
|
+
expected, target = data
|
325
|
+
assert_equal(expected, encodename_url(target))
|
272
326
|
end
|
273
327
|
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
328
|
+
data("Array" => ["Array", "Array"],
|
329
|
+
"String" => ["String", "String"],
|
330
|
+
"index" => ["index", "index"],
|
331
|
+
"=2a" => ["*", "=2a"],
|
332
|
+
"=2a=2a" => ["**", "=2a=2a"],
|
333
|
+
"open=2duri" => ["open-uri", "open=2duri"],
|
334
|
+
"net=2ehttp" => ["net.http", "net=2ehttp"])
|
335
|
+
def test_decodename_url(data)
|
336
|
+
expected, target = data
|
337
|
+
assert_equal(expected, decodename_url(target))
|
282
338
|
end
|
283
339
|
|
340
|
+
data("Array" => ["-array", "Array"],
|
341
|
+
"String" => ["-string", "String"],
|
342
|
+
"CGI" => ["-c-g-i", "CGI"],
|
343
|
+
"=2a" => ["=2a", "=2a"],
|
344
|
+
"=2a=2a" => ["=2a=2a", "=2a=2a"],
|
345
|
+
"open=2duri" => ["open=2duri", "open=2duri"],
|
346
|
+
"Net=HTTP" => ["-net=-h-t-t-p", "Net=HTTP"])
|
284
347
|
def test_encodeid
|
285
|
-
|
286
|
-
assert_equal
|
287
|
-
assert_equal "-c-g-i", encodeid("CGI")
|
288
|
-
assert_equal "=2a", encodeid("=2a")
|
289
|
-
assert_equal "=2a=2a", encodeid("=2a=2a")
|
290
|
-
assert_equal "open=2duri", encodeid("open=2duri")
|
291
|
-
assert_equal "-net=-h-t-t-p", encodeid("Net=HTTP")
|
348
|
+
expected, target = data
|
349
|
+
assert_equal(expected, encodeid(target))
|
292
350
|
end
|
293
351
|
|
352
|
+
data("-array" => ["Array", "-array"],
|
353
|
+
"-string" => ["String", "-string"],
|
354
|
+
"-c-g-i" => ["CGI", "-c-g-i"],
|
355
|
+
"=2a" => ["=2a", "=2a"],
|
356
|
+
"=2a=2a" => ["=2a=2a", "=2a=2a"],
|
357
|
+
"open=2duri" => ["open=2duri", "open=2duri"],
|
358
|
+
"-net=-h-t-t-p" => ["Net=HTTP", "-net=-h-t-t-p"])
|
294
359
|
def test_decodeid
|
295
|
-
|
296
|
-
assert_equal
|
297
|
-
assert_equal "CGI", decodeid("-c-g-i")
|
298
|
-
assert_equal "=2a", decodeid("=2a")
|
299
|
-
assert_equal "=2a=2a", decodeid("=2a=2a")
|
300
|
-
assert_equal "open=2duri", decodeid("open=2duri")
|
301
|
-
assert_equal "Net=HTTP", decodeid("-net=-h-t-t-p")
|
360
|
+
expected, target = data
|
361
|
+
assert_equal(expected, decodeid(target))
|
302
362
|
end
|
303
363
|
|
364
|
+
data("Array" => ["-array", "Array"],
|
365
|
+
"String" => ["-string", "String"],
|
366
|
+
"index" => ["index", "index"],
|
367
|
+
"*" => ["=2a", "*"],
|
368
|
+
"**" => ["=2a=2a", "**"],
|
369
|
+
"open-uri" => ["open=2duri", "open-uri"],
|
370
|
+
"net.http" => ["net=2ehttp", "net.http"])
|
304
371
|
def test_encodename_fs
|
305
|
-
|
306
|
-
assert_equal
|
307
|
-
assert_equal "index", encodename_fs("index")
|
308
|
-
assert_equal "=2a", encodename_fs("*")
|
309
|
-
assert_equal "=2a=2a", encodename_fs("**")
|
310
|
-
assert_equal "open=2duri", encodename_fs("open-uri")
|
311
|
-
assert_equal "net=2ehttp", encodename_fs("net.http")
|
372
|
+
expected, target = data
|
373
|
+
assert_equal(expected, encodename_fs(target))
|
312
374
|
end
|
313
375
|
|
376
|
+
data("-array" => ["Array", "-array"],
|
377
|
+
"-string" => ["String", "-string"],
|
378
|
+
"index" => ["index", "index"],
|
379
|
+
"=2a" => ["*", "=2a"],
|
380
|
+
"=2a=2a" => ["**", "=2a=2a"],
|
381
|
+
"open=2duri" => ["open-uri", "open=2duri"],
|
382
|
+
"net=2ehttp" => ["net.http", "net=2ehttp"])
|
314
383
|
def test_decodename_fs
|
315
|
-
|
316
|
-
assert_equal
|
317
|
-
assert_equal "index", decodename_fs("index")
|
318
|
-
assert_equal "*", decodename_fs("=2a")
|
319
|
-
assert_equal "**", decodename_fs("=2a=2a")
|
320
|
-
assert_equal "open-uri", decodename_fs("open=2duri")
|
321
|
-
assert_equal "net.http", decodename_fs("net=2ehttp")
|
384
|
+
expected, target = data
|
385
|
+
assert_equal(expected, decodename_fs(target))
|
322
386
|
end
|
323
387
|
|
324
388
|
end
|