summaryrefslogtreecommitdiff
path: root/lib/oxidized/output/file.rb
diff options
context:
space:
mode:
authorRon <rgnv@users.noreply.github.com>2018-04-27 06:24:56 -0700
committerGitHub <noreply@github.com>2018-04-27 06:24:56 -0700
commit2bb40ad4d9e31cf2cd63a373f7c607eb86547e46 (patch)
treec12b52f0acd5192c457fa07189c4946674cd11fb /lib/oxidized/output/file.rb
parentec90b081f0fed05497ce6ae21e4b4ba4d44ecc01 (diff)
parent83a00943d7333fafdfe352173713a22a5ac89f6f (diff)
Merge pull request #1 from wk/pr-1280
massage into rubocop compliance
Diffstat (limited to 'lib/oxidized/output/file.rb')
-rw-r--r--lib/oxidized/output/file.rb83
1 files changed, 41 insertions, 42 deletions
diff --git a/lib/oxidized/output/file.rb b/lib/oxidized/output/file.rb
index 45f72e1..bad1b6a 100644
--- a/lib/oxidized/output/file.rb
+++ b/lib/oxidized/output/file.rb
@@ -1,59 +1,58 @@
module Oxidized
-class OxidizedFile < Output
- require 'fileutils'
+ class OxidizedFile < Output
+ require 'fileutils'
- attr_reader :commitref
+ attr_reader :commitref
- def initialize
- @cfg = Oxidized.config.output.file
- end
+ def initialize
+ @cfg = Oxidized.config.output.file
+ end
- def setup
- if @cfg.empty?
- Oxidized.asetus.user.output.file.directory = File.join(Config::Root, 'configs')
- Oxidized.asetus.save :user
- raise NoConfig, 'no output file config, edit ~/.config/oxidized/config'
+ def setup
+ if @cfg.empty?
+ Oxidized.asetus.user.output.file.directory = File.join(Config::Root, 'configs')
+ Oxidized.asetus.save :user
+ raise NoConfig, 'no output file config, edit ~/.config/oxidized/config'
+ end
end
- end
- def store node, outputs, opt={}
- file = File.expand_path @cfg.directory
- if opt[:group]
- file = File.join File.dirname(file), opt[:group]
+ def store node, outputs, opt = {}
+ file = File.expand_path @cfg.directory
+ if opt[:group]
+ file = File.join File.dirname(file), opt[:group]
+ end
+ FileUtils.mkdir_p file
+ file = File.join file, node
+ open(file, 'w') { |fh| fh.write outputs.to_cfg }
+ @commitref = file
end
- FileUtils.mkdir_p file
- file = File.join file, node
- open(file, 'w') { |fh| fh.write outputs.to_cfg }
- @commitref = file
- end
- def fetch node, group
- cfg_dir = File.expand_path @cfg.directory
- node_name = node.name
+ def fetch node, group
+ cfg_dir = File.expand_path @cfg.directory
+ node_name = node.name
- if group # group is explicitly defined by user
- cfg_dir = File.join File.dirname(cfg_dir), group
- File.read File.join(cfg_dir, node_name)
- else
- if File.exists? File.join(cfg_dir, node_name) # node configuration file is stored on base directory
+ if group # group is explicitly defined by user
+ cfg_dir = File.join File.dirname(cfg_dir), group
File.read File.join(cfg_dir, node_name)
else
- path = Dir.glob(File.join(File.dirname(cfg_dir), '**', node_name)).first # fetch node in all groups
- File.read path
+ if File.exists? File.join(cfg_dir, node_name) # node configuration file is stored on base directory
+ File.read File.join(cfg_dir, node_name)
+ else
+ path = Dir.glob(File.join(File.dirname(cfg_dir), '**', node_name)).first # fetch node in all groups
+ File.read path
+ end
end
+ rescue Errno::ENOENT
+ return nil
end
- rescue Errno::ENOENT
- return nil
- end
- def version node, group
- # not supported
- []
- end
+ def version node, group
+ # not supported
+ []
+ end
- def get_version node, group, oid
- 'not supported'
+ def get_version node, group, oid
+ 'not supported'
+ end
end
-
-end
end