Class: Puppet::FileServing::Configuration
- Defined in:
- lib/puppet/file_serving/configuration.rb
Defined Under Namespace
Classes: Parser
Constant Summary collapse
- Mount =
Puppet::FileServing::Mount
Instance Attribute Summary collapse
- #mounts ⇒ Object readonly
Class Method Summary collapse
Instance Method Summary collapse
-
#find_mount(mount_name, environment) ⇒ Object
Find the right mount.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#mounted?(name) ⇒ Boolean
Is a given mount available?.
-
#split_path(request) ⇒ Object
Split the path into the separate mount point and path.
- #umount(name) ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
32 33 34 35 36 37 38 39 |
# File 'lib/puppet/file_serving/configuration.rb', line 32 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)
20 21 22 |
# File 'lib/puppet/file_serving/configuration.rb', line 20 def mounts @mounts end |
Class Method Details
.configuration ⇒ Object
12 13 14 |
# File 'lib/puppet/file_serving/configuration.rb', line 12 def self.configuration @configuration ||= new end |
Instance Method Details
#find_mount(mount_name, environment) ⇒ Object
Find the right mount. Does some shenanigans to support old-style module mounts.
25 26 27 28 29 30 |
# File 'lib/puppet/file_serving/configuration.rb', line 25 def find_mount(mount_name, environment) # Reparse the configuration if necessary. readconfig # This can be nil. mounts[mount_name] end |
#mounted?(name) ⇒ Boolean
Is a given mount available?
42 43 44 |
# File 'lib/puppet/file_serving/configuration.rb', line 42 def mounted?(name) @mounts.include?(name) end |
#split_path(request) ⇒ Object
Split the path into the separate mount point and path.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/puppet/file_serving/configuration.rb', line 47 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}'") unless mount_name =~ %r{^[-\w]+$} raise(ArgumentError, "Cannot find file: Invalid relative path '#{path}'") if path and path.split('/').include?('..') return nil unless mount = find_mount(mount_name, request.environment) 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
72 73 74 |
# File 'lib/puppet/file_serving/configuration.rb', line 72 def umount(name) @mounts.delete(name) if @mounts.include? name end |