Class: Puppet::FileServing::Configuration Private
- Defined in:
- lib/puppet/file_serving/configuration.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Defined Under Namespace
Classes: Parser
Constant Summary collapse
- Mount =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Puppet::FileServing::Mount
Instance Attribute Summary collapse
- #mounts ⇒ Object readonly private
Class Method Summary collapse
- .configuration ⇒ Object private
Instance Method Summary collapse
-
#find_mount(mount_name, environment) ⇒ Object
private
Find the right mount.
-
#initialize ⇒ Configuration
constructor
private
A new instance of Configuration.
-
#mounted?(name) ⇒ Boolean
private
Is a given mount available?.
-
#split_path(request) ⇒ Object
private
Split the path into the separate mount point and path.
- #umount(name) ⇒ Object private
Constructor Details
#initialize ⇒ Configuration
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Configuration.
36 37 38 39 40 41 42 43 |
# File 'lib/puppet/file_serving/configuration.rb', line 36 def initialize @mounts = {} @config_file = nil # We don't check to see if the file is modified the first time, # because we always want to parse at first. readconfig(false) end |
Instance Attribute Details
#mounts ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
24 25 26 |
# File 'lib/puppet/file_serving/configuration.rb', line 24 def mounts @mounts end |
Class Method Details
.configuration ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
16 17 18 |
# File 'lib/puppet/file_serving/configuration.rb', line 16 def self.configuration @configuration ||= new end |
Instance Method Details
#find_mount(mount_name, environment) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Find the right mount. Does some shenanigans to support old-style module mounts.
29 30 31 32 33 34 |
# File 'lib/puppet/file_serving/configuration.rb', line 29 def find_mount(mount_name, environment) # Reparse the configuration if necessary. readconfig # This can be nil. mounts[mount_name] end |
#mounted?(name) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Is a given mount available?
46 47 48 |
# File 'lib/puppet/file_serving/configuration.rb', line 46 def mounted?(name) @mounts.include?(name) end |
#split_path(request) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Split the path into the separate mount point and path.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/puppet/file_serving/configuration.rb', line 51 def split_path(request) # Reparse the configuration if necessary. readconfig mount_name, path = request.key.split(File::Separator, 2) raise(ArgumentError, _("Cannot find file: Invalid mount '%{mount_name}'") % { mount_name: mount_name }) unless mount_name =~ %r{^[-\w]+$} raise(ArgumentError, _("Cannot find file: Invalid relative path '%{path}'") % { path: path }) if path and path.split('/').include?('..') mount = find_mount(mount_name, request.environment) return nil unless mount if mount.name == "modules" and mount_name != "modules" # yay backward-compatibility path = "#{mount_name}/#{path}" end if path == "" path = nil elsif path # Remove any double slashes that might have occurred path = path.gsub(/\/+/, "/") end return mount, path end |
#umount(name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
77 78 79 |
# File 'lib/puppet/file_serving/configuration.rb', line 77 def umount(name) @mounts.delete(name) if @mounts.include? name end |