Class: BitClust::Subcommands::SetupCommand

Inherits:
BitClust::Subcommand show all
Defined in:
lib/bitclust/subcommands/setup_command.rb

Constant Summary collapse

REPOSITORY_PATH =
"https://github.com/rurema/doctree.git"

Instance Method Summary collapse

Methods inherited from BitClust::Subcommand

#align_progress_bar_title, #error, #help, #option_error, #parse, #srcdir_root

Constructor Details

#initializeSetupCommand

Returns a new instance of SetupCommand.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/bitclust/subcommands/setup_command.rb', line 18

def initialize
  super
  @prepare = nil
  @cleanup = nil
  @purge = nil
  @versions = ["3.3.0", "3.4.0", "4.0.0"]
  @update = true
  @parser.banner = "Usage: #{File.basename($0, '.*')} setup [options]"
  @parser.on('--prepare', 'Prepare config file and checkout repository. Do not create database.') {
    @prepare = true
  }
  @parser.on('--cleanup', 'Cleanup database before create database.') {
    @cleanup = true
  }
  @parser.on('--purge', 'Purge all downloaded and generated files and exit.') {
    @purge = true
  }
  @parser.on('--versions=V1,V2,...', "Specify versions. [#{@versions.join(',')}]") {|versions|
    @versions = versions.split(",")
  }
  @parser.on('--no-update', 'Do not update document repository') {
    @update = false
  }
end

Instance Method Details

#exec(argv, options) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/bitclust/subcommands/setup_command.rb', line 48

def exec(argv, options)
  purge if @purge
  prepare
  return if @prepare
  @config[:versions].each do |version|
    puts "Generating database for Ruby#{version}..."
    prefix = "#{@config[:database_prefix]}-#{version}"
    FileUtils.rm_rf(prefix) if @cleanup
    init_argv = ["version=#{version}", "encoding=#{@config[:encoding]}"]
    # @type var init_options: Subcommand::options
    init_options = { :prefix => prefix, :capi => false }
    InitCommand.new.exec(init_argv, init_options)
    update_method_database(prefix, ["--markdowntree=#{@config[:mdtree]}"])
    update_function_database(prefix, ["--markdowntree=#{@config[:capi_mdtree]}"])
  end
end

#needs_database?Boolean

DB は ~/.bitclust 配下に自前で作るのでグローバル --database は不要

Returns:

  • (Boolean)


44
45
46
# File 'lib/bitclust/subcommands/setup_command.rb', line 44

def needs_database?
  false
end