Commit a239da1b authored by Lucas Nussbaum's avatar Lucas Nussbaum

Make exec an instance method. There's no reason it should be a class method

parent 1715bf35
......@@ -64,7 +64,7 @@ options = WikiGenerator::parse_options
if (options)
ret = 2
begin
ret = WikiGenerator::exec(generator, options)
ret = generator.exec(options)
rescue MediawikiApi::ApiError => e
puts e, e.backtrace
ret = 3
......
......@@ -68,7 +68,7 @@ options = WikiGenerator::parse_options
if (options)
ret = 2
begin
ret = WikiGenerator::exec(generator, options)
ret = generator.exec(options)
rescue MediawikiApi::ApiError => e
puts e, e.backtrace
ret = 3
......
......@@ -276,7 +276,7 @@ options = WikiGenerator::parse_options
if (options)
ret = 2
begin
ret = WikiGenerator::exec(generator, options)
ret = generator.exec(options)
rescue MediawikiApi::ApiError => e
puts e, e.backtrace
ret = 3
......
......@@ -6,6 +6,8 @@ require "optparse"
require "mediawiki_api"
require "diffy"
require "mw_utils"
require 'date'
require 'pp'
class WikiGenerator
......@@ -140,24 +142,24 @@ class WikiGenerator
end
#Execute actions on generator based on given options
def self.exec(generator, options)
generator.generate_content()
def exec(options)
generate_content()
ret = true
#Login only if we need to
if (options[:diff] || options[:update])
generator.login(options)
login(options)
end
if (options[:diff])
ret &= generator.diff_page if generator.instance_variable_get('@generated_content')
ret &= generator.diff_files if generator.instance_variable_get('@files')
ret &= diff_page if instance_variable_get('@generated_content')
ret &= diff_files if instance_variable_get('@files')
end
if (options[:print])
generator.print
print
end
if (options[:update])
generator.update_page if generator.instance_variable_get('@generated_content')
generator.update_files if generator.instance_variable_get('@files')
update_page if instance_variable_get('@generated_content')
update_files if instance_variable_get('@files')
end
return ret
end
......
......@@ -228,7 +228,7 @@ options = WikiGenerator::parse_options
if (options)
ret = 2
begin
ret = WikiGenerator::exec(generator, options)
ret = generator.exec(options)
rescue MediawikiApi::ApiError => e
puts e, e.backtrace
ret = 3
......
......@@ -270,7 +270,7 @@ if __FILE__ == $0
ret = true
generators = options[:sites].map{ |site| SiteHardwareGenerator.new(site.capitalize + ':Hardware', site) }
generators.each{ |generator|
ret &= WikiGenerator::exec(generator, options)
ret &= generator.exec(options)
}
rescue MediawikiApi::ApiError => e
puts e, e.backtrace
......
......@@ -37,7 +37,7 @@ if (options)
ret = true
generators = options[:sites].map{ |site| SiteNetworkGenerator.new('Generated/' + site.capitalize + 'Network', site) }
generators.each{ |generator|
ret &= WikiGenerator::exec(generator, options)
ret &= generator.exec(options)
}
rescue MediawikiApi::ApiError => e
puts e, e.backtrace
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment