smailer 0.6.2 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b0ad9b68b1053871829e187454142b621a48935f
4
+ data.tar.gz: 5179717f9a0447996510e2f1dff7081b8d601245
5
+ SHA512:
6
+ metadata.gz: 8ec561c47706b8b7271a2b73b4428db6cf3156bca66e93846329a6a0ffa83185fec6f961d7016800cdc6bfdc446fd9f3af17d609c92f14956f61626b869ba3ae
7
+ data.tar.gz: 2abf5eb90fa6042aba5412fe4631568ed27a907d126a358b4ce76f18467dd812281ff70cbe54e99ac23201b62da1517be0d3d937a9f5e52a7d167f1e5eff5ce5
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Intro
4
4
 
5
- This project is a simple mailer for newsletters, which implements simple queue processing, basic campaign management, [VERP support](http://en.wikipedia.org/wiki/Variable_envelope_return_path), bounce processing and auto-unsubscribe of invalid emails and aslo assists you in implementing unsubscribe links in the email messages.
5
+ This project is a simple mailer for newsletters, which implements simple queue processing, basic campaign management, [VERP support](http://en.wikipedia.org/wiki/Variable_envelope_return_path), bounce processing and auto-unsubscribe of invalid emails and also assists you in implementing unsubscribe links in the email messages.
6
6
 
7
7
  It is intended to be used within a Rails project. It has been tested with Rails 3.0.x, Rails 3.1.0 and Rails 2.3.5.
8
8
 
@@ -3,11 +3,17 @@ require "rails/generators/active_record"
3
3
  module Smailer
4
4
  class MigrationGenerator < Rails::Generators::Base
5
5
  include Rails::Generators::Migration
6
- extend ActiveRecord::Generators::Migration
6
+ unless Smailer::Compatibility.rails_4?
7
+ extend ActiveRecord::Generators::Migration
8
+ end
7
9
 
8
10
  desc "Create a migration file with definitions of the tables needed to run Smailer."
9
11
  source_root File.expand_path('../templates', __FILE__)
10
12
 
13
+ def self.next_migration_number(path)
14
+ Time.now.utc.strftime("%Y%m%d%H%M%S")
15
+ end
16
+
11
17
  def generate_migration
12
18
  file_name = 'create_smailer_tables'
13
19
 
@@ -4,8 +4,16 @@ module Smailer
4
4
  Rails::VERSION::MAJOR == 3
5
5
  end
6
6
 
7
+ def self.rails_4?
8
+ Rails::VERSION::MAJOR == 4
9
+ end
10
+
11
+ def self.rails_3_or_4?
12
+ self.rails_3? || self.rails_4?
13
+ end
14
+
7
15
  def self.save_without_validation(object)
8
- rails_3? ? object.save(:validate => false) : object.save(false)
16
+ rails_3_or_4? ? object.save(:validate => false) : object.save(false)
9
17
  end
10
18
  end
11
19
  end
@@ -15,7 +15,9 @@ module Smailer
15
15
  validates_numericality_of :mailing_list_id, :unsubscribe_methods, :only_integer => true, :allow_nil => true
16
16
  validates_length_of :from, :subject, :maximum => 255, :allow_nil => true
17
17
 
18
- attr_accessible :mailing_list_id, :from, :subject, :body_html, :body_text
18
+ unless Smailer::Compatibility.rails_4?
19
+ attr_accessible :mailing_list_id, :from, :subject, :body_html, :body_text
20
+ end
19
21
 
20
22
  def add_unsubscribe_method(method)
21
23
  self.unsubscribe_methods = (self.unsubscribe_methods || 0) | method
@@ -8,7 +8,9 @@ module Smailer
8
8
  validates_uniqueness_of :key
9
9
  validates_length_of :email, :key, :maximum => 255
10
10
 
11
- attr_accessible :email, :key
11
+ unless Smailer::Compatibility.rails_4?
12
+ attr_accessible :email, :key
13
+ end
12
14
 
13
15
  before_validation :set_key
14
16
  before_save :set_key
@@ -7,7 +7,9 @@ module Smailer
7
7
  validates_uniqueness_of :name
8
8
  validates_length_of :name, :maximum => 255
9
9
 
10
- attr_accessible :name
10
+ unless Smailer::Compatibility.rails_4?
11
+ attr_accessible :name
12
+ end
11
13
  end
12
14
  end
13
15
  end
@@ -1,12 +1,18 @@
1
1
  module Smailer
2
2
  module Models
3
3
  class Property < ActiveRecord::Base
4
- set_table_name 'smailer_properties'
4
+ if Smailer::Compatibility.rails_3_or_4?
5
+ self.table_name = 'smailer_properties'
6
+ else
7
+ set_table_name 'smailer_properties'
8
+ end
5
9
 
6
10
  validates_presence_of :name
7
11
  validates_uniqueness_of :name
8
12
 
9
- attr_accessible :name, :value, :notes
13
+ unless Smailer::Compatibility.rails_4?
14
+ attr_accessible :name, :value, :notes
15
+ end
10
16
 
11
17
  @@cache_created_at = Time.now
12
18
 
@@ -11,7 +11,9 @@ module Smailer
11
11
  validates_numericality_of :mail_campaign_id, :retries, :only_integer => true, :allow_nil => true
12
12
  validates_length_of :to, :last_error, :maximum => 255, :allow_nil => true
13
13
 
14
- attr_accessible :mail_campaign_id, :to
14
+ unless Smailer::Compatibility.rails_4?
15
+ attr_accessible :mail_campaign_id, :to
16
+ end
15
17
 
16
18
  delegate :from, :subject, :mailing_list, :to => :mail_campaign, :allow_nil => true
17
19
 
@@ -11,7 +11,7 @@ module Smailer
11
11
  raise "VERP is enabled, but a :return_path_domain option has not been specified or is blank."
12
12
  end
13
13
 
14
- rails_delivery_method = if Compatibility.rails_3?
14
+ rails_delivery_method = if Smailer::Compatibility.rails_3_or_4?
15
15
  method = Rails.configuration.action_mailer.delivery_method
16
16
  [method, Rails.configuration.action_mailer.send("#{method}_settings")]
17
17
  else
@@ -29,18 +29,29 @@ module Smailer
29
29
  results = []
30
30
 
31
31
  # clean up any old locked items
32
- Smailer::Models::QueuedMail.update_all({:locked => false}, ['locked = ? AND locked_at <= ?', true, 1.hour.ago.utc])
32
+ expired_locks_condition = ['locked = ? AND locked_at <= ?', true, 1.hour.ago.utc]
33
+ if Smailer::Compatibility.rails_3_or_4?
34
+ Smailer::Models::QueuedMail.where(expired_locks_condition).update_all(:locked => false)
35
+ else
36
+ Smailer::Models::QueuedMail.update_all({:locked => false}, expired_locks_condition)
37
+ end
33
38
 
34
39
  # load the queue items to process
35
40
  queue_sort_order = 'retries ASC, id ASC'
36
- items_to_process = if Compatibility.rails_3?
41
+ items_to_process = if Smailer::Compatibility.rails_3_or_4?
37
42
  Smailer::Models::QueuedMail.where(:locked => false).order(queue_sort_order).limit(batch_size)
38
43
  else
39
44
  Smailer::Models::QueuedMail.all(:conditions => {:locked => false}, :order => queue_sort_order, :limit => batch_size)
40
45
  end
41
46
 
42
47
  # lock the queue items
43
- Smailer::Models::QueuedMail.update_all({:locked => true, :locked_at => Time.now.utc}, {:id => items_to_process.map(&:id)})
48
+ lock_condition = {:id => items_to_process.map(&:id)}
49
+ lock_update = {:locked => true, :locked_at => Time.now.utc}
50
+ if Smailer::Compatibility.rails_3_or_4?
51
+ Smailer::Models::QueuedMail.where(lock_condition).update_all(lock_update)
52
+ else
53
+ Smailer::Models::QueuedMail.update_all(lock_update, lock_condition)
54
+ end
44
55
 
45
56
  items_to_process.each do |queue_item|
46
57
  # try to send the email
@@ -1,7 +1,7 @@
1
1
  module Smailer
2
2
  MAJOR = 0
3
3
  MINOR = 6
4
- PATCH = 2
4
+ PATCH = 3
5
5
 
6
6
  VERSION = [MAJOR, MINOR, PATCH].join('.')
7
7
  end
metadata CHANGED
@@ -1,49 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smailer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
5
- prerelease:
4
+ version: 0.6.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Dimitar Dimitrov
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-12-13 00:00:00.000000000 Z
11
+ date: 2014-03-22 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
- requirement: &70159511397240 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: 1.0.0
22
20
  type: :development
23
21
  prerelease: false
24
- version_requirements: *70159511397240
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.0
25
27
  - !ruby/object:Gem::Dependency
26
28
  name: mail
27
- requirement: &70159511396580 !ruby/object:Gem::Requirement
28
- none: false
29
+ requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
- - - ~>
31
+ - - "~>"
31
32
  - !ruby/object:Gem::Version
32
33
  version: '2.3'
33
34
  type: :runtime
34
35
  prerelease: false
35
- version_requirements: *70159511396580
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.3'
36
41
  - !ruby/object:Gem::Dependency
37
42
  name: bounce_email
38
- requirement: &70159511395800 !ruby/object:Gem::Requirement
39
- none: false
43
+ requirement: !ruby/object:Gem::Requirement
40
44
  requirements:
41
- - - ~>
45
+ - - "~>"
42
46
  - !ruby/object:Gem::Version
43
47
  version: '0.2'
44
48
  type: :runtime
45
49
  prerelease: false
46
- version_requirements: *70159511395800
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.2'
47
55
  description: A simple mailer for newsletters with basic campaign management, queue
48
56
  and unsubscribe support. To be used within Rails.
49
57
  email:
@@ -52,7 +60,7 @@ executables: []
52
60
  extensions: []
53
61
  extra_rdoc_files: []
54
62
  files:
55
- - .gitignore
63
+ - ".gitignore"
56
64
  - Gemfile
57
65
  - README.md
58
66
  - Rakefile
@@ -80,27 +88,25 @@ files:
80
88
  - smailer.gemspec
81
89
  homepage: http://github.com/mitio/smailer
82
90
  licenses: []
91
+ metadata: {}
83
92
  post_install_message:
84
93
  rdoc_options: []
85
94
  require_paths:
86
95
  - lib
87
96
  required_ruby_version: !ruby/object:Gem::Requirement
88
- none: false
89
97
  requirements:
90
- - - ! '>='
98
+ - - ">="
91
99
  - !ruby/object:Gem::Version
92
100
  version: '0'
93
101
  required_rubygems_version: !ruby/object:Gem::Requirement
94
- none: false
95
102
  requirements:
96
- - - ! '>='
103
+ - - ">="
97
104
  - !ruby/object:Gem::Version
98
105
  version: 1.3.6
99
106
  requirements: []
100
107
  rubyforge_project: smailer
101
- rubygems_version: 1.8.11
108
+ rubygems_version: 2.2.0
102
109
  signing_key:
103
- specification_version: 3
110
+ specification_version: 4
104
111
  summary: A simple newsletter mailer for Rails.
105
112
  test_files: []
106
- has_rdoc: