Skip to content

Commit

Permalink
Update for Shrine 1.1
Browse files Browse the repository at this point in the history
We add `#stream` for streaming download. We also add a Shrine dependency
because just in case Shrine 2.0 breaks some backwards compatibility for
shrine-fog. We also require "shrine" for consistency with other
storages. We also don't need to rewind the file anymore.
  • Loading branch information
janko committed Dec 26, 2015
1 parent bba5ab5 commit 6c769e5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
10 changes: 7 additions & 3 deletions lib/shrine/storage/fog.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require "shrine"
require "down"
require "uri"

Expand Down Expand Up @@ -26,6 +27,10 @@ def download(id)
Down.download(url(id))
end

def stream(id)
get(id) { |chunk| yield chunk }
end

def open(id)
download(id)
end
Expand Down Expand Up @@ -64,8 +69,8 @@ def file(id)
directory.files.new(key: path(id))
end

def get(id)
directory.files.get(path(id))
def get(id, &block)
directory.files.get(path(id), &block)
end

def head(id)
Expand All @@ -91,7 +96,6 @@ def put(io, id, metadata = {})
options[:content_type] = metadata["mime_type"]

directory.files.create(options)
io.rewind
end

def copy(io, id, metadata = {})
Expand Down
6 changes: 3 additions & 3 deletions shrine-fog.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |gem|
gem.name = "shrine-fog"
gem.version = "0.1.1"
gem.version = "0.2.0"

gem.required_ruby_version = ">= 2.1"

Expand All @@ -14,12 +14,12 @@ Gem::Specification.new do |gem|
gem.files = Dir["README.md", "LICENSE.txt", "lib/**/*.rb", "shrine-fog.gemspec"]
gem.require_path = "lib"

gem.add_development_dependency "down", ">= 1.0.3"
gem.add_dependency "shrine", "~> 1.1"
gem.add_dependency "down", ">= 1.0.5"

gem.add_development_dependency "rake"
gem.add_development_dependency "fog-aws"
gem.add_development_dependency "mime-types"
gem.add_development_dependency "dotenv"
gem.add_development_dependency "shrine"
gem.add_development_dependency "minitest", "~> 5.8"
end

0 comments on commit 6c769e5

Please sign in to comment.