Method: Danger::PluginParser#method_params

Defined in:
lib/danger/plugin_support/plugin_parser.rb

#method_params(method) ⇒ Object



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/danger/plugin_support/plugin_parser.rb', line 106

def method_params(method)
  return {} unless method[:params]

  params_names = method[:params].map { |param| param.compact.join("=").strip }
  params_values = method[:tags].select { |t| t[:name] == "param" }

  return {} if params_values.empty?
  return {} if params_values.select { |p| p[:types] }.empty?

  return params_names.map.with_index do |name, index|
    name = name.delete ":"
    if index < params_values.length
      type = params_values[index][:types]
      { name => type ? type.first : "Unknown" }
    else
      { name => "Unknown" }
    end
  end
end