bitclust-core 0.6.0 → 0.7.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 +7 -0
- data/ChangeLog +7 -0
- data/Gemfile +1 -0
- data/bitclust.gemspec +1 -0
- data/data/bitclust/template.offline/class +1 -1
- data/lib/bitclust/crossrubyutils.rb +2 -2
- data/lib/bitclust/methodentry.rb +1 -2
- data/lib/bitclust/progress_bar.rb +7 -0
- data/lib/bitclust/rdcompiler.rb +1 -1
- data/lib/bitclust/runner.rb +46 -32
- data/lib/bitclust/searcher.rb +14 -13
- data/lib/bitclust/silent_progress_bar.rb +17 -0
- data/lib/bitclust/subcommand.rb +27 -0
- data/lib/bitclust/subcommands/ancestors_command.rb +145 -0
- data/lib/bitclust/subcommands/chm_command.rb +268 -0
- data/lib/bitclust/subcommands/classes_command.rb +73 -0
- data/lib/bitclust/subcommands/extract_command.rb +55 -0
- data/lib/bitclust/subcommands/htmlfile_command.rb +105 -0
- data/lib/bitclust/subcommands/init_command.rb +29 -30
- data/lib/bitclust/subcommands/list_command.rb +39 -41
- data/lib/bitclust/subcommands/lookup_command.rb +71 -73
- data/lib/bitclust/subcommands/methods_command.rb +159 -0
- data/lib/bitclust/subcommands/preproc_command.rb +35 -0
- data/lib/bitclust/subcommands/property_command.rb +47 -48
- data/lib/bitclust/subcommands/query_command.rb +12 -18
- data/lib/bitclust/subcommands/server_command.rb +180 -182
- data/lib/bitclust/subcommands/setup_command.rb +85 -89
- data/lib/bitclust/subcommands/statichtml_command.rb +276 -0
- data/lib/bitclust/subcommands/update_command.rb +39 -41
- data/lib/bitclust/version.rb +1 -1
- data/test/test_bitclust.rb +1 -1
- data/test/test_rdcompiler.rb +1 -1
- data/test/test_runner.rb +7 -14
- metadata +120 -114
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'optparse'
|
3
|
+
|
4
|
+
require 'bitclust/rrdparser'
|
5
|
+
|
6
|
+
module BitClust
|
7
|
+
module Subcommands
|
8
|
+
class PreprocCommand < Subcommand
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
super
|
12
|
+
@params = { "version" => "2.0.0" }
|
13
|
+
@parser.banner = "Usage: #{File.basename($0, '.*')} <file>..."
|
14
|
+
@parser.on('--param=KVPAIR', 'Set parameter by key/value pair.') {|pair|
|
15
|
+
key, value = pair.split('=', 2)
|
16
|
+
params[key] = value
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
def exec(argv, options)
|
21
|
+
argv.each do |path|
|
22
|
+
File.open(path) {|file|
|
23
|
+
Preprocessor.wrap(file, @params).each do |line|
|
24
|
+
puts line
|
25
|
+
end
|
26
|
+
}
|
27
|
+
end
|
28
|
+
rescue WriterError => err
|
29
|
+
$stderr.puts err.message
|
30
|
+
exit 1
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -8,66 +8,65 @@ require 'yaml'
|
|
8
8
|
require 'bitclust'
|
9
9
|
require 'bitclust/subcommand'
|
10
10
|
|
11
|
-
module BitClust
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
11
|
+
module BitClust
|
12
|
+
module Subcommands
|
13
|
+
class PropertyCommand < Subcommand
|
14
|
+
def initialize
|
15
|
+
super
|
16
|
+
@mode = nil
|
17
|
+
@parser.banner = "Usage: #{File.basename($0, '.*')} property [options]"
|
18
|
+
@parser.on('--list', 'List all properties.') {
|
18
19
|
@mode = :list
|
19
20
|
}
|
20
|
-
|
21
|
+
@parser.on('--get', 'Get property value.') {
|
21
22
|
@mode = :get
|
22
23
|
}
|
23
|
-
|
24
|
+
@parser.on('--set', 'Set property value.') {
|
24
25
|
@mode = :set
|
25
26
|
}
|
26
|
-
opt.on('--help', 'Prints this message and quit.') {
|
27
|
-
puts opt.help
|
28
|
-
exit 0
|
29
|
-
}
|
30
|
-
}
|
31
|
-
end
|
32
|
-
|
33
|
-
def parse(argv)
|
34
|
-
super
|
35
|
-
unless @mode
|
36
|
-
error "one of (--list|--get|--set) is required"
|
37
27
|
end
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
28
|
+
|
29
|
+
def parse(argv)
|
30
|
+
super
|
31
|
+
unless @mode
|
32
|
+
error "one of (--list|--get|--set) is required"
|
42
33
|
end
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
34
|
+
case @mode
|
35
|
+
when :list
|
36
|
+
unless argv.empty?
|
37
|
+
error "--list requires no argument"
|
38
|
+
end
|
39
|
+
when :get
|
40
|
+
;
|
41
|
+
when :set
|
42
|
+
unless argv.size == 2
|
43
|
+
error "--set requires just 2 arguments"
|
44
|
+
end
|
45
|
+
else
|
46
|
+
raise "must not happen: #{@mode}"
|
48
47
|
end
|
49
|
-
else
|
50
|
-
raise "must not happen: #{@mode}"
|
51
48
|
end
|
52
|
-
end
|
53
49
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
50
|
+
def exec(argv, options)
|
51
|
+
prefix = options[:prefix]
|
52
|
+
db = MethodDatabase.new(prefix)
|
53
|
+
case @mode
|
54
|
+
when :list
|
55
|
+
db.properties.each do |key, val|
|
56
|
+
puts "#{key}=#{val}"
|
57
|
+
end
|
58
|
+
when :get
|
59
|
+
argv.each do |key|
|
60
|
+
puts db.propget(key)
|
61
|
+
end
|
62
|
+
when :set
|
63
|
+
key, val = *argv
|
64
|
+
db.transaction {
|
65
|
+
db.propset key, val
|
66
|
+
}
|
67
|
+
else
|
68
|
+
raise "must not happen: #{@mode}"
|
63
69
|
end
|
64
|
-
when :set
|
65
|
-
key, val = *argv
|
66
|
-
db.transaction {
|
67
|
-
db.propset key, val
|
68
|
-
}
|
69
|
-
else
|
70
|
-
raise "must not happen: #{@mode}"
|
71
70
|
end
|
72
71
|
end
|
73
72
|
end
|
@@ -8,26 +8,20 @@ require 'yaml'
|
|
8
8
|
require 'bitclust'
|
9
9
|
require 'bitclust/subcommand'
|
10
10
|
|
11
|
-
module BitClust
|
12
|
-
|
11
|
+
module BitClust
|
12
|
+
module Subcommands
|
13
|
+
class QueryCommand < Subcommand
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
puts opt.help
|
19
|
-
exit 0
|
20
|
-
}
|
21
|
-
}
|
22
|
-
end
|
23
|
-
|
24
|
-
def parse(argv)
|
25
|
-
end
|
15
|
+
def initialize
|
16
|
+
super
|
17
|
+
@parser.banner = "Usage: #{File.basename($0, '.*')} query <ruby-script>"
|
18
|
+
end
|
26
19
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
20
|
+
def exec(argv, options)
|
21
|
+
argv.each do |query|
|
22
|
+
# pp eval(query) # FIXME: causes ArgumentError
|
23
|
+
p eval(query)
|
24
|
+
end
|
31
25
|
end
|
32
26
|
end
|
33
27
|
end
|
@@ -10,208 +10,206 @@ require 'uri'
|
|
10
10
|
require 'bitclust'
|
11
11
|
require 'bitclust/subcommand'
|
12
12
|
|
13
|
-
module BitClust
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
module BitClust
|
14
|
+
module Subcommands
|
15
|
+
class ServerCommand < Subcommand
|
16
|
+
def initialize
|
17
|
+
super
|
18
|
+
require 'webrick'
|
19
|
+
require 'uri'
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
21
|
+
@params = {
|
22
|
+
:BindAddress => "0.0.0.0",
|
23
|
+
:Port => 10080
|
24
|
+
}
|
25
|
+
@baseurl = nil
|
26
|
+
@dbpath = nil
|
27
|
+
@srcdir = @datadir = @themedir = @theme = @templatedir = nil
|
28
|
+
@encoding = 'utf-8' # encoding of view
|
29
|
+
if Object.const_defined?(:Encoding)
|
30
|
+
Encoding.default_external = @encoding
|
31
|
+
end
|
30
32
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
@debugp = false
|
34
|
+
@autop = false
|
35
|
+
@browser = nil
|
36
|
+
@pid_file = nil
|
37
|
+
@capi = false
|
36
38
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
}
|
82
|
-
@parser.on('--capi', 'see also FunctionDatabase.') {|path|
|
83
|
-
@capi = true
|
84
|
-
}
|
85
|
-
end
|
39
|
+
@parser.banner = "#{$0} [--bind-address=ADDR] [--port=NUM] --baseurl=URL --database=PATH [--srcdir=PATH] [--datadir=PATH] [--themedir=PATH] [--debug] [--auto] [--browser=BROWSER] [--pid-file=PATH] [--capi]"
|
40
|
+
@parser.on('--bind-address=ADDR', 'Bind address') {|addr|
|
41
|
+
@params[:BindAddress] = addr
|
42
|
+
}
|
43
|
+
@parser.on('--port=NUM', 'Listening port number') {|num|
|
44
|
+
@params[:Port] = num.to_i
|
45
|
+
}
|
46
|
+
@parser.on('--baseurl=URL', 'The base URL to host.') {|url|
|
47
|
+
@baseurl = url
|
48
|
+
}
|
49
|
+
@parser.on('--database=PATH', 'MethodDatabase root directory.') {|path|
|
50
|
+
@dbpath = path
|
51
|
+
}
|
52
|
+
@parser.on('--srcdir=PATH', 'BitClust source directory.') {|path|
|
53
|
+
set_srcdir(path)
|
54
|
+
}
|
55
|
+
@parser.on('--datadir=PATH', 'BitClust data directory.') {|path|
|
56
|
+
@datadir = path
|
57
|
+
}
|
58
|
+
@parser.on('--templatedir=PATH', 'Template directory.') {|path|
|
59
|
+
@templatedir = path
|
60
|
+
}
|
61
|
+
@parser.on('--themedir=PATH', 'BitClust theme directory.') {|path|
|
62
|
+
@themedir = path
|
63
|
+
}
|
64
|
+
@parser.on('--theme=THEME', 'BitClust theme.') {|th|
|
65
|
+
@theme = th
|
66
|
+
}
|
67
|
+
@parser.on('--[no-]debug', 'Debug mode.') {|flag|
|
68
|
+
@debugp = flag
|
69
|
+
}
|
70
|
+
@parser.on('--[no-]auto', 'Auto mode.') {|flag|
|
71
|
+
@autop = flag
|
72
|
+
}
|
73
|
+
@parser.on('--browser=BROWSER', 'Open with the browser.') {|path|
|
74
|
+
@browser = path
|
75
|
+
}
|
76
|
+
@parser.on('--pid-file=PATH', 'Write pid of the daemon to the specified file.') {|path|
|
77
|
+
@pid_file = path
|
78
|
+
}
|
79
|
+
@parser.on('--capi', 'see also FunctionDatabase.') {|path|
|
80
|
+
@capi = true
|
81
|
+
}
|
82
|
+
end
|
86
83
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
84
|
+
def parse(argv)
|
85
|
+
super
|
86
|
+
load_config_file
|
87
|
+
set_srcdir(srcdir_root) unless @srcdir
|
91
88
|
|
92
|
-
|
93
|
-
|
94
|
-
exit 1
|
95
|
-
end
|
96
|
-
unless @dbpath || @autop
|
97
|
-
$stderr.puts "missing database path. Use --database"
|
98
|
-
exit 1
|
99
|
-
end
|
100
|
-
unless @datadir
|
101
|
-
$stderr.puts "missing datadir. Use --datadir"
|
102
|
-
exit 1
|
103
|
-
end
|
104
|
-
unless @themedir
|
105
|
-
$stderr.puts "missing themedir. Use --themedir"
|
106
|
-
exit 1
|
107
|
-
end
|
108
|
-
if @pid_file
|
109
|
-
if File.exist?(@pid_file)
|
110
|
-
$stderr.puts "There is still #{@pid_file}. Is another process running?"
|
89
|
+
unless @baseurl
|
90
|
+
$stderr.puts "missing base URL. Use --baseurl or check ~/.bitclust/config"
|
111
91
|
exit 1
|
112
92
|
end
|
113
|
-
@
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
@
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
93
|
+
unless @dbpath || @autop
|
94
|
+
$stderr.puts "missing database path. Use --database"
|
95
|
+
exit 1
|
96
|
+
end
|
97
|
+
unless @datadir
|
98
|
+
$stderr.puts "missing datadir. Use --datadir"
|
99
|
+
exit 1
|
100
|
+
end
|
101
|
+
unless @themedir
|
102
|
+
$stderr.puts "missing themedir. Use --themedir"
|
103
|
+
exit 1
|
104
|
+
end
|
105
|
+
if @pid_file
|
106
|
+
if File.exist?(@pid_file)
|
107
|
+
$stderr.puts "There is still #{@pid_file}. Is another process running?"
|
108
|
+
exit 1
|
109
|
+
end
|
110
|
+
@pid_file = File.expand_path(@pid_file)
|
111
|
+
end
|
129
112
|
end
|
130
|
-
basepath = URI.parse(@baseurl).path
|
131
|
-
server = WEBrick::HTTPServer.new(@params)
|
132
113
|
|
133
|
-
|
134
|
-
app
|
135
|
-
|
136
|
-
:
|
137
|
-
:
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
114
|
+
def exec(argv, options)
|
115
|
+
require 'bitclust/app'
|
116
|
+
if @debugp
|
117
|
+
@params[:Logger] = WEBrick::Log.new($stderr, WEBrick::Log::DEBUG)
|
118
|
+
@params[:AccessLog] = [
|
119
|
+
[ $stderr, WEBrick::AccessLog::COMMON_LOG_FORMAT ],
|
120
|
+
[ $stderr, WEBrick::AccessLog::REFERER_LOG_FORMAT ],
|
121
|
+
[ $stderr, WEBrick::AccessLog::AGENT_LOG_FORMAT ],
|
122
|
+
]
|
123
|
+
else
|
124
|
+
@params[:Logger] = WEBrick::Log.new($stderr, WEBrick::Log::INFO)
|
125
|
+
@params[:AccessLog] = []
|
145
126
|
end
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
127
|
+
basepath = URI.parse(@baseurl).path
|
128
|
+
server = WEBrick::HTTPServer.new(@params)
|
129
|
+
|
130
|
+
if @autop
|
131
|
+
app = App.new(
|
132
|
+
:dbpath => Dir.glob("#{@database_prefix}-*"),
|
133
|
+
:baseurl => @baseurl,
|
134
|
+
:datadir => @datadir,
|
135
|
+
:templatedir => @templatedir,
|
136
|
+
:theme => @theme,
|
137
|
+
:encoding => @encoding,
|
138
|
+
:capi => @capi
|
139
|
+
)
|
140
|
+
app.interfaces.each do |version, interface|
|
141
|
+
server.mount(File.join(basepath, version), interface)
|
142
|
+
end
|
143
|
+
server.mount(File.join(basepath, '/'), app)
|
144
|
+
else
|
145
|
+
viewpath = File.join(basepath, 'view')
|
146
|
+
app = App.new(
|
147
|
+
:viewpath => viewpath,
|
148
|
+
:dbpath => @dbpath,
|
149
|
+
:baseurl => @baseurl,
|
150
|
+
:datadir => @datadir,
|
151
|
+
:templatedir => @templatedir,
|
152
|
+
:theme => @theme,
|
153
|
+
:encoding => @encoding,
|
154
|
+
:capi => @capi
|
155
|
+
)
|
156
|
+
app.interfaces.each do |viewpath, interface|
|
157
|
+
server.mount viewpath, interface
|
158
|
+
end
|
159
|
+
# Redirect from '/' to "#{viewpath}/"
|
160
|
+
server.mount('/', app)
|
161
161
|
end
|
162
|
-
# Redirect from '/' to "#{viewpath}/"
|
163
|
-
server.mount('/', app)
|
164
|
-
end
|
165
162
|
|
166
|
-
|
163
|
+
server.mount File.join(basepath, 'theme/'), WEBrick::HTTPServlet::FileHandler, @themedir
|
167
164
|
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
165
|
+
if @debugp
|
166
|
+
trap(:INT) { server.shutdown }
|
167
|
+
else
|
168
|
+
WEBrick::Daemon.start do
|
169
|
+
trap(:TERM) {
|
170
|
+
server.shutdown
|
171
|
+
begin
|
172
|
+
File.unlink @pid_file if @pid_file
|
173
|
+
rescue Errno::ENOENT
|
174
|
+
end
|
175
|
+
}
|
176
|
+
File.open(@pid_file, 'w') {|f| f.write Process.pid } if @pid_file
|
177
|
+
end
|
180
178
|
end
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
179
|
+
exit if $".include?("exerb/mkexy.rb")
|
180
|
+
if @autop && !@browser
|
181
|
+
case RUBY_PLATFORM
|
182
|
+
when /mswin/
|
183
|
+
@browser = "start"
|
184
|
+
end
|
187
185
|
end
|
186
|
+
system("#{@browser} http://localhost:#{@params[:Port]}/") if @browser
|
187
|
+
server.start
|
188
188
|
end
|
189
|
-
system("#{@browser} http://localhost:#{@params[:Port]}/") if @browser
|
190
|
-
server.start
|
191
|
-
end
|
192
189
|
|
193
|
-
|
190
|
+
private
|
194
191
|
|
195
|
-
|
196
|
-
|
197
|
-
|
192
|
+
def srcdir_root
|
193
|
+
Pathname.new(__FILE__).realpath.dirname.parent.parent.parent.cleanpath
|
194
|
+
end
|
198
195
|
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
196
|
+
def set_srcdir(dir)
|
197
|
+
@srcdir ||= dir
|
198
|
+
@datadir ||= "#{@srcdir}/data/bitclust"
|
199
|
+
@themedir ||= "#{@srcdir}/theme"
|
200
|
+
end
|
204
201
|
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
202
|
+
def load_config_file
|
203
|
+
home_directory = Pathname(ENV['HOME'])
|
204
|
+
config_path = home_directory + ".bitclust/config"
|
205
|
+
if config_path.exist?
|
206
|
+
config = YAML.load_file(config_path)
|
207
|
+
@baseurl ||= config[:baseurl]
|
208
|
+
@dbpath ||= "#{config[:database_prefix]}-#{config[:default_version]}"
|
209
|
+
@port ||= config[:port]
|
210
|
+
@pid_file ||= config[:pid_file]
|
211
|
+
@database_prefix ||= config[:database_prefix]
|
212
|
+
end
|
215
213
|
end
|
216
214
|
end
|
217
215
|
end
|