#!/usr/bin/ruby1.9.1
#-*- coding: utf-8 -*-

require 'rubygems'
require 'bundler'
Bundler.setup

require 'nos_oignons/mailman'
require 'nos_oignons/subscriptions'

LIST = 'ag'

current_emails = NosOignons::Mailman.list_members(LIST)
uptodate_emails = NosOignons::Subscription.all.select(&:up_to_date?).collect(&:email)

NosOignons::Mailman.add_members(LIST, uptodate_emails - current_emails)
NosOignons::Mailman.remove_members(LIST, current_emails - uptodate_emails)
