provider/ansible.rb
# Given a URL and function name, emit a URL.
# URL functions will have 1-3 parameters.
# * module will always be included.
# * extra_data is a dict of extra information.
# * extra_url will have a URL chunk to be appended after the URL.
# rubocop:disable Metrics/MethodLength
Given a URL and function name, emit a URL.
URL functions will have 1-3 parameters.
module will always be included.
extra_data is a dict of extra information.
extra_url will have a URL chunk to be appended after the URL.
Given a URL and function name emit a URL . URL functions will have 1 - 3 parameters . module will always be included . extra_data is a dict of extra information . extra_url will have a URL chunk to be appended after the URL .
def emit_link(name, url, extra_data = false)
        params = emit_link_var_args(url, extra_data)
        extra = (' + extra' if url.include?('<|extra|>')) || ''
        if extra_data
          [
            "def #{name}(#{params.join(', ')}):",
            indent([
                     'if extra_data is None:',
                     indent('extra_data = {}', 4)
                   ], 4),
            indent("url = #{url}#{extra}", 4).gsub('<|extra|>', ''),
            indent([
                     'combined = extra_data.copy()',
                     'combined.update(module.params)',
                     'return url.format(**combined)'
                   ], 4)
          ].compact.join("\n")
        else
          url_code = "#{url}.format(**module.params)#{extra}"
          [
            "def #{name}(#{params.join(', ')}):",
            indent("return #{url_code}", 4).gsub('<|extra|>', '')
          ].join("\n")
        end
      end
def emit_link ( name , url , extra_data = false ) params = emit_link_var_args ( url , extra_data ) extra = ( ' + extra' if url . include? ( '<|extra|>' ) ) || '' if extra_data [ "def #{name}(#{params.join(', ')}):" , indent ( [ 'if extra_data is None:' , indent ( 'extra_data = {}' , 4 ) ] , 4 ) , indent ( "url = #{url}#{extra}" , 4 ) . gsub ( '<|extra|>' , '' ) , indent ( [ 'combined = extra_data.copy()' , 'combined.update(module.params)' , 'return url.format(**combined)' ] , 4 ) ] . compact . join ( "\n" ) else url_code = "#{url}.format(**module.params)#{extra}" [ "def #{name}(#{params.join(', ')}):" , indent ( "return #{url_code}" , 4 ) . gsub ( '<|extra|>' , '' ) ] . join ( "\n" ) end end
Given a URL and function name, emit a URL.
Given a URL and function name emit a URL .
name
<not_specific>
url
<not_specific>
extra_data
<not_specific>