From 62771e12454ec7016c961af043ef67af90de5400 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Art=C5=ABrs=20Pirogovs?= Date: Mon, 25 Sep 2023 17:40:27 +0300 Subject: [PATCH] Support for legacy in-memory storage behavior - In memory storage - persists encoding for upload / download --- CHANGELOG.md | 5 +++++ lib/bucket_store/in_memory.rb | 10 ++++++++-- lib/bucket_store/version.rb | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 738d1c8..5ebdb77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +v0.6.1 +------ +- Support for legacy in-memory storage behavior + * In memory storage - persists encoding for upload / download + v0.6.0 ------ - [BREAKING] Remove support for Ruby 2.6 diff --git a/lib/bucket_store/in_memory.rb b/lib/bucket_store/in_memory.rb index 8fd88fd..111b0c3 100644 --- a/lib/bucket_store/in_memory.rb +++ b/lib/bucket_store/in_memory.rb @@ -26,7 +26,10 @@ def reset! def upload!(bucket:, key:, file:) file.tap do |f| - @buckets[bucket][key] = f.read + @buckets[bucket][key] = { + data: f.read, + encoding: file.external_encoding + } end { @@ -37,7 +40,10 @@ def upload!(bucket:, key:, file:) def download(bucket:, key:, file:) file.tap do |f| - f.write(@buckets[bucket].fetch(key)) + f.set_encoding( + @buckets[bucket].fetch(key).fetch(:encoding) + ) + f.write(@buckets[bucket].fetch(key).fetch(:data)) f.rewind end end diff --git a/lib/bucket_store/version.rb b/lib/bucket_store/version.rb index 5195582..259b845 100644 --- a/lib/bucket_store/version.rb +++ b/lib/bucket_store/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module BucketStore - VERSION = "0.6.0" + VERSION = "0.6.1" end