no_notifier_needed 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/README.rdoc +33 -2
- data/Rakefile +7 -25
- data/VERSION +1 -1
- data/lib/generators/no_notifier_needed/install_generator.rb +35 -0
- data/lib/generators/no_notifier_needed/templates/email_template.rb +11 -0
- data/lib/generators/no_notifier_needed/templates/install.rb +17 -0
- data/lib/generators/no_notifier_needed/templates/jobs/email_processor.rb +12 -0
- data/lib/generators/no_notifier_needed/templates/no_notifier_needed_initalizer.rb +6 -0
- data/lib/tasks/no_notifier_needed_tasks.rake +6 -4
- data/no_notifier_needed.gemspec +9 -4
- metadata +10 -5
data/Gemfile.lock
CHANGED
data/README.rdoc
CHANGED
@@ -1,6 +1,38 @@
|
|
1
1
|
= no_notifier_needed
|
2
2
|
|
3
|
-
|
3
|
+
== To Install
|
4
|
+
rails generate 'no_notifier_needed:install'
|
5
|
+
|
6
|
+
Copies EmailProcessor, no_notifier_needed_initalizer, email_template,
|
7
|
+
and email template migration into your rails application.
|
8
|
+
|
9
|
+
To send a template email:
|
10
|
+
Notifier.send_now(email_template_name, any objects the template expects)
|
11
|
+
|
12
|
+
Example
|
13
|
+
Notifier.send_now("my_email", User.first, City.first, Topic) will translate to ->
|
14
|
+
|
15
|
+
EmailProcessor [{"which_email"=>"lead_intro", "user"=>105391, "city"=>1851, "topic"=>4121}] in Resque
|
16
|
+
|
17
|
+
and translated back to @user, @city, @topic
|
18
|
+
|
19
|
+
@user = User.find(105391)
|
20
|
+
|
21
|
+
@city = City.find(1851)
|
22
|
+
|
23
|
+
@topic = Topic.find(4121)
|
24
|
+
|
25
|
+
in the email template.
|
26
|
+
|
27
|
+
|
28
|
+
Use send_in to specify a delay before sending the email:
|
29
|
+
|
30
|
+
Notifier.send_in(5.days, "my_email", ...)
|
31
|
+
|
32
|
+
Use send_at to specify a time to send the email:
|
33
|
+
|
34
|
+
Notifier.send_at(3.days.from_now, "my_email", ...)
|
35
|
+
|
4
36
|
|
5
37
|
== Contributing to no_notifier_needed
|
6
38
|
|
@@ -10,7 +42,6 @@ Description goes here.
|
|
10
42
|
* Start a feature/bugfix branch.
|
11
43
|
* Commit and push until you are happy with your contribution.
|
12
44
|
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
-
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
45
|
|
15
46
|
== Copyright
|
16
47
|
|
data/Rakefile
CHANGED
@@ -15,6 +15,10 @@ rescue LoadError
|
|
15
15
|
RDoc::Task = Rake::RDocTask
|
16
16
|
end
|
17
17
|
|
18
|
+
|
19
|
+
require 'bundler/gem_helper'
|
20
|
+
Bundler::GemHelper.install_tasks(:name => 'no_notifier_needed')
|
21
|
+
|
18
22
|
require 'metric_fu'
|
19
23
|
MetricFu::Configuration.run do |config|
|
20
24
|
config.rcov[:rcov_opts] << "-Itest" # Needed to find test_helper
|
@@ -41,28 +45,14 @@ end
|
|
41
45
|
|
42
46
|
task :default => :test
|
43
47
|
|
44
|
-
=begin
|
45
|
-
|
46
|
-
require 'rubygems'
|
47
|
-
require 'bundler'
|
48
|
-
begin
|
49
|
-
Bundler.setup(:default, :development)
|
50
|
-
rescue Bundler::BundlerError => e
|
51
|
-
$stderr.puts e.message
|
52
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
53
|
-
exit e.status_code
|
54
|
-
end
|
55
|
-
require 'rake'
|
56
|
-
=end
|
57
|
-
|
58
48
|
require 'jeweler'
|
59
49
|
Jeweler::Tasks.new do |gem|
|
60
50
|
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
61
51
|
gem.name = "no_notifier_needed"
|
62
52
|
gem.homepage = "http://github.com/Blue-Dog-Archolit/no_notifier_needed"
|
63
53
|
gem.license = "MIT"
|
64
|
-
gem.summary = %Q{A Gem used to
|
65
|
-
gem.description = %Q{A work in progress}
|
54
|
+
gem.summary = %Q{A Gem used to remove ActionMailer::Base class and and provide Templates}
|
55
|
+
gem.description = %Q{A work in progress: Replace ActionMailer::Base class redundency. Temlating using haml or erb. Installing not working correctly yet.}
|
66
56
|
gem.email = "Blue.Dog.Archolite@gmail.com"
|
67
57
|
gem.authors = ["Robert R. Meyer"]
|
68
58
|
# dependencies defined in Gemfile
|
@@ -78,13 +68,5 @@ Rake::TestTask.new(:test) do |test|
|
|
78
68
|
end
|
79
69
|
|
80
70
|
task :default => :test
|
71
|
+
#!/usr/bin/env rake
|
81
72
|
|
82
|
-
require 'rdoc/task'
|
83
|
-
Rake::RDocTask.new do |rdoc|
|
84
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
85
|
-
|
86
|
-
rdoc.rdoc_dir = 'rdoc'
|
87
|
-
rdoc.title = "no_notifier_needed #{version}"
|
88
|
-
rdoc.rdoc_files.include('README*')
|
89
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
90
|
-
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.0.0
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require 'rails/generators/migration'
|
3
|
+
require 'active_record'
|
4
|
+
require 'rails/generators/active_record'
|
5
|
+
|
6
|
+
module NoNotifierNeeded
|
7
|
+
class InstallGenerator < Rails::Generators::Base
|
8
|
+
include Rails::Generators::Migration
|
9
|
+
source_root File.expand_path(File.join(File.dirname(__FILE__), "templates"))
|
10
|
+
|
11
|
+
def copy_migration_and_config
|
12
|
+
|
13
|
+
#Config file
|
14
|
+
copy_file 'no_notifier_needed_initalizer.rb', 'config/initializers/no_notifier_needed_initalizer.rb'
|
15
|
+
|
16
|
+
#Resque workers
|
17
|
+
copy_file "jobs/email_processor.rb", "app/jobs/email_processor.rb"
|
18
|
+
|
19
|
+
#Active Record File
|
20
|
+
copy_file "email_template.rb", "app/models/email_template.rb"
|
21
|
+
|
22
|
+
#create migration
|
23
|
+
migration_template 'install.rb', 'db/migrate/install_acts_as_no_notifier_needed.rb'
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.next_migration_number(dirname)
|
27
|
+
next_migration_number = current_migration_number(dirname) + 1
|
28
|
+
if ActiveRecord::Base.timestamped_migrations
|
29
|
+
[Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max
|
30
|
+
else
|
31
|
+
"%.3d" % next_migration_number
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class EmailTemplate < ActiveRecord::Base
|
2
|
+
before_save :clean_inputs
|
3
|
+
|
4
|
+
attr_accessible :body, :subject, :name, :template_type, :sent_to, :when_sent,
|
5
|
+
:email_template_comments_attributes, :from_name, :from_email, :reply_to
|
6
|
+
|
7
|
+
def clean_inputs
|
8
|
+
body.strip!
|
9
|
+
subject.strip!
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class <%= migration_class_name %> < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :email_templates do |t|
|
4
|
+
t.timestamps
|
5
|
+
t.string :from_email
|
6
|
+
t.string :from_name
|
7
|
+
t.string :bcc
|
8
|
+
t.string :reply_to
|
9
|
+
t.string :body
|
10
|
+
t.string :template_type
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def down
|
15
|
+
drop_table :email_templates
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class EmailProcessor
|
2
|
+
@retry_limit = 1
|
3
|
+
@retry_delay = 120
|
4
|
+
@queue = :no_notifier_needed
|
5
|
+
|
6
|
+
def self.perform(args)
|
7
|
+
exec_me = args["which_email"].downcase.to_sym
|
8
|
+
raise ArgumentError.new("No email specified to send. MCP needs your memory. Program deleted") unless exec_me
|
9
|
+
|
10
|
+
Notifier.mcp(exec_me, args).deliver
|
11
|
+
end
|
12
|
+
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
namespace :no_notifier_needed do
|
2
|
+
desc "install the default files and migration"
|
3
|
+
task :install do
|
4
|
+
load File.expand_path(File.join(File.dirname(__FILE__), "..", "generators", "install_generator.rb"))
|
5
|
+
end
|
6
|
+
end
|
data/no_notifier_needed.gemspec
CHANGED
@@ -5,12 +5,12 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "no_notifier_needed"
|
8
|
-
s.version = "
|
8
|
+
s.version = "2.0.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Robert R. Meyer"]
|
12
|
-
s.date = "2013-01-
|
13
|
-
s.description = "A work in progress"
|
12
|
+
s.date = "2013-01-28"
|
13
|
+
s.description = "A work in progress: Replace ActionMailer::Base class redundency. Temlating using haml or erb. Installing not working correctly yet."
|
14
14
|
s.email = "Blue.Dog.Archolite@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"README.css",
|
@@ -27,6 +27,11 @@ Gem::Specification.new do |s|
|
|
27
27
|
"VERSION",
|
28
28
|
"initializers/hotpatches/subclasses.rb",
|
29
29
|
"initializers/notifier.rb",
|
30
|
+
"lib/generators/no_notifier_needed/install_generator.rb",
|
31
|
+
"lib/generators/no_notifier_needed/templates/email_template.rb",
|
32
|
+
"lib/generators/no_notifier_needed/templates/install.rb",
|
33
|
+
"lib/generators/no_notifier_needed/templates/jobs/email_processor.rb",
|
34
|
+
"lib/generators/no_notifier_needed/templates/no_notifier_needed_initalizer.rb",
|
30
35
|
"lib/no_notifier_needed.rb",
|
31
36
|
"lib/no_notifier_needed/config.rb",
|
32
37
|
"lib/no_notifier_needed/railtie.rb",
|
@@ -81,7 +86,7 @@ Gem::Specification.new do |s|
|
|
81
86
|
s.licenses = ["MIT"]
|
82
87
|
s.require_paths = ["lib"]
|
83
88
|
s.rubygems_version = "1.8.24"
|
84
|
-
s.summary = "A Gem used to
|
89
|
+
s.summary = "A Gem used to remove ActionMailer::Base class and and provide Templates"
|
85
90
|
|
86
91
|
if s.respond_to? :specification_version then
|
87
92
|
s.specification_version = 3
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: no_notifier_needed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version:
|
5
|
+
version: 2.0.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Robert R. Meyer
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2013-01-
|
13
|
+
date: 2013-01-28 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: haml
|
@@ -122,7 +122,7 @@ dependencies:
|
|
122
122
|
type: :development
|
123
123
|
prerelease: false
|
124
124
|
version_requirements: *id010
|
125
|
-
description: A work in progress
|
125
|
+
description: "A work in progress: Replace ActionMailer::Base class redundency. Temlating using haml or erb. Installing not working correctly yet."
|
126
126
|
email: Blue.Dog.Archolite@gmail.com
|
127
127
|
executables: []
|
128
128
|
|
@@ -142,6 +142,11 @@ files:
|
|
142
142
|
- VERSION
|
143
143
|
- initializers/hotpatches/subclasses.rb
|
144
144
|
- initializers/notifier.rb
|
145
|
+
- lib/generators/no_notifier_needed/install_generator.rb
|
146
|
+
- lib/generators/no_notifier_needed/templates/email_template.rb
|
147
|
+
- lib/generators/no_notifier_needed/templates/install.rb
|
148
|
+
- lib/generators/no_notifier_needed/templates/jobs/email_processor.rb
|
149
|
+
- lib/generators/no_notifier_needed/templates/no_notifier_needed_initalizer.rb
|
145
150
|
- lib/no_notifier_needed.rb
|
146
151
|
- lib/no_notifier_needed/config.rb
|
147
152
|
- lib/no_notifier_needed/railtie.rb
|
@@ -204,7 +209,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
204
209
|
requirements:
|
205
210
|
- - ">="
|
206
211
|
- !ruby/object:Gem::Version
|
207
|
-
hash:
|
212
|
+
hash: -254889247369949991
|
208
213
|
segments:
|
209
214
|
- 0
|
210
215
|
version: "0"
|
@@ -220,6 +225,6 @@ rubyforge_project:
|
|
220
225
|
rubygems_version: 1.8.24
|
221
226
|
signing_key:
|
222
227
|
specification_version: 3
|
223
|
-
summary: A Gem used to
|
228
|
+
summary: A Gem used to remove ActionMailer::Base class and and provide Templates
|
224
229
|
test_files: []
|
225
230
|
|