# Updating the google group importer

**URL:** <https://meta.discourse.org/t/updating-the-google-group-importer/59075>\
**Category:** Development\
**Created:** [2017年三月14日 12:18 UTC](https://meta.discourse.org/t/updating-the-google-group-importer/59075 "2017-03-14T12:18:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pacharanero](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pacharanero/32/500583_2.png) [@pacharanero](https://meta.discourse.org/u/pacharanero)\
**Post date:** [2017年三月14日 12:18 UTC](https://meta.discourse.org/t/updating-the-google-group-importer/59075/1 "2017-03-14T12:18:04Z")

</div>

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](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.

### 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

---

<div class="post-metadata">

**Author:** ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)\
**Post date:** [2017年三月14日 14:46 UTC](https://meta.discourse.org/t/updating-the-google-group-importer/59075/2 "2017-03-14T14:46:54Z")

</div>

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 😉

---

<div class="post-metadata">

**Author:** ![pacharanero](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pacharanero/32/500583_2.png) [@pacharanero](https://meta.discourse.org/u/pacharanero)\
**Post date:** [2017年三月14日 15:09 UTC](https://meta.discourse.org/t/updating-the-google-group-importer/59075/3 "2017-03-14T15:09:11Z")

</div>

Thanks @zogstrip. I’ll do that.

Marcus

---

<div class="post-metadata">

**Author:** ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)\
**Post date:** [2018年十月31日 14:33 UTC](https://meta.discourse.org/t/updating-the-google-group-importer/59075/4 "2018-10-31T14:33:08Z")

</div>

Please see [Migrate a mailing list to Discourse (mbox, Listserv, Google Groups, etc)](https://meta.discourse.org/t/importing-mailing-lists-mbox-listserv-google-groups-emails/79773)
