Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,33 @@ EOM
end
end

desc 'Regenerate the deprecated unamespaced shims'
task :regenerate_unamespaced_shims do
Dir['lib/puppet/functions/*.rb'].each do |filename|
content = File.read(filename)

unless content =~ /@summary DEPRECATED. Use the namespaced function/
warn("#{filename} does not look like a deprecation shim (skipping)")
next
end

function_name = File.basename(filename, '.rb')

File.write(filename, <<~CODE)
# frozen_string_literal: true

# THIS FILE WAS GENERATED BY `rake regenerate_unamespaced_shims`

# @summary DEPRECATED. Use the namespaced function [`stdlib::#{function_name}`](#stdlib#{function_name}) instead.
Puppet::Functions.create_function(:#{function_name}) do
dispatch :deprecation_gen do
repeated_param 'Any', :args
end
def deprecation_gen(*args)
call_function('deprecation', '#{function_name}', 'This function is deprecated, please use stdlib::#{function_name} instead.')
call_function('stdlib::#{function_name}', *args)
end
end
CODE
end
end
4 changes: 3 additions & 1 deletion lib/puppet/functions/has_interface_with.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# frozen_string_literal: true

# THIS FILE WAS GENERATED BY `rake regenerate_unamespaced_shims`

# @summary DEPRECATED. Use the namespaced function [`stdlib::has_interface_with`](#stdlibhas_interface_with) instead.
Puppet::Functions.create_function(:has_interface_with) do
dispatch :deprecation_gen do
repeated_param 'Any', :args
end
def deprecation_gen(*args)
call_function('deprecation', 'has_interface_with', 'This method is deprecated, please use stdlib::has_interface_with instead.')
call_function('deprecation', 'has_interface_with', 'This function is deprecated, please use stdlib::has_interface_with instead.')
call_function('stdlib::has_interface_with', *args)
end
end