Class: Configuration::FileStore

Inherits:
FileSourceStoreBase show all
Includes:
ClassLogging
Defined in:
lib/httpimagestore/configuration/file.rb

Instance Attribute Summary

Attributes inherited from HandlerStatement

#config_locals

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from FileSourceStoreBase

#file_url, #initialize, #storage_path, #to_s

Methods inherited from SourceStoreBase

#initialize

Methods inherited from HandlerStatement

#config_local, #initialize, #path_template

Constructor Details

This class inherits a constructor from Configuration::FileSourceStoreBase

Class Method Details

.match(node) ⇒ Object



108
109
110
# File 'lib/httpimagestore/configuration/file.rb', line 108

def self.match(node)
	node.name == 'store_file'
end

.parse(configuration, node) ⇒ Object



112
113
114
# File 'lib/httpimagestore/configuration/file.rb', line 112

def self.parse(configuration, node)
	configuration.stores << super
end

Instance Method Details

#realize(request_state) ⇒ Object



116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/httpimagestore/configuration/file.rb', line 116

def realize(request_state)
	get_named_image_for_storage(request_state) do |image_name, image, rendered_path|
		storage_path = storage_path(rendered_path)

		image.store_url = file_url(rendered_path)

		log.info "storing '#{image_name}' in file '#{storage_path}' (#{image.data.length} bytes)"
		storage_path.open('wb'){|io| io.write image.data}
		FileSourceStoreBase.stats.incr_total_file_store
		FileSourceStoreBase.stats.incr_total_file_store_bytes(image.data.bytesize)
	end
end