bitclust-core 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README +16 -5
- data/data/bitclust/template.lillia/layout +1 -1
- data/data/bitclust/template.offline/layout +1 -1
- data/data/bitclust/template/layout +1 -1
- data/lib/bitclust/app.rb +5 -1
- data/lib/bitclust/classentry.rb +1 -1
- data/lib/bitclust/compat.rb +4 -0
- data/lib/bitclust/completion.rb +5 -0
- data/lib/bitclust/crossrubyutils.rb +2 -0
- data/lib/bitclust/database.rb +4 -0
- data/lib/bitclust/docentry.rb +1 -0
- data/lib/bitclust/entry.rb +8 -0
- data/lib/bitclust/functiondatabase.rb +1 -0
- data/lib/bitclust/functionreferenceparser.rb +6 -0
- data/lib/bitclust/htmlutils.rb +1 -0
- data/lib/bitclust/interface.rb +1 -0
- data/lib/bitclust/libraryentry.rb +1 -0
- data/lib/bitclust/lineinput.rb +1 -0
- data/lib/bitclust/messagecatalog.rb +4 -0
- data/lib/bitclust/methoddatabase.rb +3 -0
- data/lib/bitclust/methodentry.rb +2 -1
- data/lib/bitclust/methodid.rb +3 -0
- data/lib/bitclust/methodsignature.rb +2 -0
- data/lib/bitclust/nameutils.rb +1 -0
- data/lib/bitclust/parseutils.rb +5 -0
- data/lib/bitclust/preprocessor.rb +3 -0
- data/lib/bitclust/rdcompiler.rb +1 -0
- data/lib/bitclust/refsdatabase.rb +2 -0
- data/lib/bitclust/requesthandler.rb +3 -2
- data/lib/bitclust/ridatabase.rb +2 -0
- data/lib/bitclust/rrdparser.rb +1 -0
- data/lib/bitclust/runner.rb +1 -4
- data/lib/bitclust/searcher.rb +16 -0
- data/lib/bitclust/server.rb +1 -0
- data/lib/bitclust/silent_progress_bar.rb +1 -0
- data/lib/bitclust/simplesearcher.rb +2 -0
- data/lib/bitclust/subcommand.rb +2 -0
- data/lib/bitclust/subcommands/server_command.rb +1 -1
- data/lib/bitclust/subcommands/setup_command.rb +33 -3
- data/lib/bitclust/textutils.rb +1 -0
- data/lib/bitclust/version.rb +1 -1
- data/test/test_functiondatabase.rb +55 -55
- data/test/test_runner.rb +4 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20aa499245063832cb75dcfdbc4cb68556b2aac2
|
4
|
+
data.tar.gz: 3fe3945f3f873d42c2d292a7b0592dffe4aabf45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6f5ab20e05ce5bdcd63053915ccc4bd055c939fd5024eb247e7afb3d7f85e3f5c9ba8f9c839428c1d36fa6590d4a39dbe71c297045d2ad3dc80668d2a0d3327
|
7
|
+
data.tar.gz: 6d8a3ddc90d4134696155c4a02ceb891cf9f4e89cb73e70f0c745dccad206ab2a453e42e65e31dfb39cbc7bddb53c530f11501d345bb5750fa65296bda93cdf9
|
data/README
CHANGED
@@ -14,8 +14,19 @@ License
|
|
14
14
|
Ruby License.
|
15
15
|
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
Glossary
|
18
|
+
--------
|
19
|
+
|
20
|
+
* "entry"
|
21
|
+
* Each target of documentation.
|
22
|
+
* classes: Entry LibraryEntry ClassEntry MethodEntry DocEntry FunctionEntry
|
23
|
+
* "screen"
|
24
|
+
* View class.
|
25
|
+
* Used by BitClust server, chm_command, statichtml_command, etc.
|
26
|
+
* "singleton object"
|
27
|
+
* ARGF, main, etc.
|
28
|
+
* "BitClust server"
|
29
|
+
* HTTP server application to view refenence on browser.
|
30
|
+
* "Refe server"
|
31
|
+
* DRb server spawned by refe --server.
|
32
|
+
* Expose BitClust DB via DRuby.
|
data/lib/bitclust/app.rb
CHANGED
@@ -3,6 +3,10 @@ require 'bitclust/interface'
|
|
3
3
|
|
4
4
|
module BitClust
|
5
5
|
|
6
|
+
# Main class of BitClust server application.
|
7
|
+
# Actual actions are implemneted by RequestHandler.
|
8
|
+
#
|
9
|
+
# Supports Rack and WEBrick.
|
6
10
|
class App
|
7
11
|
|
8
12
|
def initialize(options)
|
@@ -122,7 +126,7 @@ module BitClust
|
|
122
126
|
[
|
123
127
|
200,
|
124
128
|
{'Content-Type' => 'text/html; charset=utf-8'},
|
125
|
-
index(Rack::Request.new(env))
|
129
|
+
[index(Rack::Request.new(env))]
|
126
130
|
]
|
127
131
|
end
|
128
132
|
end
|
data/lib/bitclust/classentry.rb
CHANGED
data/lib/bitclust/compat.rb
CHANGED
data/lib/bitclust/completion.rb
CHANGED
@@ -9,6 +9,8 @@
|
|
9
9
|
|
10
10
|
module BitClust
|
11
11
|
|
12
|
+
# Provides completion search methods like _search_classes, _search_methods.
|
13
|
+
# Included by MethodDatabase and FunctionDatabase.
|
12
14
|
module Completion
|
13
15
|
|
14
16
|
private
|
@@ -395,6 +397,8 @@ $cm_comb_m += 1
|
|
395
397
|
end
|
396
398
|
|
397
399
|
|
400
|
+
# Represents result of completion search.
|
401
|
+
# Has many SearchResult::Record.
|
398
402
|
class SearchResult
|
399
403
|
|
400
404
|
def SearchResult.empty(db, pattern)
|
@@ -445,6 +449,7 @@ $cm_comb_m += 1
|
|
445
449
|
@records.sort.each(&block)
|
446
450
|
end
|
447
451
|
|
452
|
+
# Wraps an Entry.
|
448
453
|
class Record
|
449
454
|
def initialize(db, spec, origin = nil, entry = nil)
|
450
455
|
@db = db
|
data/lib/bitclust/database.rb
CHANGED
data/lib/bitclust/docentry.rb
CHANGED
data/lib/bitclust/entry.rb
CHANGED
@@ -13,6 +13,7 @@ require 'bitclust/exception'
|
|
13
13
|
|
14
14
|
module BitClust
|
15
15
|
|
16
|
+
# Ancestor of entry classes.
|
16
17
|
class Entry
|
17
18
|
|
18
19
|
include NameUtils
|
@@ -70,6 +71,13 @@ module BitClust
|
|
70
71
|
@slots.push Property.new(name, type)
|
71
72
|
end
|
72
73
|
|
74
|
+
# Used to define specific property of each entry class.
|
75
|
+
#
|
76
|
+
# Example
|
77
|
+
# persistent_properties {
|
78
|
+
# property :requires, '[LibraryEntry]'
|
79
|
+
# property :classes, '[ClassEntry]'
|
80
|
+
# ...
|
73
81
|
class Property
|
74
82
|
def initialize(name, type)
|
75
83
|
@name = name
|
@@ -11,8 +11,12 @@ require 'bitclust/exception'
|
|
11
11
|
|
12
12
|
module BitClust
|
13
13
|
|
14
|
+
# Parser for C API reference file (refm/capi/src/*)
|
15
|
+
# Much simpler than Ruby API reference parser(RRDParser)
|
16
|
+
# because C APIs does not have library, class, etc.
|
14
17
|
class FunctionReferenceParser
|
15
18
|
|
19
|
+
# Returns an array of FunctionEntry
|
16
20
|
def FunctionReferenceParser.parse_file(path, params = {"version" => "1.9.0"})
|
17
21
|
parser = new(FunctionDatabase.dummy(params))
|
18
22
|
parser.parse_file(path, File.basename(path, ".rd"), params)
|
@@ -71,6 +75,8 @@ module BitClust
|
|
71
75
|
|
72
76
|
end
|
73
77
|
|
78
|
+
# Represents C function signature
|
79
|
+
# (Used internally in this file)
|
74
80
|
FunctionHeader = Struct.new(:macro, :private, :type, :name, :params)
|
75
81
|
|
76
82
|
end
|
data/lib/bitclust/htmlutils.rb
CHANGED
data/lib/bitclust/interface.rb
CHANGED
data/lib/bitclust/lineinput.rb
CHANGED
@@ -9,6 +9,7 @@
|
|
9
9
|
|
10
10
|
module BitClust
|
11
11
|
|
12
|
+
# Provides methods to use MessageCatalog
|
12
13
|
module Translatable
|
13
14
|
|
14
15
|
private
|
@@ -27,6 +28,9 @@ module BitClust
|
|
27
28
|
|
28
29
|
end
|
29
30
|
|
31
|
+
# Tiny implementation of message catalog (I18N)
|
32
|
+
# see data/bitclust/catalog/ja_JP.UTF-8
|
33
|
+
#
|
30
34
|
# FIXME: support automatic encoding-conversion
|
31
35
|
class MessageCatalog
|
32
36
|
|
@@ -20,6 +20,7 @@ require 'fileutils'
|
|
20
20
|
|
21
21
|
module BitClust
|
22
22
|
|
23
|
+
# Database for Ruby entries (library, class, method).
|
23
24
|
class MethodDatabase < Database
|
24
25
|
|
25
26
|
include Completion
|
@@ -343,6 +344,8 @@ module BitClust
|
|
343
344
|
# Method Entry
|
344
345
|
#
|
345
346
|
|
347
|
+
# Return existing/newly created MethodEntry from the given MethodID
|
348
|
+
#
|
346
349
|
# FIXME: see kind
|
347
350
|
def open_method(id)
|
348
351
|
check_transaction
|
data/lib/bitclust/methodentry.rb
CHANGED
@@ -12,7 +12,8 @@ require 'bitclust/exception'
|
|
12
12
|
|
13
13
|
module BitClust
|
14
14
|
|
15
|
-
#
|
15
|
+
# Entry for methods(instance methods/singleton methods/module_functions),
|
16
|
+
# constants and special variables(like $!).
|
16
17
|
class MethodEntry < Entry
|
17
18
|
|
18
19
|
def MethodEntry.type_id
|
data/lib/bitclust/methodid.rb
CHANGED
@@ -13,6 +13,9 @@ require 'bitclust/exception'
|
|
13
13
|
|
14
14
|
module BitClust
|
15
15
|
|
16
|
+
# Represents infomation to identify a method (library, class/module,
|
17
|
+
# type and name.)
|
18
|
+
#
|
16
19
|
# A MethodID has #library, #klass, #typename, and method name.
|
17
20
|
# #library, #klass, #typename must be an object.
|
18
21
|
class MethodID
|
data/lib/bitclust/nameutils.rb
CHANGED
data/lib/bitclust/parseutils.rb
CHANGED
@@ -15,6 +15,8 @@ end
|
|
15
15
|
|
16
16
|
module BitClust
|
17
17
|
|
18
|
+
# Provides line-wise access to a file with :file and :line.
|
19
|
+
# Used by Preprocessor
|
18
20
|
class LineStream
|
19
21
|
def initialize(f)
|
20
22
|
@f = f
|
@@ -33,6 +35,8 @@ module BitClust
|
|
33
35
|
end
|
34
36
|
end
|
35
37
|
|
38
|
+
# Encapsulates :file and :line.
|
39
|
+
# Used by LineStream(above)
|
36
40
|
class Location
|
37
41
|
def initialize(file, line)
|
38
42
|
@file = file
|
@@ -51,6 +55,7 @@ module BitClust
|
|
51
55
|
end
|
52
56
|
end
|
53
57
|
|
58
|
+
# Utilities for parsing
|
54
59
|
module ParseUtils
|
55
60
|
def parse_error(msg, line)
|
56
61
|
raise ParseError, "#{line.location}: #{msg}: #{line.inspect}"
|
@@ -12,6 +12,7 @@ require 'strscan'
|
|
12
12
|
|
13
13
|
module BitClust
|
14
14
|
|
15
|
+
# Superclass of Preprocessor
|
15
16
|
class LineFilter
|
16
17
|
|
17
18
|
include ParseUtils
|
@@ -37,6 +38,7 @@ module BitClust
|
|
37
38
|
end
|
38
39
|
|
39
40
|
|
41
|
+
# Handle pragmas like #@todo, #@include, #@since, etc.
|
40
42
|
class Preprocessor < LineFilter
|
41
43
|
|
42
44
|
def self.read(path, params = {})
|
@@ -236,6 +238,7 @@ module BitClust
|
|
236
238
|
end
|
237
239
|
|
238
240
|
|
241
|
+
# Used by tools/stattodo.rb
|
239
242
|
class LineCollector < LineFilter
|
240
243
|
|
241
244
|
def LineCollector.process(path)
|
data/lib/bitclust/rdcompiler.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
|
2
2
|
# bitclust/requesthandler.rb
|
3
3
|
#
|
4
4
|
# Copyright (c) 2006-2008 Minero Aoki
|
@@ -15,6 +15,7 @@ require 'bitclust/simplesearcher'
|
|
15
15
|
|
16
16
|
module BitClust
|
17
17
|
|
18
|
+
# Actions of BitClust server.
|
18
19
|
class RequestHandler
|
19
20
|
|
20
21
|
def initialize(db, manager)
|
@@ -321,7 +322,7 @@ module BitClust
|
|
321
322
|
{
|
322
323
|
'Content-Type' => @screen.content_type,
|
323
324
|
},
|
324
|
-
@screen.body
|
325
|
+
[@screen.body]
|
325
326
|
]
|
326
327
|
end
|
327
328
|
|
data/lib/bitclust/ridatabase.rb
CHANGED
@@ -5,6 +5,8 @@ require 'rdoc/ri/ri_paths'
|
|
5
5
|
class ApplicationError < StandardError; end
|
6
6
|
class RiClassNotFound < ApplicationError; end
|
7
7
|
|
8
|
+
# Handle RDoc(ri) database for tools/bc-rdoc.rb and
|
9
|
+
# `bitclust methods --diff`.
|
8
10
|
class RiDatabase
|
9
11
|
def RiDatabase.open_system_db
|
10
12
|
new(RI::Paths.path(true, false, false, false), RUBY_VERSION)
|
data/lib/bitclust/rrdparser.rb
CHANGED
data/lib/bitclust/runner.rb
CHANGED
@@ -20,6 +20,7 @@ Dir.glob(File.join(subcommands_dir.to_s, "*.rb")) do |entry|
|
|
20
20
|
end
|
21
21
|
|
22
22
|
module BitClust
|
23
|
+
# Body of bin/bitclust.
|
23
24
|
class Runner
|
24
25
|
def initialize
|
25
26
|
end
|
@@ -130,10 +131,6 @@ Global Options:
|
|
130
131
|
@version ||= config[:default_version]
|
131
132
|
@prefix ||= "#{config[:database_prefix]}-#{@version}"
|
132
133
|
end
|
133
|
-
unless @prefix
|
134
|
-
$stderr.puts "no database given. Use --database option"
|
135
|
-
exit 1
|
136
|
-
end
|
137
134
|
options = {
|
138
135
|
:prefix => @prefix,
|
139
136
|
:capi => @capi
|
data/lib/bitclust/searcher.rb
CHANGED
@@ -20,6 +20,7 @@ require 'yaml'
|
|
20
20
|
|
21
21
|
module BitClust
|
22
22
|
|
23
|
+
# Body of bin/refe.
|
23
24
|
class Searcher
|
24
25
|
|
25
26
|
include NameUtils
|
@@ -443,8 +444,23 @@ module BitClust
|
|
443
444
|
puts
|
444
445
|
puts @compiler.compile(c.source.strip)
|
445
446
|
end
|
447
|
+
|
448
|
+
print_methods(c, :module_function, "* Module functions")
|
449
|
+
print_methods(c, :singleton_method, "* Singleton methods")
|
450
|
+
print_methods(c, :instance_method, "* Instance methods")
|
451
|
+
print_methods(c, :constant, "* Constants")
|
452
|
+
print_methods(c, :special_variable, "* Special variables")
|
446
453
|
end
|
447
454
|
|
455
|
+
def print_methods(c, typename, title)
|
456
|
+
methods = c.methods.select{|m| m.typename == typename }
|
457
|
+
return if methods.empty?
|
458
|
+
|
459
|
+
puts
|
460
|
+
puts title
|
461
|
+
print_names methods.map{|m| m.name }
|
462
|
+
end
|
463
|
+
|
448
464
|
def describe_method(rec)
|
449
465
|
unless rec.entry.library.name == '_builtin'
|
450
466
|
puts "require '#{rec.entry.library.name}'"
|
data/lib/bitclust/server.rb
CHANGED
data/lib/bitclust/subcommand.rb
CHANGED
@@ -9,6 +9,7 @@ require 'yaml'
|
|
9
9
|
|
10
10
|
module BitClust
|
11
11
|
|
12
|
+
# Base class for bitclust subcommands.
|
12
13
|
class Subcommand
|
13
14
|
def initialize
|
14
15
|
@parser = OptionParser.new
|
@@ -28,6 +29,7 @@ module BitClust
|
|
28
29
|
|
29
30
|
def exec(argv, options)
|
30
31
|
prefix = options[:prefix]
|
32
|
+
error("no database given. Use --database option") unless prefix
|
31
33
|
if options[:capi]
|
32
34
|
@db = BitClust::FunctionDatabase.new(prefix)
|
33
35
|
else
|
@@ -40,7 +40,7 @@ module BitClust
|
|
40
40
|
@parser.on('--bind-address=ADDR', 'Bind address') {|addr|
|
41
41
|
@params[:BindAddress] = addr
|
42
42
|
}
|
43
|
-
@parser.on('--port=NUM',
|
43
|
+
@parser.on('--port=NUM', "Listening port number (default: #{@params[:Port]})") {|num|
|
44
44
|
@params[:Port] = num.to_i
|
45
45
|
}
|
46
46
|
@parser.on('--baseurl=URL', 'The base URL to host.') {|url|
|
@@ -12,12 +12,13 @@ module BitClust
|
|
12
12
|
module Subcommands
|
13
13
|
class SetupCommand < Subcommand
|
14
14
|
|
15
|
-
REPOSITORY_PATH = "
|
15
|
+
REPOSITORY_PATH = "https://github.com/rurema/doctree.git"
|
16
16
|
|
17
17
|
def initialize
|
18
18
|
super
|
19
19
|
@prepare = nil
|
20
20
|
@cleanup = nil
|
21
|
+
@purge = nil
|
21
22
|
@versions = ["1.8.7", "1.9.3", "2.0.0"]
|
22
23
|
@parser.banner = "Usage: #{File.basename($0, '.*')} setup [options]"
|
23
24
|
@parser.on('--prepare', 'Prepare config file and checkout repository. Do not create database.') {
|
@@ -26,12 +27,16 @@ module BitClust
|
|
26
27
|
@parser.on('--cleanup', 'Cleanup datebase before create database.') {
|
27
28
|
@cleanup = true
|
28
29
|
}
|
30
|
+
@parser.on('--purge', 'Purge all downloaded and generated files and exit.') {
|
31
|
+
@purge = true
|
32
|
+
}
|
29
33
|
@parser.on('--versions=V1,V2,...', "Specify versions. [#{@versions.join(',')}]") {|versions|
|
30
34
|
@versions = versions.split(",")
|
31
35
|
}
|
32
36
|
end
|
33
37
|
|
34
38
|
def exec(argv, options)
|
39
|
+
purge if @purge
|
35
40
|
prepare
|
36
41
|
return if @prepare
|
37
42
|
@config[:versions].each do |version|
|
@@ -49,6 +54,15 @@ module BitClust
|
|
49
54
|
|
50
55
|
private
|
51
56
|
|
57
|
+
def purge
|
58
|
+
home_directory = Pathname(ENV["HOME"])
|
59
|
+
config_dir = home_directory + ".bitclust"
|
60
|
+
print "Remove all generated files..."
|
61
|
+
FileUtils.rm_rf(config_dir.to_s)
|
62
|
+
puts "done!"
|
63
|
+
exit 0
|
64
|
+
end
|
65
|
+
|
52
66
|
def prepare
|
53
67
|
home_directory = Pathname(ENV["HOME"])
|
54
68
|
config_dir = home_directory + ".bitclust"
|
@@ -89,8 +103,24 @@ module BitClust
|
|
89
103
|
end
|
90
104
|
|
91
105
|
def checkout(rubydoc_dir)
|
92
|
-
|
93
|
-
warn "
|
106
|
+
if (rubydoc_dir + ".svn").exist?
|
107
|
+
warn "Remove old repository data."
|
108
|
+
warn "Use --purge option."
|
109
|
+
help
|
110
|
+
exit 1
|
111
|
+
end
|
112
|
+
|
113
|
+
succeeded = false
|
114
|
+
if (rubydoc_dir + ".git").exist?
|
115
|
+
Dir.chdir(rubydoc_dir) do
|
116
|
+
succeeded = system("git", "pull", "--rebase")
|
117
|
+
end
|
118
|
+
else
|
119
|
+
succeeded = system("git", "clone", "--depth", "10", REPOSITORY_PATH, rubydoc_dir.to_s)
|
120
|
+
end
|
121
|
+
|
122
|
+
unless succeeded
|
123
|
+
warn "git command failed. Please install Git or check your PATH."
|
94
124
|
exit 1
|
95
125
|
end
|
96
126
|
end
|
data/lib/bitclust/textutils.rb
CHANGED
data/lib/bitclust/version.rb
CHANGED
@@ -1,55 +1,55 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'bitclust'
|
3
|
-
require 'bitclust/functiondatabase'
|
4
|
-
require 'tmpdir'
|
5
|
-
require 'fileutils'
|
6
|
-
|
7
|
-
class TesFunctionDatabase < Test::Unit::TestCase
|
8
|
-
def setup
|
9
|
-
prefix = 'db'
|
10
|
-
src = "test.rd"
|
11
|
-
|
12
|
-
@pwd = Dir.pwd
|
13
|
-
Dir.chdir(@tmpdir = Dir.mktmpdir)
|
14
|
-
File.open(src, 'w') do |file|
|
15
|
-
file.puts <<'HERE'
|
16
|
-
--- VALUE func1()
|
17
|
-
|
18
|
-
some text
|
19
|
-
|
20
|
-
--- VALUE func2()
|
21
|
-
|
22
|
-
some text
|
23
|
-
HERE
|
24
|
-
end
|
25
|
-
@db = BitClust::FunctionDatabase.new(prefix)
|
26
|
-
@db.transaction {
|
27
|
-
@db.update_by_file(src, src)
|
28
|
-
}
|
29
|
-
end
|
30
|
-
|
31
|
-
def teardown
|
32
|
-
Dir.chdir @pwd
|
33
|
-
FileUtils.rm_r(@tmpdir, :force => true)
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_search_functions__function
|
37
|
-
result = @db.search_functions('func1')
|
38
|
-
assert_not_nil result.first
|
39
|
-
assert_equal 1, result.size
|
40
|
-
assert_equal 'func1', result.first.name
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_search_functions__functions
|
44
|
-
result = @db.search_functions('func')
|
45
|
-
assert_not_nil result.first
|
46
|
-
assert_equal 2, result.size
|
47
|
-
assert_equal %w[func1 func2], result.map(&:name)
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_search_functions__nonexistent
|
51
|
-
assert_raise(BitClust::FunctionNotFound) do
|
52
|
-
@db.search_functions('nonexistent')
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
1
|
+
require 'test/unit'
|
2
|
+
require 'bitclust'
|
3
|
+
require 'bitclust/database/functiondatabase'
|
4
|
+
require 'tmpdir'
|
5
|
+
require 'fileutils'
|
6
|
+
|
7
|
+
class TesFunctionDatabase < Test::Unit::TestCase
|
8
|
+
def setup
|
9
|
+
prefix = 'db'
|
10
|
+
src = "test.rd"
|
11
|
+
|
12
|
+
@pwd = Dir.pwd
|
13
|
+
Dir.chdir(@tmpdir = Dir.mktmpdir)
|
14
|
+
File.open(src, 'w') do |file|
|
15
|
+
file.puts <<'HERE'
|
16
|
+
--- VALUE func1()
|
17
|
+
|
18
|
+
some text
|
19
|
+
|
20
|
+
--- VALUE func2()
|
21
|
+
|
22
|
+
some text
|
23
|
+
HERE
|
24
|
+
end
|
25
|
+
@db = BitClust::Database::FunctionDatabase.new(prefix)
|
26
|
+
@db.transaction {
|
27
|
+
@db.update_by_file(src, src)
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
def teardown
|
32
|
+
Dir.chdir @pwd
|
33
|
+
FileUtils.rm_r(@tmpdir, :force => true)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_search_functions__function
|
37
|
+
result = @db.search_functions('func1')
|
38
|
+
assert_not_nil result.first
|
39
|
+
assert_equal 1, result.size
|
40
|
+
assert_equal 'func1', result.first.name
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_search_functions__functions
|
44
|
+
result = @db.search_functions('func')
|
45
|
+
assert_not_nil result.first
|
46
|
+
assert_equal 2, result.size
|
47
|
+
assert_equal %w[func1 func2], result.map(&:name)
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_search_functions__nonexistent
|
51
|
+
assert_raise(BitClust::Database::FunctionNotFound) do
|
52
|
+
@db.search_functions('nonexistent')
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/test/test_runner.rb
CHANGED
@@ -17,16 +17,18 @@ class TestRunner < Test::Unit::TestCase
|
|
17
17
|
def test_run_setup
|
18
18
|
command = mock(Object.new)
|
19
19
|
mock(::BitClust::Subcommands::SetupCommand).new.returns(command)
|
20
|
+
mock(@runner).load_config.returns(@config)
|
20
21
|
command.parse([])
|
21
|
-
command.exec(
|
22
|
+
command.exec([], {:prefix => @prefix, :capi => false}).returns(nil)
|
22
23
|
@runner.run(["setup"])
|
23
24
|
end
|
24
25
|
|
25
26
|
def test_run_server
|
26
27
|
command = mock(Object.new)
|
27
28
|
mock(::BitClust::Subcommands::ServerCommand).new.returns(command)
|
29
|
+
mock(@runner).load_config.returns(@config)
|
28
30
|
command.parse([])
|
29
|
-
command.exec(
|
31
|
+
command.exec([], {:prefix => @prefix, :capi => false}).returns(nil)
|
30
32
|
@runner.run(["server"])
|
31
33
|
end
|
32
34
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bitclust-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- http://bugs.ruby-lang.org/projects/rurema
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test-unit
|
@@ -222,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
222
222
|
version: '0'
|
223
223
|
requirements: []
|
224
224
|
rubyforge_project: ''
|
225
|
-
rubygems_version: 2.0.
|
225
|
+
rubygems_version: 2.0.3
|
226
226
|
signing_key:
|
227
227
|
specification_version: 4
|
228
228
|
summary: BitClust is a rurema document processor.
|