module Wpxf::ModuleInfo

Provides functionality for specifying module metadata.

Public Class Methods

new() click to toggle source

Initialize a new instance of {ModuleInfo}.

Calls superclass method
# File lib/wpxf/core/module_info.rb, line 7
def initialize
  super
  @_module_info = {}
end

Public Instance Methods

emit_usage_info() click to toggle source

Emits any information that the user should be aware of before using the module.

# File lib/wpxf/core/module_info.rb, line 54
def emit_usage_info
  nil
end
module_author() click to toggle source

@return [Array] the name of the module author(s).

# File lib/wpxf/core/module_info.rb, line 39
def module_author
  @_module_info[:author]
end
module_date() click to toggle source

@return [Date] the disclosure date of the vulnerability.

# File lib/wpxf/core/module_info.rb, line 44
def module_date
  @_module_info[:date]
end
module_desc() click to toggle source

@return [String] the description of the module.

# File lib/wpxf/core/module_info.rb, line 29
def module_desc
  @_module_info[:desc]
end
module_description_preformatted() click to toggle source

@return [Boolean] true if the description is preformatted.

# File lib/wpxf/core/module_info.rb, line 49
def module_description_preformatted
  @_module_info[:desc_preformatted]
end
module_name() click to toggle source

@return [String] the name of the module.

# File lib/wpxf/core/module_info.rb, line 24
def module_name
  @_module_info[:name]
end
module_references() click to toggle source

@return [Array] an aray of references relating to the module.

# File lib/wpxf/core/module_info.rb, line 34
def module_references
  @_module_info[:references]
end
update_info(info) click to toggle source

Update the module info. @param info [Hash] a hash containing the module info.

# File lib/wpxf/core/module_info.rb, line 14
def update_info(info)
  required_keys = %i[name desc author date]
  unless required_keys.all? { |key| info.key?(key) || @_module_info.key?(key) }
    raise 'Missing one or more required module info keys'
  end

  _update_info_without_validation(info)
end

Private Instance Methods

_update_info_without_validation(info) click to toggle source
# File lib/wpxf/core/module_info.rb, line 60
def _update_info_without_validation(info)
  @_module_info.merge!(info)

  if @_module_info[:date]
    @_module_info[:date] = Date.parse(@_module_info[:date].to_s)
  end

  if @_module_info[:desc]
    @_module_info[:desc] = @_module_info[:desc].gsub(/  +/, ' ')
  end

  @_module_info
end