Welcome to mirror list, hosted at ThFree Co, Russian Federation.

rake_helpers.rb « lib - github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ea25274b396a07c346c9c2c02ba6caf3028aff95 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#   Copyright (c) 2010, Diaspora Inc.  This file is
#   licensed under the Affero General Public License version 3 or later.  See
#   the COPYRIGHT file.
module RakeHelpers

  def load_yaml

  end

  def process_emails(csv, num_to_process, offset, test=true)
    if RUBY_VERSION.include? "1.8"

       require 'fastercsv'
       backers = FasterCSV.read(csv)
     else
       require 'csv'
       backers = CSV.read(csv)
     end
    puts "DRY RUN" if test
    churn_through = 0
    num_to_process.times do |n|
      if backers[n+offset] == nil
        break
      end
      churn_through = n
      backer_name = backers[n+offset][1].to_s.strip
      backer_email = backers[n+offset][0].to_s.strip
      unless User.find_by_email(backer_email) || User.find_by_invitation_identifier(backer_email)
        puts "sending email to: #{backer_name} #{backer_email}" unless Rails.env == 'test'
        Invitation.create_invitee(:service => 'email', :identifier => backer_email, :name => backer_name ) unless test
      else
        puts "user with the email exists: #{backer_email} ,  #{backer_name} " unless Rails.env == 'test'
      end
    end
    churn_through
  end
end