rails_mail_preview 0.0.4
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.
- data/.gitignore +5 -0
- data/Gemfile +8 -0
- data/README.rdoc +8 -0
- data/Rakefile +15 -0
- data/lib/rails_mail_preview.rb +4 -0
- data/lib/rails_mail_preview/preview.rb +25 -0
- data/lib/rails_mail_preview/version.rb +3 -0
- data/lib/railtie.rb +14 -0
- data/rails_mail_preview.gemspec +23 -0
- data/spec/preview_spec.rb +47 -0
- data/spec/spec_helper.rb +9 -0
- metadata +92 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
== Rails Mail Preview
|
2
|
+
|
3
|
+
A Rails 3 plugin gem to intercept emails being sent and send a NSDistributedNotification so other Cocoa based apps can listen for the notification.
|
4
|
+
|
5
|
+
=== Usage
|
6
|
+
|
7
|
+
The only known app that listens for these notifications is called "RailsMailPreview" which I also wrote.
|
8
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
|
3
|
+
|
4
|
+
require 'rspec/core'
|
5
|
+
require 'rspec/core/rake_task'
|
6
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
7
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
8
|
+
end
|
9
|
+
|
10
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
11
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
12
|
+
spec.rcov = true
|
13
|
+
end
|
14
|
+
|
15
|
+
task :default => :spec
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'action_view'
|
2
|
+
require 'active_support/concern'
|
3
|
+
|
4
|
+
module RailsMailPreview
|
5
|
+
module Preview
|
6
|
+
module Glue
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
|
9
|
+
included do |sender|
|
10
|
+
sender.class_eval do
|
11
|
+
alias_method :orig_mail, :mail
|
12
|
+
def mail(headers, &block)
|
13
|
+
m = orig_mail(headers, &block)
|
14
|
+
if m.class.to_s == "Mail::Message"
|
15
|
+
notification = ::FBDistributedNotification.new
|
16
|
+
notification.postNotificationName("RailsMailPreview.email", object: m.encoded.to_lf)
|
17
|
+
end
|
18
|
+
m
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end # Glue
|
24
|
+
end # Preview
|
25
|
+
end
|
data/lib/railtie.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rails_mail_preview'
|
2
|
+
require 'rails'
|
3
|
+
|
4
|
+
module RailsMailPreview
|
5
|
+
class Railtie < ::Rails::Railtie
|
6
|
+
|
7
|
+
initializer 'rails_mail_preview.insert_into_action_mailer' do
|
8
|
+
ActiveSupport.on_load :action_mailer do
|
9
|
+
ActionMailer::Base.send :include, RailsMailPreview::Preview::Glue
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "rails_mail_preview/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "rails_mail_preview"
|
7
|
+
s.version = RailsMailPreview::VERSION
|
8
|
+
s.authors = ["Fernando Barajas"]
|
9
|
+
s.email = ["fernyb@fernyb.net"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{A Rails plugin gem to intercept emails in development and preview them in RailsMailPreview.}
|
12
|
+
s.description = %q{A Rails plugin gem to intercept emails in development and preview them in RailsMailPreview to get an idea of what it will look like when it's sent in production.}
|
13
|
+
s.date = "2012-05-11"
|
14
|
+
|
15
|
+
s.rubyforge_project = "rails_mail_preview"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
s.add_dependency('FBDistributedNotification', '0.0.1')
|
22
|
+
s.add_dependency('rails', '>= 3.0.0')
|
23
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe RailsMailPreview::Preview::Glue do
|
4
|
+
before do
|
5
|
+
mailer = Class.new do
|
6
|
+
class << self
|
7
|
+
attr_accessor :delivery_method
|
8
|
+
end
|
9
|
+
|
10
|
+
def mail(headers, &block)
|
11
|
+
true
|
12
|
+
end
|
13
|
+
end
|
14
|
+
mailer.send(:include, RailsMailPreview::Preview::Glue)
|
15
|
+
|
16
|
+
@mailer = mailer.new
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should return true" do
|
20
|
+
@mailer.mail("hello").should be_true
|
21
|
+
end
|
22
|
+
|
23
|
+
let :message do
|
24
|
+
message = Struct.new(:class).new("Mail::Message")
|
25
|
+
message.stub(:to_lf).and_return("mail message")
|
26
|
+
message.stub(:encoded).and_return(message)
|
27
|
+
message
|
28
|
+
end
|
29
|
+
|
30
|
+
it "sends postNotificationName" do
|
31
|
+
notify = mock("FBDistributedNotification")
|
32
|
+
notify.should_receive(:postNotificationName).with("RailsMailPreview.email", object: "mail message")
|
33
|
+
|
34
|
+
notification = FBDistributedNotification.stub(:new).and_return(notify)
|
35
|
+
|
36
|
+
@mailer.stub(:orig_mail).and_return(message)
|
37
|
+
@mailer.mail("headers").should be_true
|
38
|
+
end
|
39
|
+
|
40
|
+
it "does not sends postNotificationName" do
|
41
|
+
FBDistributedNotification.should_not_receive(:new)
|
42
|
+
message.stub(:class).and_return("NotMessage")
|
43
|
+
|
44
|
+
@mailer.stub(:orig_mail).and_return(message)
|
45
|
+
@mailer.mail("headers").should be_true
|
46
|
+
end
|
47
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rails_mail_preview
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Fernando Barajas
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-05-11 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: FBDistributedNotification
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - '='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.0.1
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - '='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.0.1
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rails
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 3.0.0
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 3.0.0
|
46
|
+
description: A Rails plugin gem to intercept emails in development and preview them
|
47
|
+
in RailsMailPreview to get an idea of what it will look like when it's sent in production.
|
48
|
+
email:
|
49
|
+
- fernyb@fernyb.net
|
50
|
+
executables: []
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- .gitignore
|
55
|
+
- Gemfile
|
56
|
+
- README.rdoc
|
57
|
+
- Rakefile
|
58
|
+
- lib/rails_mail_preview.rb
|
59
|
+
- lib/rails_mail_preview/preview.rb
|
60
|
+
- lib/rails_mail_preview/version.rb
|
61
|
+
- lib/railtie.rb
|
62
|
+
- rails_mail_preview.gemspec
|
63
|
+
- spec/preview_spec.rb
|
64
|
+
- spec/spec_helper.rb
|
65
|
+
homepage: ''
|
66
|
+
licenses: []
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options: []
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
none: false
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
requirements: []
|
84
|
+
rubyforge_project: rails_mail_preview
|
85
|
+
rubygems_version: 1.8.24
|
86
|
+
signing_key:
|
87
|
+
specification_version: 3
|
88
|
+
summary: A Rails plugin gem to intercept emails in development and preview them in
|
89
|
+
RailsMailPreview.
|
90
|
+
test_files:
|
91
|
+
- spec/preview_spec.rb
|
92
|
+
- spec/spec_helper.rb
|