summaryrefslogtreecommitdiff
path: root/lib/oxidized/source/csv.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/oxidized/source/csv.rb')
-rw-r--r--lib/oxidized/source/csv.rb13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/oxidized/source/csv.rb b/lib/oxidized/source/csv.rb
index 449b297..c508358 100644
--- a/lib/oxidized/source/csv.rb
+++ b/lib/oxidized/source/csv.rb
@@ -10,21 +10,22 @@ class CSV < Source
Oxidized.asetus.user.source.csv.file = File.join(Config::Root, 'router.db')
Oxidized.asetus.user.source.csv.delimiter = /:/
Oxidized.asetus.user.source.csv.map.name = 0
- Oxidized.asetus.user.source.csv.map.model = 1
Oxidized.asetus.user.source.csv.gpg = false
Oxidized.asetus.save :user
raise NoConfig, 'no source csv config, edit ~/.config/oxidized/config'
end
+ require 'gpgme' if @cfg.gpg?
end
def load
nodes = []
- if @cfg.gpg != 'false'
- crypto = GPGME::Crypto.new :password => @cfg.gpg_password
- file = crypto.decrypt(File.open(@cfg.file)).to_s
+ file = File.expand_path(@cfg.file)
+ file = if @cfg.gpg?
+ crypto = GPGME::Crypto.new password: @cfg.gpg_password
+ crypto.decrypt(file).to_s
else
- file = open(File.expand_path @cfg.file)
- end
+ open(file)
+ end
file.each_line do |line|
next if line.match(/^\s*#/)
data = line.chomp.split(@cfg.delimiter, -1)