class Blockbuster::Delta
Delta
file objects
Constants
- INITIALIZING_NUMBER
Attributes
configuration[R]
file_name[R]
Public Class Methods
file_name_without_timestamp(file_name)
click to toggle source
# File lib/blockbuster/delta.rb, line 43 def self.file_name_without_timestamp(file_name) file_name.sub(/^\d+_/, '') end
files(directory)
click to toggle source
# File lib/blockbuster/delta.rb, line 18 def self.files(directory) Dir.glob("#{directory}/*.tar.gz").sort.map { |file| File.basename(file) } end
initialize_for_each(comparator, configuration)
click to toggle source
# File lib/blockbuster/delta.rb, line 22 def self.initialize_for_each(comparator, configuration) setup_directory(configuration.full_delta_directory) delta_files = files(configuration.full_delta_directory) # If the current delta doesn't exist we want to add it current_delta = configuration.current_delta_name delta_files << "#{INITIALIZING_NUMBER}_#{current_delta}" unless delta_files.any? { |file| file_name_without_timestamp(file) == current_delta } delta_files.map do |file| new(file, comparator, configuration) end end
new(file_name, comparator, configuration)
click to toggle source
# File lib/blockbuster/delta.rb, line 47 def initialize(file_name, comparator, configuration) raise NotEnabledError if configuration.deltas_disabled? @configuration = configuration @comparator = comparator @file_name = file_name @current = true if file_name_without_timestamp == configuration.current_delta_name end
setup_directory(directory)
click to toggle source
# File lib/blockbuster/delta.rb, line 36 def self.setup_directory(directory) return if Dir.exist?(directory) FileUtils.mkdir_p(directory) FileUtils.touch("#{directory}/.keep") end
Public Instance Methods
current()
click to toggle source
# File lib/blockbuster/delta.rb, line 60 def current @current || false end
Also aliased as: current?
file_name_without_timestamp()
click to toggle source
# File lib/blockbuster/delta.rb, line 56 def file_name_without_timestamp self.class.file_name_without_timestamp(file_name) end
file_path()
click to toggle source
# File lib/blockbuster/delta.rb, line 66 def file_path File.join(configuration.full_delta_directory, file_name) end
target_path()
click to toggle source
# File lib/blockbuster/delta.rb, line 70 def target_path target = [Time.now.to_i, configuration.current_delta_name].join('_') File.join(configuration.full_delta_directory, target) end