Sha256: b2657666352db2819f31304b31eddbd5984d4d1ba517ba138749bf37837701f2
Contents?: true
Size: 1019 Bytes
Versions: 3
Compression:
Stored size: 1019 Bytes
Contents
# frozen_string_literal: true module Expire # Reads contents of a directory and returns a corresponding BackupList class GenerateBackupListService def self.call(path) new(path).call end def initialize(path) @path = path end attr_reader :path 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 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 # backup_path may be a String or a Pathname so we call #to_s to # ensure that chomp works as expected def purify_backup_path(backup_path) backup_path.to_s.chomp.strip end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
expire-0.2.2 | lib/expire/generate_backup_list_service.rb |
expire-0.2.1 | lib/expire/generate_backup_list_service.rb |
expire-0.2.0 | lib/expire/generate_backup_list_service.rb |