referthis 0.4.23 → 0.5.34

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  # http://stackoverflow.com/questions/6021372/best-way-to-create-unique-token-in-rails
2
2
  class Mailer < ActionMailer::Base
3
- def send_referral(referral, url, referrer_name, app_name, body)
4
- mail(:to => Referee.find(referral.referee_id).endpoint, :subject => app_name, :body => body + Base64::encode64(referral.id.to_s).chop + '.')
3
+ def send_referral(referral, url, referrer_name, optional)
4
+ mail(:to => Referee.find(referral.referee_id).endpoint, :subject => optional[:app_name], :body => optional[:body] + Base64::encode64(referral.id.to_s).chop + '.')
5
5
  end
6
6
  end
data/lib/referral.rb CHANGED
@@ -11,20 +11,20 @@ class Referral < ActiveRecord::Base
11
11
  referral.save
12
12
  return referral
13
13
  end
14
- def self.generate_referral(endpoints, user_current_id, url, referrer_name, app_name, body)
14
+ def self.generate_referral(endpoints, user_current_id, url, referrer_name, optional)
15
15
  threads = []
16
16
  @user_current_id = user_current_id
17
17
  if endpoints[:phone_number] != ''
18
18
  threads << Thread.new('sms'){
19
19
  phone_number = SMS.sieve(endpoints[:phone_number])
20
- Referee.exists?(:endpoint => phone_number) ? SMS.send_referral(self.construct(Referee.find_by_endpoint(phone_number.to_s).id), url, referrer_name, app_name, body) : SMS.send_referral(self.construct(Referee.construct(phone_number.to_s).id), url, referrer_name, app_name, body)
20
+ Referee.exists?(:endpoint => phone_number) ? SMS.send_referral(self.construct(Referee.find_by_endpoint(phone_number.to_s).id), url, referrer_name, optional) : SMS.send_referral(self.construct(Referee.construct(phone_number.to_s).id), url, referrer_name, optional)
21
21
  }
22
22
  end
23
23
  if endpoints[:email_address] != ''
24
24
  threads << Thread.new('email'){
25
25
  email_address = endpoints[:email_address]
26
26
  begin
27
- Referee.exists?(:endpoint => email_address) ? Mailer.send_referral(self.construct(Referee.find_by_endpoint(email_address).id), url, referrer_name, app_name, body).deliver : Mailer.send_referral(self.construct(Referee.construct(email_address).id), url, referrer_name, app_name, body).deliver
27
+ Referee.exists?(:endpoint => email_address) ? Mailer.send_referral(self.construct(Referee.find_by_endpoint(email_address).id), url, referrer_name, optional).deliver : Mailer.send_referral(self.construct(Referee.construct(email_address).id), url, referrer_name, optional).deliver
28
28
  rescue Net::SMTPSyntaxError
29
29
  puts 'Hello'
30
30
  end
data/lib/referthis.rb CHANGED
@@ -10,7 +10,9 @@ class ReferThis < Referral
10
10
  system('cp -r ' + File.dirname(File.absolute_path(__FILE__)) + '/db/migrate/* ' + "'" + Rails.root.to_s.split('app/').first + "/db/migrate/'")
11
11
  system('rake db:migrate')
12
12
  end
13
- def self.url(endpoints, user_current_id, url, referrer_name, app_name=Rails.application.class.to_s.split('::').first, body=referrer_name + ' has referred you to ' + app_name + '! You might be interested in checking out the following: ' + url + '/')
14
- self.generate_referral(endpoints, user_current_id, url, referrer_name, app_name, body)
13
+ def self.url(endpoints, user_current_id, url, referrer_name, optional = {:app_name=>Rails.application.class.to_s.split('::').first, :body=>referrer_name + ' has referred you to ' + optional[:app_name] + '! You might be interested in checking out the following: ' + url + '/'})
14
+ optional[:body].nil? ? optional[:body] = referrer_name + ' has referred you to ' + optional[:app_name] + '! You might be interested in checking out the following: ' + url + '/' : optional[:body]
15
+ optional[:app_name].nil? ? optional[:app_name] = Rails.application.class.to_s.split('::').first : optional[:app_name]
16
+ self.generate_referral(endpoints, user_current_id, url, referrer_name, optional)
15
17
  end
16
18
  end
data/lib/sms.rb CHANGED
@@ -9,7 +9,7 @@ class SMS
9
9
  def self.sieve(number)
10
10
  return number.to_s.gsub(/\D/, '')
11
11
  end
12
- def self.send_referral(referral, url, referrer_name, app_name, body)
13
- @@account.sms.messages.create(:from => '+18599030353', :to => Referee.find(referral.referee_id).endpoint, :body => body + Base64::encode64(referral.id.to_s).chop + '.')
12
+ def self.send_referral(referral, url, referrer_name, optional)
13
+ @@account.sms.messages.create(:from => '+18599030353', :to => Referee.find(referral.referee_id).endpoint, :body => optional[:body] + Base64::encode64(referral.id.to_s).chop + '.')
14
14
  end
15
15
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: referthis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.23
4
+ version: 0.5.34
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-20 00:00:00.000000000 Z
12
+ date: 2012-07-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: twilio-ruby