Class: Configuration::FileSource
Class Method Summary
collapse
Instance Method Summary
collapse
#initialize, #storage_path
#initialize
#excluded?, #included?, #inclusion_matcher
Class Method Details
.match(node) ⇒ Object
62
63
64
|
# File 'lib/httpimagestore/configuration/file.rb', line 62
def self.match(node)
node.name == 'source_file'
end
|
.parse(configuration, node) ⇒ Object
66
67
68
|
# File 'lib/httpimagestore/configuration/file.rb', line 66
def self.parse(configuration, node)
configuration.sources << super
end
|
Instance Method Details
#realize(request_state) ⇒ Object
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/httpimagestore/configuration/file.rb', line 70
def realize(request_state)
put_sourced_named_image(request_state) do |image_name, rendered_path|
storage_path = storage_path(rendered_path)
log.info "sourcing '#{image_name}' from file '#{storage_path}'"
begin
data = storage_path.open('rb') do |io|
request_state.memory_limit.io io
io.read
end
FileSourceStoreBase.stats.incr_total_file_source
FileSourceStoreBase.stats.incr_total_file_source_bytes(data.bytesize)
image = Image.new(data)
image.source_url = "file://#{URI.encode(rendered_path.to_s)}"
image
rescue Errno::ENOENT
raise NoSuchFileError.new(image_name, rendered_path)
end
end
end
|