Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow configuration of the disk adapter base dir via the config class #48

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
v0.6.0
------
- Allow overriding the disk adapter base directory via the configuration class.

v0.5.0
------
- Support escaping of URI keys. Fixes #46.
Expand Down
15 changes: 15 additions & 0 deletions lib/bucket_store/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,20 @@ def logger
# config.logger = Logger.new($stderr)
# @!attribute logger
attr_writer :logger

def disk_adapter_base_directory
@disk_adapter_base_directory ||= ENV["DISK_ADAPTER_BASE_DIR"] || Dir.tmpdir
end

# Specifies the location of the disk adapter's base directory.
#
# If `DISK_ADAPTER_BASE_DIR` is given as an environment variable, its value
# will be used as a default value. Otherwise this will be equal to the operating
# system's default temporary file path.
#
# @example Create a temporary directory for the disk adapter
# config.disk_adapter_base_directory = Dir.mktmpdir
# @!attribute disk_adapter_base_directory
attr_writer :disk_adapter_base_directory
end
end
3 changes: 1 addition & 2 deletions lib/bucket_store/disk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

module BucketStore
class Disk
def self.build(base_dir = ENV["DISK_ADAPTER_BASE_DIR"])
base_dir ||= Dir.tmpdir
def self.build(base_dir = BucketStore.configuration.disk_adapter_base_directory)
Disk.new(base_dir)
end

Expand Down