bitclust-core 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/README +16 -5
  3. data/data/bitclust/template.lillia/layout +1 -1
  4. data/data/bitclust/template.offline/layout +1 -1
  5. data/data/bitclust/template/layout +1 -1
  6. data/lib/bitclust/app.rb +5 -1
  7. data/lib/bitclust/classentry.rb +1 -1
  8. data/lib/bitclust/compat.rb +4 -0
  9. data/lib/bitclust/completion.rb +5 -0
  10. data/lib/bitclust/crossrubyutils.rb +2 -0
  11. data/lib/bitclust/database.rb +4 -0
  12. data/lib/bitclust/docentry.rb +1 -0
  13. data/lib/bitclust/entry.rb +8 -0
  14. data/lib/bitclust/functiondatabase.rb +1 -0
  15. data/lib/bitclust/functionreferenceparser.rb +6 -0
  16. data/lib/bitclust/htmlutils.rb +1 -0
  17. data/lib/bitclust/interface.rb +1 -0
  18. data/lib/bitclust/libraryentry.rb +1 -0
  19. data/lib/bitclust/lineinput.rb +1 -0
  20. data/lib/bitclust/messagecatalog.rb +4 -0
  21. data/lib/bitclust/methoddatabase.rb +3 -0
  22. data/lib/bitclust/methodentry.rb +2 -1
  23. data/lib/bitclust/methodid.rb +3 -0
  24. data/lib/bitclust/methodsignature.rb +2 -0
  25. data/lib/bitclust/nameutils.rb +1 -0
  26. data/lib/bitclust/parseutils.rb +5 -0
  27. data/lib/bitclust/preprocessor.rb +3 -0
  28. data/lib/bitclust/rdcompiler.rb +1 -0
  29. data/lib/bitclust/refsdatabase.rb +2 -0
  30. data/lib/bitclust/requesthandler.rb +3 -2
  31. data/lib/bitclust/ridatabase.rb +2 -0
  32. data/lib/bitclust/rrdparser.rb +1 -0
  33. data/lib/bitclust/runner.rb +1 -4
  34. data/lib/bitclust/searcher.rb +16 -0
  35. data/lib/bitclust/server.rb +1 -0
  36. data/lib/bitclust/silent_progress_bar.rb +1 -0
  37. data/lib/bitclust/simplesearcher.rb +2 -0
  38. data/lib/bitclust/subcommand.rb +2 -0
  39. data/lib/bitclust/subcommands/server_command.rb +1 -1
  40. data/lib/bitclust/subcommands/setup_command.rb +33 -3
  41. data/lib/bitclust/textutils.rb +1 -0
  42. data/lib/bitclust/version.rb +1 -1
  43. data/test/test_functiondatabase.rb +55 -55
  44. data/test/test_runner.rb +4 -2
  45. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 16a76bb3555a76e8172df8e518012cf5c441bf15
4
- data.tar.gz: 98b008bd6df5d144bbb98bfe1cae8757bfe1dffb
3
+ metadata.gz: 20aa499245063832cb75dcfdbc4cb68556b2aac2
4
+ data.tar.gz: 3fe3945f3f873d42c2d292a7b0592dffe4aabf45
5
5
  SHA512:
6
- metadata.gz: 712c1e7a269282a99cf27af4176d40b9e0337d5533d27aaea190648c0df49232d6114374fa74e3b693f0b8dd000dba5b7360cec8c6885fcb1079cbb139235b8e
7
- data.tar.gz: f8e50965325085b78e6b2dc4230d61c597d0d646699984e96adeedccdf322d7cab6cf00bf5dc3bf7f3eb2c45017b9397d9d9bbd3d71056513781f7727b12414c
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
- Maintainer
18
- ----------
19
-
20
- Minero Aoki <aamine@loveruby.net>
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.
@@ -1,4 +1,4 @@
1
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
1
+ <!DOCTYPE html>
2
2
  <html lang="ja-JP">
3
3
  <head>
4
4
  <meta http-equiv="Content-Type" content="text/html; charset=<%=h charset() %>">
@@ -1,4 +1,4 @@
1
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
1
+ <!DOCTYPE html>
2
2
  <html lang="ja-JP">
3
3
  <head>
4
4
  <meta http-equiv="Content-Type" content="text/html; charset=<%=h charset() %>">
@@ -1,4 +1,4 @@
1
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
1
+ <!DOCTYPE html>
2
2
  <html lang="ja-JP">
3
3
  <head>
4
4
  <meta http-equiv="Content-Type" content="text/html; charset=<%=h charset() %>">
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
@@ -12,7 +12,7 @@ require 'bitclust/exception'
12
12
 
13
13
  module BitClust
14
14
 
15
- # Represents a class, a module and a singleton object.
15
+ # Represents a class, a module or a singleton object (like ARGF, main, etc.).
16
16
  class ClassEntry < Entry
17
17
 
18
18
  include Enumerable
@@ -1,3 +1,7 @@
1
+ #
2
+ # Compatibility for older rubies
3
+ #
4
+
1
5
  unless Object.method_defined?(:__send)
2
6
  class Object
3
7
  alias __send __send__
@@ -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
@@ -6,6 +6,8 @@
6
6
 
7
7
  module BitClust
8
8
 
9
+ # Provides utility methods like print_crossruby_table.
10
+ # Used by subcommands "ancestors" "classes" etc.
9
11
  module CrossRubyUtils
