Sha256: 36ffe52edc8461a933c90fd77d21e3504cbb6d8f0c2a16709f18295eeb57c14f

Contents?: true

Size: 949 Bytes

Versions: 1

Compression:

Stored size: 949 Bytes

Contents

# frozen_string_literal: true

module Hotwired
  require "strada"
  require "fileutils"

  class Config
    ROOT  = File.join ENV["HOME"], ".config", "hotwired"
    CRASH = File.join ROOT, "crash"
  end

  FileUtils.mkdir_p Config::ROOT
  CONFIG = Strada.new name: "hotwired", load: "false", key_to_s: true

  CONFIG.default.community = "cisco"
  CONFIG.default.db        = File.join Config::ROOT, "hotwired.db"
  CONFIG.default.poll      = %w( 192.168.8.0/24 )
  CONFIG.default.ignore    = %w( 192.168.8.100 )
  CONFIG.default.mgmt      = %w( lo0.0 loopback0 vlan2 )
  CONFIG.default.threads   = 50
  CONFIG.default.timeout   = 0.25
  CONFIG.default.retries   = 2
  CONFIG.default.log       = File.join Config::ROOT, "log"
  CONFIG.default.debug     = true

  # 加载初始化配置
  CONFIG.load
  CFG       = CONFIG.cfg

  # 初始化项目日志参数
  Log.file  = CFG.log if CFG.log
  Log.level = CFG.debug ? Logger::INFO : Logger::DEBUG
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hotwired-0.0.1 lib/hotwired/config.rb