Class: Configuration::FileSourceStoreBase

Inherits:
SourceStoreBase show all
Extended by:
Stats
Defined in:
lib/httpimagestore/configuration/file.rb

Direct Known Subclasses

FileSource, FileStore

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ConditionalInclusion

#excluded?, #included?, #inclusion_matcher

Constructor Details

#initialize(global, image_name, matcher, root_dir, path_spec) ⇒ FileSourceStoreBase

Returns a new instance of FileSourceStoreBase.



43
44
45
46
47
# File 'lib/httpimagestore/configuration/file.rb', line 43

def initialize(global, image_name, matcher, root_dir, path_spec)
	super global, image_name, matcher
	@root_dir = Pathname.new(root_dir).cleanpath
	@path_spec = path_spec
end

Class Method Details

.parse(configuration, node) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/httpimagestore/configuration/file.rb', line 28

def self.parse(configuration, node)
	image_name = node.grab_values('image name').first
	node.required_attributes('root', 'path')
	root_dir, path_spec, if_image_name_on = *node.grab_attributes('root', 'path', 'if-image-name-on')
	matcher = InclusionMatcher.new(image_name, if_image_name_on)

	self.new(
		configuration.global,
		image_name,
		matcher,
		root_dir,
		path_spec
	)
end

Instance Method Details

#storage_path(rendered_path) ⇒ Object



49
50
51
52
53
54
55
56
# File 'lib/httpimagestore/configuration/file.rb', line 49

def storage_path(rendered_path)
	path = Pathname.new(rendered_path)

	storage_path = (@root_dir + path).cleanpath
	storage_path.to_s =~ /^#{@root_dir.to_s}/ or raise FileStorageOutsideOfRootDirError.new(@image_name, path)

	storage_path
end