Skip to content

Commit f5d6408

Browse files
committed
Rename Storage::Base base class to Storage and add S3 shard
1 parent 62bc50e commit f5d6408

8 files changed

Lines changed: 11 additions & 8 deletions

File tree

shard.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,8 @@ development_dependencies:
5656
ameba:
5757
github: crystal-ameba/ameba
5858
version: ~> 1.6.4
59+
awscr-s3:
60+
github: taylorfinnell/awscr-s3
61+
version: ~> 0.10.0
5962

6063
license: MIT

spec/lucky/attachment/uploader_spec.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ describe Lucky::Attachment::Uploader do
9494
context "error handling" do
9595
it "raises Error when no storages are not configured" do
9696
Lucky::Attachment.configure do |settings|
97-
settings.storages = {} of String => Lucky::Attachment::Storage::Base
97+
settings.storages = {} of String => Lucky::Attachment::Storage
9898
end
9999

100100
expect_raises(

src/lucky/attachment/config.cr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module Lucky::Attachment
1010
# NOTE: Additional stores are not supported yet. Please reach out if that
1111
# is something you need.
1212
#
13-
setting storages : Hash(String, Storage::Base) = {} of String => Storage::Base
13+
setting storages : Hash(String, Storage) = {} of String => Storage
1414

1515
# Path prefix for uploads. Possible keywords are:
1616
# - `:model` (an underscored string of the model name)
@@ -27,7 +27,7 @@ module Lucky::Attachment
2727
# Lucky::Attachment.find_storage("missing") # raises Lucky::Attachment::Error
2828
# ```
2929
#
30-
def self.find_storage(name : String) : Storage::Base
30+
def self.find_storage(name : String) : Storage
3131
settings.storages[name]? ||
3232
raise Error.new(
3333
String.build do |io|

src/lucky/attachment/storage.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Implementations must provide methods for uploading, retreiving, checking
33
# existence, and deleting files.
44
#
5-
abstract class Lucky::Attachment::Storage::Base
5+
abstract class Lucky::Attachment::Storage
66
# Uploads an IO to the given location (id) in the storage.
77
#
88
# ```

src/lucky/attachment/storage/file_system.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ require "../storage"
1515
# end
1616
# ```
1717
#
18-
class Lucky::Attachment::Storage::FileSystem < Lucky::Attachment::Storage::Base
18+
class Lucky::Attachment::Storage::FileSystem < Lucky::Attachment::Storage
1919
DEFAULT_PERMISSIONS = File::Permissions.new(0o644)
2020
DEFAULT_DIRECTORY_PERMISSIONS = File::Permissions.new(0o755)
2121

src/lucky/attachment/storage/memory.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ require "../storage"
1111
# end
1212
# ```
1313
#
14-
class Lucky::Attachment::Storage::Memory < Lucky::Attachment::Storage::Base
14+
class Lucky::Attachment::Storage::Memory < Lucky::Attachment::Storage
1515
getter store : Hash(String, Bytes)
1616
getter base_url : String?
1717

src/lucky/attachment/stored_file.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class Lucky::Attachment::StoredFile
110110
end
111111

112112
# Returns the storage instance this file is stored in.
113-
def storage : Storage::Base
113+
def storage : Storage
114114
::Lucky::Attachment.find_storage(storage_key)
115115
end
116116

src/lucky/attachment/uploader.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ abstract struct Lucky::Attachment::Uploader
2222
end
2323

2424
# Returns the storage instance for this uploader.
25-
def storage : Storage::Base
25+
def storage : Storage
2626
Lucky::Attachment.find_storage(storage_key)
2727
end
2828

0 commit comments

Comments
 (0)