lib/io_streams/s3.rb in iostreams-0.17.0 vs lib/io_streams/s3.rb in iostreams-0.17.1
- old
+ new
@@ -1,11 +1,5 @@
-begin
- require 'aws-sdk-s3'
-rescue LoadError => exc
- raise(LoadError, "Install gem 'aws-sdk-s3' to read and write AWS S3 files: #{exc.message}")
-end
-
require 'uri'
module IOStreams
module S3
autoload :Reader, 'io_streams/s3/reader'
autoload :Writer, 'io_streams/s3/writer'
@@ -14,10 +8,18 @@
def self.parse_uri(uri)
uri = URI.parse(uri)
raise "Invalid URI. Required Format: 's3://<bucket_name>/<key>'" unless uri.scheme == 's3'
{
bucket: uri.host,
- key: uri.path.sub(/\A\//, '')
+ key: uri.path.sub(/\A\//, '')
}
+ end
+
+ def self.load_dependencies
+ return unless defined?(::Aws::S3::Resource)
+
+ require 'aws-sdk-s3'
+ rescue LoadError => exc
+ raise(LoadError, "Install gem 'aws-sdk-s3' to read and write AWS S3 files: #{exc.message}")
end
end
end