I have now written 2 iterations of importers for Google Groups into Discourse. The most recent one is here: https://github.com/pacharanero/google_group.to_discourse.
It’s broken since some updates to Discourse, so I’m in the process of updating it. In particular I’m hoping with this version to get it good enough that I can submit it to Discourse as a part of Discourse itself, so I want to make it a) run well and b) not to break any other importers.
The require and subclassing lines are thus:
require File.expand_path(File.dirname(__FILE__) + "/mbox.rb") class ImportScripts::GoogleGroups < ImportScripts::Mbox def initialize(google_group_name) ...
I am subclassing the standard Discourse importer script
mbox.rb in order to use the methods it contains.
The last line of
mbox.rb instantiates and runs
ImportScripts::Mbox#perform, which is a problem since the whole thing gets run as soon as Ruby executes the
require. This is before I’ve been able to set any of the environment variables etc, so of course it fails with an error.
I want to be able to subclass
mbox.rb without instantiating it and running #perform (until I’m ready)
Is there any way of doing this? Apologies if this is a bit of a basic/dumb question - I am a very part-time Rubyist.
Or is it better to change
mbox.rb so that it doesn’t instantiate and run itself (the instantiation and running part could be extracted out into another script)? It doesn’t look as though any other scripts are subclassing
mbox.rb or depending on it in any other way, so this is unlikely to break anything else.