From 62a990bc08c23684840d34eccd46c54197cb7d02 Mon Sep 17 00:00:00 2001 From: mbakerbp Date: Tue, 24 Jan 2017 07:44:23 +0800 Subject: GPG support --- lib/oxidized/source/csv.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lib/oxidized/source') diff --git a/lib/oxidized/source/csv.rb b/lib/oxidized/source/csv.rb index dc246ab..85fee77 100644 --- a/lib/oxidized/source/csv.rb +++ b/lib/oxidized/source/csv.rb @@ -19,9 +19,13 @@ class CSV < Source def load nodes = [] - crypto = GPGME::Crypto.new - file = (@cfg.gpg == 'false') ? open(File.expand_path @cfg.file) : crypto.decrypt(File.open(@cfg.file)) - open(file).each_line do |line| + if @cfg.gpg != 'false' + crypto = GPGME::Crypto.new :password => @cfg.gpg_password + file = crypto.decrypt(File.open(@cfg.file)) + else + file = open(File.expand_path @cfg.file) + end + file.each_line do |line| next if line.match(/^\s*#/) data = line.chomp.split(@cfg.delimiter, -1) next if data.empty? -- cgit v1.2.1