class RRSE::Command::UpdateDB
require “rdoc/ri/driver”
Public Class Methods
new(dir)
click to toggle source
# File lib/rrse/update-db-command.rb, line 12 def initialize(dir) @dir = dir @table = {} @index_table = {} end
short_description()
click to toggle source
# File lib/rrse/update-db-command.rb, line 8 def self.short_description "update database" end
Public Instance Methods
merge_tables(table, index_table)
click to toggle source
# File lib/rrse/update-db-command.rb, line 46 def merge_tables(table, index_table) @table.merge!(table) @index_table.merge!(index_table) end
options()
click to toggle source
# File lib/rrse/update-db-command.rb, line 18 def options opts = OptionParser.new opts.banner = "Usage: rrse [global-options] update-db" opts end
read_bitclust_config(path)
click to toggle source
# File lib/rrse/update-db-command.rb, line 42 def read_bitclust_config(path) YAML.load_file(File.expand_path(path)) end
run(argv)
click to toggle source
# File lib/rrse/update-db-command.rb, line 24 def run(argv) options.order!(argv) config = RRSE.load_config(@dir) config["sources"].each do |source| case source["type"] when "bitclust" merge_tables(*BitClustAdaptor.new( read_bitclust_config(source["config"]), source["version"], source["dbpath"] ).generate_tables) when "ri" raise "ri does not support" end end save_table(@table, @dir.join("table")) save_table(@index_table, @dir.join("index_table")) end
save_table(table, path)
click to toggle source
# File lib/rrse/update-db-command.rb, line 51 def save_table(table, path) File.open(path, "w"){|f| MessagePack.dump(table, f)} end