lib/httpimagestore/configuration/s3.rb in httpimagestore-1.6.0 vs lib/httpimagestore/configuration/s3.rb in httpimagestore-1.7.0

- old
+ new

@@ -2,10 +2,11 @@ require 'digest/sha2' require 'msgpack' require 'httpimagestore/aws_sdk_regions_hack' require 'httpimagestore/configuration/path' require 'httpimagestore/configuration/handler' +require 'httpimagestore/configuration/source_failover' module Configuration class S3NotConfiguredError < ConfigurationError def initialize super "S3 client not configured" @@ -41,11 +42,11 @@ configuration.s3 and raise StatementCollisionError.new(node, 's3') node.grab_values node.required_attributes('key', 'secret') node.valid_attribute_values('ssl', true, false, nil) - + key, secret, ssl = node.grab_attributes('key', 'secret', 'ssl') ssl = true if ssl.nil? configuration.s3 = AWS::S3.new( access_key_id: key, @@ -189,11 +190,11 @@ end class CacheObject < S3Object extend Stats def_stats( - :total_s3_cache_hits, + :total_s3_cache_hits, :total_s3_cache_misses, :total_s3_cache_errors, ) include ClassLogging @@ -272,11 +273,11 @@ end end extend Stats def_stats( - :total_s3_store, + :total_s3_store, :total_s3_store_bytes, :total_s3_source, :total_s3_source_bytes ) @@ -284,22 +285,22 @@ image_name = node.grab_values('image name').first node.required_attributes('bucket', 'path') node.valid_attribute_values('public_access', true, false, nil) - bucket, path_spec, public_access, cache_control, prefix, cache_root, if_image_name_on = + bucket, path_spec, public_access, cache_control, prefix, cache_root, if_image_name_on = *node.grab_attributes('bucket', 'path', 'public', 'cache-control', 'prefix', 'cache-root', 'if-image-name-on') public_access = false if public_access.nil? prefix = '' if prefix.nil? self.new( - configuration.global, - image_name, + configuration.global, + image_name, InclusionMatcher.new(image_name, if_image_name_on), - bucket, - path_spec, - public_access, + bucket, + path_spec, + public_access, cache_control, prefix, cache_root ) end @@ -393,11 +394,16 @@ image.source_url = url(object) image end end end + + def to_s + "S3Source[image_name: '#{@image_name}' bucket: '#{@bucket}' prefix: '#{@prefix}' path_spec: '#{@path_spec}']" + end end Handler::register_node_parser S3Source + SourceFailover::register_node_parser S3Source class S3Store < S3SourceStoreBase def self.match(node) node.name == 'store_s3' end