X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=lib%2Fsup%2Fsource.rb;h=78386ff3fd19b0f74c75820827346df036f84c61;hb=3de96fb9b308afe600c7ccfcee75913f039ef4f6;hp=8154591f6adce27c071e16d11784f8dd77b05888;hpb=5f393122bdba9d1374461a01a7d0b3c694c6db3c;p=sup diff --git a/lib/sup/source.rb b/lib/sup/source.rb index 8154591..78386ff 100644 --- a/lib/sup/source.rb +++ b/lib/sup/source.rb @@ -161,6 +161,21 @@ protected end end +## if you have a @labels instance variable, include this +## to serialize them nicely as an array, rather than as a +## nasty set. +module SerializeLabelsNicely + def before_marshal # can return an object + c = clone + c.instance_eval { @labels = @labels.to_a.map { |l| l.to_s } } + c + end + + def after_unmarshal! + @labels = Set.new(@labels.map { |s| s.to_sym }) + end +end + class SourceManager include Singleton @@ -209,7 +224,7 @@ class SourceManager File.chmod 0600, fn FileUtils.mv fn, bakfn, :force => true unless File.exists?(bakfn) && File.size(fn) == 0 end - Redwood::save_yaml_obj sources.sort_by { |s| s.id.to_i }, fn, true + Redwood::save_yaml_obj sources, fn, true File.chmod 0600, fn end @sources_dirty = false