10
12
 
11
13
  private
@@ -12,6 +12,10 @@ require 'bitclust/exception'
12
12
 
13
13
  module BitClust
14
14
 
15
+ # Abstract class for BitClust DB.
16
+ # Each entry is written in a file.
17
+ #
18
+ # Has subclass MethodDatabase (Ruby stuff) and FunctionDatabase (C stuff).
15
19
  class Database
16
20
 
17
21
  include NameUtils
@@ -12,6 +12,7 @@ require 'bitclust/exception'
12
12
 
13
13
  module BitClust
14
14
 
15
+ # Entry for general documents (doc/**/*.rd, etc.)
15
16
  class DocEntry < Entry
16
17
 
17
18
  def self.type_id
@@ -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
@@ -15,6 +15,7 @@ require 'bitclust/exception'
15
15
 
16
16
  module BitClust
17
17
 
18
+ # Database for C API functions.
18
19
  class FunctionDatabase < Database
19
20
 
20
21
  include Completion
@@ -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
@@ -11,6 +11,7 @@ require 'bitclust/nameutils'
11
11
 
12
12
  module BitClust
13
13
 
14
+ # Utility functions for HTML tag generation
14
15
  module HTMLUtils
15
16
 
16
17
  include NameUtils
@@ -16,6 +16,7 @@ end
16
16
 
17
17
  module BitClust
18
18
 
19
+ # Web server interface for BitClust server
19
20
  class Interface
20
21
 
21
22
  def initialize(webrick_conf = {})
@@ -12,6 +12,7 @@ require 'bitclust/exception'
12
12
 
13
13
  module BitClust
14
14
 
15
+ # Entry for libraries ("_builtin", "yaml", etc.)
15
16
  class LibraryEntry < Entry
16
17
 
17
18
  include Enumerable
@@ -10,6 +10,7 @@
10
10
 
11
11
  require 'stringio'
12
12
 
13
+ # Utility class for line-wise file parsing
13
14
  class LineInput
14
15
 
15
16
  def LineInput.for_string(s)
@@ -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
@@ -12,7 +12,8 @@ require 'bitclust/exception'
12
12
 
13
13
  module BitClust
14
14
 
15
- # Represents a method, a constant, and a special variable.
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
@@ -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
@@ -12,6 +12,8 @@ require 'bitclust/exception'
12
12
 
13
13
  module BitClust
14
14
 
15
+ # Represents detailed signature of a method in a class/module.
16
+ # Includes parameters, block specification and return type.
15
17
  class MethodSignature
16
18
 
17
19
  include NameUtils
@@ -11,6 +11,7 @@ require 'bitclust/compat'
11
11
 
12
12
  module BitClust
13
13
 
14
+ # Utilities for conversion among names, ids and URL fragments.
14
15
  module NameUtils
15
16
 
16
17
  module_function
@@ -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)
@@ -15,6 +15,7 @@ require 'stringio'
15
15
 
16
16
  module BitClust
17
17
 
18
+ # Compiles doc into HTML.
18
19
  class RDCompiler
19
20
 
20
21
  include HTMLUtils
@@ -6,6 +6,8 @@
6
6
  #
7
7
 
8
8
  module BitClust
9
+
10
+ # Corresponds to db-x.y.z/refs file.
9
11
  class RefsDatabase
10
12
  def self.load(src)
11
13
  if src.respond_to?(:to_str)
@@ -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
 
@@ -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)
@@ -18,6 +18,7 @@ require 'bitclust/methoddatabase'
18
18
 
19
19
  module BitClust
20
20
 
21
+ # Parser for Ruby API reference file (refm/api/src/*)
21
22
  class RRDParser
22
23
 
23
24
  include NameUtils
@@ -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
@@ -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}'"
@@ -18,6 +18,7 @@ require 'webrick/server'
18
18
 
19
19
  module BitClust
20
20
 
21
+ # Body of Refe server (spanwed by `refe --server`).
21
22
  class Server
22
23
 
23
24
  def initialize(db)
@@ -1,5 +1,6 @@
1
1
 
2
2
  module BitClust
3
+ # Null-object version of ProgressBar.
3
4
  class SilentProgressBar
4
5
 
5
6
  attr_reader :title
@@ -2,6 +2,8 @@ require 'bitclust/nameutils'
2
2
  require 'bitclust/methodid'
3
3
 
4
4
  module BitClust
5
+ # Tiny search engine for BitClust server.
6
+ # Note: loads all the entries onto memory, so first search will be slow.
5
7
  module SimpleSearcher
6
8
  include NameUtils
7
9
 
@@ -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', 'Listening port number') {|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 = "http://jp.rubyist.net/svn/rurema/doctree/trunk"
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
- unless system("svn", "co", REPOSITORY_PATH, rubydoc_dir.to_s)
93
- warn "svn command failed. Please install Subversion or check your PATH."
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
@@ -9,6 +9,7 @@
9
9
 
10
10
  module BitClust
11
11
 
12
+ # Utility for tweaking text.
12
13
  module TextUtils
13
14
 
14
15
  module_function
@@ -1,3 +1,3 @@
1
1
  module BitClust
2
- VERSION = "0.7.0"
2
+ VERSION = "0.8.0"
3
3
  end
@@ -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(nil, []).returns(nil)
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(nil, []).returns(nil)
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.7.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-05-12 00:00:00.000000000 Z
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.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.