Created
November 22, 2013 17:16
-
-
Save eterps/7603536 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Gem::Specification.new do |s| | |
s.name = 'open-s3uri' | |
s.version = '0.1.0' | |
s.platform = Gem::Platform::RUBY | |
s.author = 'Erik Terpstra' | |
s.email = '[email protected]' | |
s.summary = 'Opens an S3 uri' | |
s.description = 'Opens an S3 uri like open-uri does for http URLs' | |
s.files = ['open-s3uri.rb'] | |
s.require_path = '.' | |
s.add_dependency 'aws-sdk' | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'aws-sdk' | |
class AWS::S3 | |
# @param [String] S3 uri | |
# @return [AWS::S3::S3Object] S3 object (quacks like IO) | |
# @example Open an S3 object | |
# s3 = AWS::S3.new | |
# s3.open('s://mybucket/folder/hello.txt').read | |
def open(uri) | |
uri = URI(uri) | |
buckets[uri.host].objects[uri.path[1..-1]] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment