-
Notifications
You must be signed in to change notification settings - Fork 936
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve conflicts while loading http classes (input, output, source)
- manager.rb: specify in which namespace a file must be loaded - Adds a namespace Oxidized::Output for outputs - More unit tests to test the changes to manager.rb - Renamed Oxidized::OxidizedFile to Oxidized::Output::File. To access ruby's File object within the Oxidized::Output::File object, you need ::File within the Oxidized::Output::File object. Other modifications: - output/http.rb can not have worked, as it used a not initialized constant CFGS. Fixed this. Not modified: - No Namespace Oxidized::Input was created for inputs. Maybe this should be also done some day, but input/cli.rb seemed to be too complicated for this commit.
- Loading branch information
1 parent
73c8861
commit b3f3f95
Showing
10 changed files
with
569 additions
and
491 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,58 @@ | ||
module Oxidized | ||
class OxidizedFile < Output | ||
require 'fileutils' | ||
module Output | ||
# ruby's File class must be accessed with ::File to avoid name conflicts | ||
class File < Output | ||
require 'fileutils' | ||
|
||
attr_reader :commitref | ||
attr_reader :commitref | ||
|
||
def initialize | ||
super | ||
@cfg = Oxidized.config.output.file | ||
end | ||
def initialize | ||
super | ||
@cfg = Oxidized.config.output.file | ||
end | ||
|
||
def setup | ||
return unless @cfg.empty? | ||
def setup | ||
return unless @cfg.empty? | ||
|
||
Oxidized.asetus.user.output.file.directory = File.join(Config::ROOT, 'configs') | ||
Oxidized.asetus.save :user | ||
raise NoConfig, "no output file config, edit #{Oxidized::Config.configfile}" | ||
end | ||
Oxidized.asetus.user.output.file.directory = ::File.join(Config::ROOT, 'configs') | ||
Oxidized.asetus.save :user | ||
raise NoConfig, "no output file config, edit #{Oxidized::Config.configfile}" | ||
end | ||
|
||
def store(node, outputs, opt = {}) | ||
file = File.expand_path @cfg.directory | ||
file = File.join File.dirname(file), opt[:group] if opt[:group] | ||
FileUtils.mkdir_p file | ||
file = File.join file, node | ||
File.write(file, outputs.to_cfg) | ||
@commitref = file | ||
end | ||
def store(node, outputs, opt = {}) | ||
file = ::File.expand_path @cfg.directory | ||
file = ::File.join ::File.dirname(file), opt[:group] if opt[:group] | ||
FileUtils.mkdir_p file | ||
file = ::File.join file, node | ||
::File.write(file, outputs.to_cfg) | ||
@commitref = file | ||
end | ||
|
||
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) | ||
elsif File.exist? 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 | ||
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) | ||
elsif ::File.exist? ::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 | ||
rescue Errno::ENOENT | ||
nil | ||
end | ||
rescue Errno::ENOENT | ||
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 |
Oops, something went wrong.