Add missing new files from commit 131e09855e06
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / lib / puppet / functions / stdlib / extname.rb
1 # Returns the Extension (the Portion of Filename in Path starting from the
2 # last Period).
3 #
4 # If Path is a Dotfile, or starts with a Period, then the starting Dot is not
5 # dealt with the Start of the Extension.
6 #
7 # An empty String will also be returned, when the Period is the last Character
8 # in Path.
9
10 Puppet::Functions.create_function(:'stdlib::extname') do
11   # @param filename The Filename
12   # @return [String] The Extension starting from the last Period
13   # @example Determining the Extension of a Filename
14   #   stdlib::extname('test.rb')       => '.rb'
15   #   stdlib::extname('a/b/d/test.rb') => '.rb'
16   #   stdlib::extname('test')          => ''
17   #   stdlib::extname('.profile')      => ''
18   dispatch :extname do
19     param 'String', :filename
20     return_type 'String'
21   end
22
23   def extname(filename)
24     File.extname(filename)
25   end
26 end