Class: Configuration::Path

Inherits:
RubyStringTemplate show all
Defined in:
lib/httpimagestore/configuration/path.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from RubyStringTemplate

#render

Constructor Details

#initialize(path_name, template) ⇒ Path

Returns a new instance of Path.



44
45
46
47
48
49
50
51
52
# File 'lib/httpimagestore/configuration/path.rb', line 44

def initialize(path_name, template)
	super(template) do |locals, name|
		begin
			locals[name]
		rescue ConfigurationError => error
			raise PathRenderingError.new(path_name, template, error.message)
		end or raise NoValueForPathTemplatePlaceholerError.new(path_name, template, name)
	end
end

Class Method Details

.match(node) ⇒ Object



24
25
26
# File 'lib/httpimagestore/configuration/path.rb', line 24

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

.parse(configuration, node) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/httpimagestore/configuration/path.rb', line 32

def self.parse(configuration, node)
	nodes = []
	nodes << node unless node.values.empty?
	nodes |= node.children

	nodes.empty? and raise NoValueError.new(node, 'path name')
	nodes.each do |node|
		path_name, template = *node.grab_values('path name', 'path template')
		configuration.paths[path_name] = Path.new(path_name, template)
	end
end

.pre(configuration) ⇒ Object



28
29
30
# File 'lib/httpimagestore/configuration/path.rb', line 28

def self.pre(configuration)
	configuration.paths ||= Hash.new{|hash, path_name| raise PathNotDefinedError.new(path_name)}
end