summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/oxidized/model/model.rb2
-rw-r--r--lib/oxidized/model/outputs.rb4
-rw-r--r--lib/oxidized/output/file.rb4
-rw-r--r--lib/oxidized/output/git.rb3
-rw-r--r--lib/oxidized/string.rb16
5 files changed, 13 insertions, 16 deletions
diff --git a/lib/oxidized/model/model.rb b/lib/oxidized/model/model.rb
index 3dd3f98..7258912 100644
--- a/lib/oxidized/model/model.rb
+++ b/lib/oxidized/model/model.rb
@@ -155,7 +155,7 @@ module Oxidized
if output.class != Oxidized::String
output = Oxidized::String.new output
end
- output.cmd = name
+ output.set_cmd(name)
output
end
diff --git a/lib/oxidized/model/outputs.rb b/lib/oxidized/model/outputs.rb
index 406f886..10015f8 100644
--- a/lib/oxidized/model/outputs.rb
+++ b/lib/oxidized/model/outputs.rb
@@ -3,7 +3,7 @@ module Oxidized
class Outputs
def to_cfg
- type_to_str('cfg')
+ type_to_str(nil)
end
def type_to_str want_type
@@ -23,7 +23,7 @@ module Oxidized
end
def types
- @outputs.map { |out| out.type }.uniq - ['cfg']
+ @outputs.map { |out| out.type }.uniq.compact
end
private
diff --git a/lib/oxidized/output/file.rb b/lib/oxidized/output/file.rb
index 2d08106..03c878a 100644
--- a/lib/oxidized/output/file.rb
+++ b/lib/oxidized/output/file.rb
@@ -14,14 +14,14 @@ class OxidizedFile < Output
end
end
- def store node, data, opt={}
+ def store node, outputs, opt={}
file = @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 data }
+ open(file, 'w') { |fh| fh.write outputs.to_cfg }
end
def fetch node, group
diff --git a/lib/oxidized/output/git.rb b/lib/oxidized/output/git.rb
index f87ab66..0391d5d 100644
--- a/lib/oxidized/output/git.rb
+++ b/lib/oxidized/output/git.rb
@@ -28,11 +28,14 @@ class Git < Output
repo = @cfg.repo
outputs.types.each do |type|
+ type_cfg = ''
type_repo = File.join File.dirname(repo), type + '.git'
outputs.type(type).each do |output|
+ (type_cfg << output; next) if not output.name
type_file = file + '--' + output.name
update type_repo, type_file, output
end
+ update type_repo, file, type_cfg unless type_cfg.empty?
end
update repo, file, outputs.to_cfg
diff --git a/lib/oxidized/string.rb b/lib/oxidized/string.rb
index b17f896..d95bcae 100644
--- a/lib/oxidized/string.rb
+++ b/lib/oxidized/string.rb
@@ -1,7 +1,7 @@
module Oxidized
# Used in models, contains convenience methods
class String < String
- attr_accessor :type, :cmd
+ attr_accessor :type, :cmd, :name
# @return [Oxidized::String] copy of self with last line removed
def cut_tail
@@ -13,17 +13,11 @@ module Oxidized
Oxidized::String.new each_line.to_a[1..-1].join
end
- # @return clean/filename version of cmd
- def name
- cmd.strip.gsub(/\s+/, '_')
+ # sets @cmd and @name unless @name is already set
+ def set_cmd command
+ @cmd = command
+ @name = @cmd.strip.gsub(/\s+/, '_') if @name == nil
end
- private
-
- def initialize arg
- super
- @type = 'cfg'
- @cmd = 'n/a'
- end
end
end