Sha256: 01d1d7d5f441199595795e93e81460638f25d5a43ab4dd346e3cac5cca58759c

Contents?: true

Size: 880 Bytes

Versions: 6

Compression:

Stored size: 880 Bytes

Contents

module S3Website
  class Keyboard
    def self.if_user_confirms_delete(to_delete, standard_input=STDIN)
      delete_all = false
      keep_all = false
      confirmed_deletes = to_delete.map do |f|
        delete = false
        keep = false
        until delete || delete_all || keep || keep_all
          puts "#{f} is on S3 but not in your website directory anymore. Do you want to [d]elete, [D]elete all, [k]eep, [K]eep all?"
          case standard_input.gets.chomp
          when 'd' then delete = true
          when 'D' then delete_all = true
          when 'k' then keep = true
          when 'K' then keep_all = true
          end
        end
        if (delete_all || delete) && !(keep_all || keep)
          f
        end
      end.select { |f| f }
      Parallelism.each_in_parallel_or_sequentially(confirmed_deletes) { |f|
        yield f
      }
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
s3_website-1.0.3 lib/s3_website/keyboard.rb
s3_website-1.0.2 lib/s3_website/keyboard.rb
s3_website-1.0.1 lib/s3_website/keyboard.rb
s3_website-1.0.0 lib/s3_website/keyboard.rb
s3_website-0.4.0 lib/s3_website/keyboard.rb
s3_website-0.3.0 lib/s3_website/keyboard.rb