X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=lib%2Fsup%2Fsource.rb;h=78386ff3fd19b0f74c75820827346df036f84c61;hb=aa5608229171a78694c64d0a30375e765ffe86e0;hp=8154591f6adce27c071e16d11784f8dd77b05888;hpb=3dc202c1f8880357ce31bb65e4f52fe1110dad60;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