module Trunk class KDBX include Enumerable def initialize(file, password:) require 'kdbx' require 'rexml/document' @file = Kdbx.open(file, password: password) @document = REXML::Document.new(@file.content) end def each REXML::XPath.each(@document, "//Entry") do |element| yield( REXML::XPath.each(element, "./String").inject({}) do |memo, x| key = REXML::XPath.first(x, "./Key").text memo[key.downcase.to_sym] = REXML::XPath.first(x, "./Value").text memo end ) end end private def xml @file.content end end end