Parent

Generate_List

This tool generates a list to use for plugin and theme enumeration

Attributes

verbose[RW]

Public Class Methods

new(type, verbose) click to toggle source

type = themes | plugins

# File lib/wpstools/generate_list.rb, line 27
def initialize(type, verbose)
  if type =~ /plugins/
    @type           = "plugin"
    @svn_url        = 'http://plugins.svn.wordpress.org/'
    @file_name      = DATA_DIR + '/plugins.txt'
    @popular_url    = 'http://wordpress.org/extend/plugins/browse/popular/'
    @popular_regex  = %{<h3><a href="http://wordpress.org/extend/plugins/(.+)/">.+</a></h3>}
  elsif type =~ /themes/
    @type           = "theme"
    @svn_url        = 'http://themes.svn.wordpress.org/'
    @file_name      = DATA_DIR + '/themes.txt'
    @popular_url    = 'http://wordpress.org/extend/themes/browse/popular/'
    @popular_regex  = %{<h3><a href="http://wordpress.org/extend/themes/(.+)">.+</a></h3>}
  else
    raise "Type #{type} not defined"
  end
  @verbose  = verbose
  @browser  = Browser.instance
  @hydra    = @browser.hydra
end

Public Instance Methods

generate_full_list() click to toggle source
# File lib/wpstools/generate_list.rb, line 48
def generate_full_list
  items = Svn_Parser.new(@svn_url, @verbose).parse
  save items
end
save(items) click to toggle source

Save the file

# File lib/wpstools/generate_list.rb, line 99
def save(items)
  items.sort!
  items.uniq!
  puts "[*] We have parsed #{items.length} #{@type}s"
  File.open(@file_name, 'w') { |f| f.puts(items) }
  puts "New #{@file_name} file created"
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.