Class: Configuration::FileSource
- Inherits:
-
FileSourceStoreBase
- Object
- Scope
- HandlerStatement
- SourceStoreBase
- FileSourceStoreBase
- Configuration::FileSource
- Includes:
- ClassLogging
- Defined in:
- lib/httpimagestore/configuration/file.rb
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from FileSourceStoreBase
#file_url, #initialize, #storage_path, #to_s
Methods inherited from SourceStoreBase
Methods inherited from Scope
#initialize, node_parsers, #parse, register_node_parser
Constructor Details
This class inherits a constructor from Configuration::FileSourceStoreBase
Class Method Details
.match(node) ⇒ Object
77 78 79 |
# File 'lib/httpimagestore/configuration/file.rb', line 77 def self.match(node) node.name == 'source_file' end |
.parse(configuration, node) ⇒ Object
81 82 83 |
# File 'lib/httpimagestore/configuration/file.rb', line 81 def self.parse(configuration, node) configuration.sources << super end |
Instance Method Details
#realize(request_state) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/httpimagestore/configuration/file.rb', line 85 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 = measure "sourcing image from file", image_name do storage_path.open('rb') do |io| request_state.memory_limit.io io io.read end end FileSourceStoreBase.stats.incr_total_file_source FileSourceStoreBase.stats.incr_total_file_source_bytes(data.bytesize) image = Image.new(data) image.source_url = file_url(rendered_path) image rescue Errno::ENOENT raise NoSuchFileError.new(image_name, rendered_path) end end end |