summaryrefslogtreecommitdiff
path: root/lib/oxidized
diff options
context:
space:
mode:
authormbakerbp <michael.baker@bulletproof.net>2017-01-24 06:47:57 +0800
committermbakerbp <michael.baker@bulletproof.net>2017-01-24 06:47:57 +0800
commite4680d181c368d901e27023c1f7ab524007d5b64 (patch)
tree8576ceb238b18bec4e98571b295a06210f3b1f2e /lib/oxidized
parent8375aa0ad364e4cb274ba96be1ddfb312c148e38 (diff)
Untested GPG work
Diffstat (limited to 'lib/oxidized')
-rw-r--r--lib/oxidized/manager.rb1
-rw-r--r--lib/oxidized/source/csv.rb4
2 files changed, 4 insertions, 1 deletions
diff --git a/lib/oxidized/manager.rb b/lib/oxidized/manager.rb
index bf28ae7..60394fd 100644
--- a/lib/oxidized/manager.rb
+++ b/lib/oxidized/manager.rb
@@ -3,6 +3,7 @@ module Oxidized
require 'oxidized/input/input'
require 'oxidized/output/output'
require 'oxidized/source/source'
+ require 'gpgme'
class Manager
class << self
def load dir, file
diff --git a/lib/oxidized/source/csv.rb b/lib/oxidized/source/csv.rb
index d498e0b..c41162d 100644
--- a/lib/oxidized/source/csv.rb
+++ b/lib/oxidized/source/csv.rb
@@ -11,6 +11,7 @@ class CSV < Source
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
@@ -18,7 +19,8 @@ class CSV < Source
def load
nodes = []
- open(File.expand_path @cfg.file).each_line do |line|
+ file = @cfg.gpg == 'false' ? open(File.expand_path @cfg.file) : crypto.decrypt File.open(@cfg.file)
+ open(file).each_line do |line|
next if line.match(/^\s*#/)
data = line.chomp.split(@cfg.delimiter, -1)
next if data.empty?