Class: Configuration::FileSourceStoreBase
Class Method Summary
collapse
Instance Method Summary
collapse
#excluded?, #included?, #inclusion_matcher
Constructor Details
#initialize(global, image_name, matcher, root_dir, path_spec) ⇒ FileSourceStoreBase
Returns a new instance of FileSourceStoreBase.
44
45
46
47
48
|
# File 'lib/httpimagestore/configuration/file.rb', line 44
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/httpimagestore/configuration/file.rb', line 29
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
50
51
52
53
54
55
56
57
|
# File 'lib/httpimagestore/configuration/file.rb', line 50
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
|
#to_s ⇒ Object
59
60
61
|
# File 'lib/httpimagestore/configuration/file.rb', line 59
def to_s
"FileSource[image_name: '#{@image_name}' root_dir: '#{@root_dir}' path_spec: '#{@path_spec}']"
end
|