lib/backup/storage/cycler.rb in backup-4.4.1 vs lib/backup/storage/cycler.rb in backup-5.0.0.beta.1

- old
+ new

@@ -1,7 +1,5 @@ -# encoding: utf-8 - module Backup module Storage module Cycler class Error < Backup::Error; end @@ -9,11 +7,11 @@ # Adds the current package being stored to the YAML cycle data file # and will remove any old package file(s) when the storage limit # set by #keep is exceeded. def cycle! - Logger.info 'Cycling Started...' + Logger.info "Cycling Started..." packages = yaml_load.unshift(package) cycled_packages = [] if keep.is_a?(Date) || keep.is_a?(Time) @@ -30,28 +28,26 @@ yaml_save(saved_packages) end def delete_package(package) - begin - remove!(package) unless package.no_cycle - rescue => err - Logger.warn Error.wrap(err, <<-EOS) + remove!(package) unless package.no_cycle + rescue => err + Logger.warn Error.wrap(err, <<-EOS) There was a problem removing the following package: Trigger: #{package.trigger} :: Dated: #{package.time} - Package included the following #{ package.filenames.count } file(s): - #{ package.filenames.join("\n") } + Package included the following #{package.filenames.count} file(s): + #{package.filenames.join("\n")} EOS - end end # Returns path to the YAML data file. def yaml_file @yaml_file ||= begin - filename = self.class.to_s.split('::').last - filename << "-#{ storage_id }" if storage_id - File.join(Config.data_path, package.trigger, "#{ filename }.yml") + filename = self.class.to_s.split("::").last + filename << "-#{storage_id}" if storage_id + File.join(Config.data_path, package.trigger, "#{filename}.yml") end end # Returns stored Package objects, sorted by #time descending (oldest last). def yaml_load @@ -63,13 +59,12 @@ end # Stores the given package objects to the YAML data file. def yaml_save(packages) FileUtils.mkdir_p(File.dirname(yaml_file)) - File.open(yaml_file, 'w') do |file| + File.open(yaml_file, "w") do |file| file.write(packages.to_yaml) end end - end end end