Class: Configuration::FileStore

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from FileSourceStoreBase

#initialize, #storage_path

Methods inherited from SourceStoreBase

#initialize

Methods included from ConditionalInclusion

#excluded?, #included?, #inclusion_matcher

Constructor Details

This class inherits a constructor from Configuration::FileSourceStoreBase

Class Method Details

.match(node) ⇒ Object



97
98
99
# File 'lib/httpimagestore/configuration/file.rb', line 97

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

.parse(configuration, node) ⇒ Object



101
102
103
# File 'lib/httpimagestore/configuration/file.rb', line 101

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

Instance Method Details

#realize(request_state) ⇒ Object



105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/httpimagestore/configuration/file.rb', line 105

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://#{URI.encode(rendered_path.to_s)}"

		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