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 = ["2.4.0", "2.5.0", "2.6.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



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/bitclust/subcommands/setup_command.rb', line 43

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]}"]
    init_options = { :prefix => prefix }
    InitCommand.new.exec(init_argv, init_options)
    update_method_database(prefix, ["--stdlibtree=#{@config[:stdlibtree]}"])
    update_argv = Pathname(@config[:capi_src]).children.select(&:file?).map{|v| v.realpath.to_s }
    update_function_database(prefix, update_argv)
  end
end