# class WpItem - RDoc Documentation

# class WpItem

### Attributes

found_from[R]
name[RW]
path[R]
version[W]
wp_content_dir[RW]
wp_plugins_dir[RW]

### Public Class Methods

new(target_base_uri, options = {}) click to toggle source

@param [ URI ] target_base_uri @param [ Hash ] options See allowed_option

@return [ WpItem ]

    # File lib/common/models/wp_item.rb, line 31
    def initialize(target_base_uri, options = {})

      options[:wp_content_dir] ||= 'wp-content'
      options[:wp_plugins_dir] ||= options[:wp_content_dir] + '/plugins'

      set_options(options)
      forge_uri(target_base_uri)
    end

### Public Instance Methods

<=>(other) click to toggle source

@param [ WpItem ] other

    # File lib/common/models/wp_item.rb, line 88
    def <=>(other)
      name <=> other.name
    end

==(other) click to toggle source

@param [ WpItem ] other

    # File lib/common/models/wp_item.rb, line 93
    def ==(other)
      name === other.name
    end

===(other) click to toggle source

@param [ WpItem ] other

    # File lib/common/models/wp_item.rb, line 98
    def ===(other)
      self == other && version === other.version
    end

allowed_options() click to toggle source

@return [ Array ] Make it private ?

    # File lib/common/models/wp_item.rb, line 23
    def allowed_options
      [:name, :wp_content_dir, :wp_plugins_dir, :path, :version, :vulns_file]
    end

forge_uri(target_base_uri) click to toggle source

@param [ URI ] target_base_uri

@return [ void ]

    # File lib/common/models/wp_item.rb, line 61
    def forge_uri(target_base_uri)
      @uri = target_base_uri
    end

found_from=(method) click to toggle source

Sets the #found_from attribute

@param [ String ] method The method which found the WpItem

@return [ void ]

    # File lib/common/models/wp_item/findable.rb, line 10
    def found_from=(method)
      found       = method[%r{find_from_(.*)}, 1]
      @found_from = found.gsub('_', ' ') if found
    end

path=(path) click to toggle source

Sets the path

Variable, such as $wp-plugins$ and $wp-content$ can be used and will be replace by their value

@param [ String ] path

@return [ void ]

    # File lib/common/models/wp_item.rb, line 81
    def path=(path)
      @path = URI.encode(
        path.gsub(/\$wp-plugins\$/, wp_plugins_dir).gsub(/\$wp-content\$/, wp_content_dir)
      )
    end

uri() click to toggle source

@return [ URI ] The uri to the WpItem, with the path if present

    # File lib/common/models/wp_item.rb, line 66
    def uri
      path ? @uri.merge(path) : @uri
    end

url() click to toggle source

@return [ String ] The url to the WpItem

    # File lib/common/models/wp_item.rb, line 71
    def url; uri.to_s end