From 64c3c2959733fb3d144f544a85f478e8a99f92a7 Mon Sep 17 00:00:00 2001 From: erwanlr Date: Mon, 11 Mar 2013 17:52:19 +0100 Subject: [PATCH] StatsPlugin code factoring --- lib/wpstools/plugins/stats/stats_plugin.rb | 25 +++++++++++----------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/lib/wpstools/plugins/stats/stats_plugin.rb b/lib/wpstools/plugins/stats/stats_plugin.rb index bf89f762..4244fe88 100644 --- a/lib/wpstools/plugins/stats/stats_plugin.rb +++ b/lib/wpstools/plugins/stats/stats_plugin.rb @@ -65,22 +65,21 @@ class StatsPlugin < Plugin end def total_plugins(file=PLUGINS_FULL_FILE, xml=PLUGINS_VULNS_FILE) - options = {} - options[:only_vulnerable_ones] = false - options[:file] = file - options[:vulns_file] = xml - options[:base_url] = "http://localhost" - options[:type] = "plugins" - WpEnumerator.generate_items(options).count + total('plugins', file, xml) end def total_themes(file=THEMES_FULL_FILE, xml=THEMES_VULNS_FILE) - options = {} - options[:only_vulnerable_ones] = false - options[:file] = file - options[:vulns_file] = xml - options[:base_url] = "http://localhost" - options[:type] = "themes" + total('themes', file, xml) + end + + def total(type, file, xml) + options = { + type: type, + file: file, + vulns_file: xml, + base_url: 'http://localhost', + only_vulnerable_ones: false + } WpEnumerator.generate_items(options).count end