Updating the google group importer

AI-generated summary

The discussion revolves around updating the Google group importer to work with Discourse. pacharanero has written two iterations of the importer, with the latest available on GitHub. However, it’s currently broken due to updates in Discourse.

The main issue is that the mbox.rb script, which pacharanero is trying to subclass, instantiates and runs itself upon execution, causing problems. pacharanero is seeking advice on how to resolve this, considering either modifying mbox.rb or finding an alternative approach.

zogstrip suggested extracting reusable methods from mbox.rb into a library file, which pacharanero plans to implement. The goal is to create a working importer that can be submitted to Discourse without breaking other importers.

Hi

I have now written 2 iterations of importers for Google Groups into Discourse. The most recent one is here: GitHub - pacharanero/google_group.to_discourse: Import script from a private Google Group into a Discourse forum · GitHub.

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.

problem

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.

I’d be interested in any thoughts, particularly from @erlend_sh (who originally suggested I could submit it to DIscourse) and other Discourse Team @sam @codinghorror

Marcus

I would extract the methods that you want to re-use from the mbox importer and put them in a library file that you use in both importers :wink:

Thanks @zogstrip. I’ll do that.

Marcus