Method: PEROBS::FlatFileDB#initialize

Defined in:
lib/perobs/FlatFileDB.rb

#initialize(db_name, options = {}) ⇒ FlatFileDB

Create a new FlatFileDB object.

Parameters:

  • db_name (String)

    name of the DB directory

  • options (Hash) (defaults to: {})

    options to customize the behavior. Currently only the following options are supported: :serializer : Can be :marshal, :json, :yaml :progressmeter : Reference to a ProgressMeter object :log : IO that should be used for logging :log_level : Minimum Logger level to log



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/perobs/FlatFileDB.rb', line 57

def initialize(db_name, options = {})
  super(options)

  @db_dir = db_name
  # Create the database directory if it doesn't exist yet.
  ensure_dir_exists(@db_dir)
  PEROBS.log.level = options[:log_level] if options[:log_level]
  PEROBS.log.open(options[:log] || File.join(@db_dir, 'log'))
  check_version_and_upgrade

  # Read the existing DB config.
  @config = get_hash('config')
  check_option('serializer')

  put_hash('config', @config)
end