intentmedia-action_mailer_cache_delivery 0.1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in action_mailer_cache_delivery.gemspec
4
+ gemspec
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 [name of plugin creator]
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,35 @@
1
+ ActionMailerCacheDelivery
2
+ ========================
3
+
4
+ Currently ActionMailer only supports :test, :smtp & :sendmail delivery methods.
5
+ This plugin enhances ActionMailer to support the :cache method, which behaves like
6
+ :test, except that the deliveries are marshalled to a temporary cache file, thus,
7
+ making them available to other processes.
8
+
9
+ This fork integrates with email_spec
10
+
11
+ Installation
12
+ ============
13
+
14
+ #$ cd RAILS_ROOT
15
+ #$ ./script/plugin install git://github.com/ngty/action_mailer_cache_delivery.git
16
+
17
+ Example
18
+ =======
19
+
20
+ In your RAILS_ROOT/config/environments/test.rb, make sure you have the line:
21
+
22
+ config.action_mailer.delivery_method = :cache
23
+
24
+ And that's all. To access the cached deliveries in another process, just do:
25
+
26
+ ActionMailer::Base.cached_deliveries # array of TMail::Mail instances
27
+
28
+
29
+ Credits
30
+ =======
31
+
32
+ Many thanks to langalex, who suggested the birth of this plugin.
33
+
34
+
35
+ Copyright (c) 2009 [Ng Tze Yang, ngty77(at)gmail(dot)com], released under the MIT license
@@ -0,0 +1,23 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+
5
+ desc 'Default: run unit tests.'
6
+ task :default => :test
7
+
8
+ desc 'Test the action_mailer_cache_delivery plugin.'
9
+ Rake::TestTask.new(:test) do |t|
10
+ t.libs << 'lib'
11
+ t.libs << 'test'
12
+ t.pattern = 'test/**/*_test.rb'
13
+ t.verbose = true
14
+ end
15
+
16
+ desc 'Generate documentation for the action_mailer_cache_delivery plugin.'
17
+ Rake::RDocTask.new(:rdoc) do |rdoc|
18
+ rdoc.rdoc_dir = 'rdoc'
19
+ rdoc.title = 'ActionMailerCacheDelivery'
20
+ rdoc.options << '--line-numbers' << '--inline-source'
21
+ rdoc.rdoc_files.include('README')
22
+ rdoc.rdoc_files.include('lib/**/*.rb')
23
+ end
data/TODO ADDED
@@ -0,0 +1 @@
1
+ Write specs for this plugin.
@@ -0,0 +1,7 @@
1
+ author: Ng Tze Yang
2
+ summary: Provides :cache delivery method for ActionMailer
3
+ homepage: http://github.com/ngty/action_mailer_cache_delivery
4
+ plugin: action_mailer_cache_delivery
5
+ license: MIT
6
+ version: 0.1.0
7
+ rails_version: >= 2.3.2
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "action_mailer_cache_delivery/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "intentmedia-action_mailer_cache_delivery"
7
+ s.version = ActionMailerCacheDelivery::VERSION
8
+ s.summary = %q{Gem-ized version of action_mailer_cache_delivery}
9
+ s.description = %q{It's a gem}
10
+ s.authors = "NA"
11
+ s.files = `git ls-files`.split("\n")
12
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
13
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
14
+ s.require_paths = ["lib"]
15
+
16
+ # specify any dependencies here; for example:
17
+ # s.add_development_dependency "rspec"
18
+ # s.add_runtime_dependency "rest-client"
19
+ end
@@ -0,0 +1,29 @@
1
+ require "action_mailer_cache_delivery/version"
2
+ require "action_mailer_cache_delivery/railtie"
3
+
4
+ module ActionMailerCacheDelivery
5
+
6
+ class << self
7
+
8
+ attr_reader :deliveries_cache_path
9
+ def install
10
+ @deliveries_cache_path = File.join(Rails.root,'tmp','cache','action_mailer_cache_deliveries.cache')
11
+
12
+ require File.join(File.dirname(__FILE__), 'action_mailer_cache_delivery', 'action_mailer', 'base')
13
+ require File.join(File.dirname(__FILE__), 'action_mailer_cache_delivery', 'mail', 'cache_delivery')
14
+ ActionMailer::Base.add_delivery_method :cache, Mail::CacheDelivery
15
+
16
+ # Create the cache directory if it doesn't exist
17
+ require 'fileutils'
18
+ cache_dir = File.dirname(deliveries_cache_path)
19
+ FileUtils.mkdir_p(cache_dir) unless File.directory?(cache_dir)
20
+
21
+ # Marshal the empty list of deliveries
22
+ File.open(deliveries_cache_path, 'w') do |f|
23
+ Marshal.dump([], f)
24
+ end
25
+ end
26
+ end
27
+
28
+ end
29
+
@@ -0,0 +1,33 @@
1
+ ActionMailer::Base.class_eval do
2
+
3
+ # Deliver +mail+ using the :cache delivery method.
4
+ # This is called by the ActionMailer#deliver! method.
5
+ def perform_delivery_cache(mail)
6
+ deliveries = self.class.cached_deliveries
7
+ deliveries << mail
8
+
9
+ File.open(ActionMailerCacheDelivery.deliveries_cache_path,'w') do |f|
10
+ Marshal.dump(deliveries, f)
11
+ end
12
+ end
13
+
14
+ # Return the list of cached deliveries, or an empty list if there are none.
15
+ # This is called by email_spec.
16
+ def self.cached_deliveries
17
+ File.open(ActionMailerCacheDelivery.deliveries_cache_path,'r') do |f|
18
+ Marshal.load(f)
19
+ end
20
+ end
21
+
22
+ # Clear the delivery cache of all emails.
23
+ # This is called by email_spec before each scenario.
24
+ def self.clear_cache
25
+ deliveries.clear
26
+
27
+ # Marshal the empty list of deliveries
28
+ File.open(ActionMailerCacheDelivery.deliveries_cache_path, 'w') do |f|
29
+ Marshal.dump(deliveries, f)
30
+ end
31
+ end
32
+
33
+ end
@@ -0,0 +1,31 @@
1
+ # I tryed to use Mail::FileDelivery, but it didn't work
2
+ #
3
+ # CacheDelivery is used to work with email-spec. Put this line in your
4
+ # test environment:
5
+ # config.action_mailer.delivery_method = :cache
6
+ #
7
+ # The code here is borowed from Mail::FileDelivery
8
+ #
9
+ module Mail
10
+ class CacheDelivery
11
+
12
+ def initialize(values)
13
+ self.settings = { :location => './mails' }.merge!(values)
14
+ end
15
+
16
+ attr_accessor :settings
17
+
18
+ def deliver!(mail)
19
+ deliveries = File.open(ActionMailerCacheDelivery.deliveries_cache_path,'r') do |f|
20
+ Marshal.load(f)
21
+ end
22
+
23
+ deliveries << mail
24
+
25
+ File.open(ActionMailerCacheDelivery.deliveries_cache_path,'w') do |f|
26
+ Marshal.dump(deliveries, f)
27
+ end
28
+ end
29
+
30
+ end
31
+ end
@@ -0,0 +1,7 @@
1
+ module ActionMailerCacheDelivery
2
+ class ActionMailerCacheDeliveryRailtie < Rails::Railtie
3
+ initializer "action_mailer_cache_delivery_railtie.configure_rails_initialization" do
4
+ ActionMailerCacheDelivery.install
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ module ActionMailerCacheDelivery
2
+ VERSION = "0.1.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: intentmedia-action_mailer_cache_delivery
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.1.0.1
6
+ platform: ruby
7
+ authors:
8
+ - NA
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-12-20 00:00:00 Z
14
+ dependencies: []
15
+
16
+ description: It's a gem
17
+ email:
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - .gitignore
26
+ - Gemfile
27
+ - MIT-LICENSE
28
+ - README
29
+ - Rakefile
30
+ - TODO
31
+ - about.yml
32
+ - action_mailer_cache_delivery.gemspec
33
+ - lib/action_mailer_cache_delivery.rb
34
+ - lib/action_mailer_cache_delivery/action_mailer/base.rb
35
+ - lib/action_mailer_cache_delivery/mail/cache_delivery.rb
36
+ - lib/action_mailer_cache_delivery/railtie.rb
37
+ - lib/action_mailer_cache_delivery/version.rb
38
+ homepage:
39
+ licenses: []
40
+
41
+ post_install_message:
42
+ rdoc_options: []
43
+
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ none: false
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: "0"
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: "0"
58
+ requirements: []
59
+
60
+ rubyforge_project:
61
+ rubygems_version: 1.8.9
62
+ signing_key:
63
+ specification_version: 3
64
+ summary: Gem-ized version of action_mailer_cache_delivery
65
+ test_files: []
66
+