Update stdlib and concat to 6.1.0 both
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / lib / puppet / functions / stdlib / extname.rb
1 # @summary
2 #   Returns the Extension (the Portion of Filename in Path starting from the
3 #   last Period).
4 #
5 # If Path is a Dotfile, or starts with a Period, then the starting Dot is not
6 # dealt with the Start of the Extension.
7 #
8 # An empty String will also be returned, when the Period is the last Character
9 # in Path.
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