class Expire::GenerateBackupListService
Reads contents of a directory and returns a corresponding BackupList
Attributes
path[R]
Public Class Methods
call(path)
click to toggle source
# File lib/expire/generate_backup_list_service.rb, line 6 def self.call(path) new(path).call end
new(path)
click to toggle source
# File lib/expire/generate_backup_list_service.rb, line 10 def initialize(path) @path = path end
Public Instance Methods
call()
click to toggle source
# File lib/expire/generate_backup_list_service.rb, line 16 def call if path == '-' generate_backup_list_from($stdin) else pathname = Pathname.new(path) raise InvalidPathError, "#{pathname} does not exit" unless pathname.exist? generate_backup_list_from(pathname.children) end end
Private Instance Methods
generate_backup_list_from(source)
click to toggle source
# File lib/expire/generate_backup_list_service.rb, line 29 def generate_backup_list_from(source) backup_list = BackupList.new source.each do |backup_path| backup_list << BackupFromPathService.call(path: purify_backup_path(backup_path)) end backup_list end
purify_backup_path(backup_path)
click to toggle source
backup_path may be a String or a Pathname so we call to_s to ensure that chomp works as expected
# File lib/expire/generate_backup_list_service.rb, line 41 def purify_backup_path(backup_path) backup_path.to_s.chomp.strip end