litmus_mailer 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use --create 1.9.3-preview1@litmus_mailer_gem
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'litmus', :git => 'git://github.com/logankoester/litmus.git'
4
+ gem 'actionmailer'
5
+
6
+ group :development do
7
+ gem "rspec", "~> 2.3.0"
8
+ gem "yard", "~> 0.6.0"
9
+ gem "bundler", "~> 1.0.0"
10
+ gem "jeweler", "~> 1.6.4"
11
+ gem "rcov", ">= 0"
12
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,91 @@
1
+ GIT
2
+ remote: git://github.com/logankoester/litmus.git
3
+ revision: 282ccc0e8f3a8cf3bc191c03cc0626c52eebc775
4
+ specs:
5
+ litmus (0.1.0)
6
+ httparty (>= 0.6.1)
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ actionmailer (3.1.0)
12
+ actionpack (= 3.1.0)
13
+ mail (~> 2.3.0)
14
+ actionpack (3.1.0)
15
+ activemodel (= 3.1.0)
16
+ activesupport (= 3.1.0)
17
+ builder (~> 3.0.0)
18
+ erubis (~> 2.7.0)
19
+ i18n (~> 0.6)
20
+ rack (~> 1.3.2)
21
+ rack-cache (~> 1.0.3)
22
+ rack-mount (~> 0.8.2)
23
+ rack-test (~> 0.6.1)
24
+ sprockets (~> 2.0.0)
25
+ activemodel (3.1.0)
26
+ activesupport (= 3.1.0)
27
+ bcrypt-ruby (~> 3.0.0)
28
+ builder (~> 3.0.0)
29
+ i18n (~> 0.6)
30
+ activesupport (3.1.0)
31
+ multi_json (~> 1.0)
32
+ bcrypt-ruby (3.0.1)
33
+ builder (3.0.0)
34
+ diff-lcs (1.1.3)
35
+ erubis (2.7.0)
36
+ git (1.2.5)
37
+ hike (1.2.1)
38
+ httparty (0.8.0)
39
+ multi_json
40
+ multi_xml
41
+ i18n (0.6.0)
42
+ jeweler (1.6.4)
43
+ bundler (~> 1.0)
44
+ git (>= 1.2.5)
45
+ rake
46
+ mail (2.3.0)
47
+ i18n (>= 0.4.0)
48
+ mime-types (~> 1.16)
49
+ treetop (~> 1.4.8)
50
+ mime-types (1.16)
51
+ multi_json (1.0.3)
52
+ multi_xml (0.4.1)
53
+ polyglot (0.3.2)
54
+ rack (1.3.3)
55
+ rack-cache (1.0.3)
56
+ rack (>= 0.4)
57
+ rack-mount (0.8.3)
58
+ rack (>= 1.0.0)
59
+ rack-test (0.6.1)
60
+ rack (>= 1.0)
61
+ rake (0.9.2)
62
+ rcov (0.9.10)
63
+ rspec (2.3.0)
64
+ rspec-core (~> 2.3.0)
65
+ rspec-expectations (~> 2.3.0)
66
+ rspec-mocks (~> 2.3.0)
67
+ rspec-core (2.3.1)
68
+ rspec-expectations (2.3.0)
69
+ diff-lcs (~> 1.1.2)
70
+ rspec-mocks (2.3.0)
71
+ sprockets (2.0.0)
72
+ hike (~> 1.2)
73
+ rack (~> 1.0)
74
+ tilt (~> 1.1, != 1.3.0)
75
+ tilt (1.3.3)
76
+ treetop (1.4.10)
77
+ polyglot
78
+ polyglot (>= 0.3.1)
79
+ yard (0.6.8)
80
+
81
+ PLATFORMS
82
+ ruby
83
+
84
+ DEPENDENCIES
85
+ actionmailer
86
+ bundler (~> 1.0.0)
87
+ jeweler (~> 1.6.4)
88
+ litmus!
89
+ rcov
90
+ rspec (~> 2.3.0)
91
+ yard (~> 0.6.0)
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Logan Koester
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.rdoc ADDED
@@ -0,0 +1,47 @@
1
+ = Litmus Mailer
2
+
3
+ Litmus Mailer adds an ActionMailer observer to update your Litmus tests
4
+ each time an email is delivered from development.
5
+
6
+ Now you have no excuse for not knowing what your emails look like.
7
+
8
+ == Requirements
9
+
10
+ * Ruby 1.9.2+
11
+ * Rails 3.0+
12
+
13
+ == Installation
14
+
15
+ In your Gemfile, add
16
+
17
+ group :development do
18
+ gem 'litmus_mailer'
19
+ end
20
+
21
+ Now create a file at `app/initializers/litmus_mailer.rb`
22
+
23
+ if Rails.env == 'development'
24
+ LitmusMailer::Config.subdomain = 'your_litmus_subdomain'
25
+ LitmusMailer::Config.username = 'your_listmus_username'
26
+ LitmusMailer::Config.password = 'your_listmus_password'
27
+ LitmusMailer::Config.test_name_prefix = 'MyApplication-'
28
+ end
29
+
30
+ You're done! A new Litmus test will be created for every action of every
31
+ mailer, every time you deliver an email from development.
32
+
33
+ == Contributing to litmus_mailer
34
+
35
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
36
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
37
+ * Fork the project
38
+ * Start a feature/bugfix branch
39
+ * Commit and push until you are happy with your contribution
40
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
41
+ * 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.
42
+
43
+ == Copyright
44
+
45
+ Copyright (c) 2011 Logan Koester. See LICENSE.txt for
46
+ further details.
47
+
data/Rakefile ADDED
@@ -0,0 +1,42 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "litmus_mailer"
18
+ gem.homepage = "http://github.com/logankoester/litmus_mailer"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Litmus Mailer adds an ActionMailer observer to update your Litmus tests each time an email is delivered from development.}
21
+ gem.description = gem.summary
22
+ gem.email = "logan@logankoester.com"
23
+ gem.authors = ["Logan Koester"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
35
+ spec.pattern = 'spec/**/*_spec.rb'
36
+ spec.rcov = true
37
+ end
38
+
39
+ task :default => :spec
40
+
41
+ require 'yard'
42
+ YARD::Rake::YardocTask.new
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,27 @@
1
+ module LitmusMailer
2
+ class MailObserver
3
+ class << self
4
+
5
+ def delivered_email(mail)
6
+ Litmus::Base.new( Config.subdomain, Config.username, Config.password)
7
+
8
+ # We can't add new versions through the API, and smtp settings are
9
+ # rarely useable in development environments. For now, let's just
10
+ # delete the pre-existing version to keep things from getting unweildy.
11
+ if existing_test = Litmus::Test.find_by_name(mail.litmus_test)
12
+ Litmus::EmailTest.destroy(existing_test['id'])
13
+ Rails.logger.debug "Deleting Litmus test #{existing_test['id']} (#{existing_test['name']})"
14
+ end
15
+
16
+ new_test = Litmus::EmailTest.create({
17
+ :subject => mail.subject,
18
+ :body => mail.parts.last.body # Note that only the last part is sent
19
+ }, mail.litmus_test)
20
+
21
+ Rails.logger.debug "Created new Litmus test #{new_test['id']} (#{new_test['name']})"
22
+ new_test
23
+ end
24
+
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,8 @@
1
+ module LitmusMailer
2
+ class Config
3
+ class << self
4
+ attr_accessor :subdomain, :username, :password, :test_name_prefix
5
+ LitmusMailer::Config.test_name_prefix = Rails.application.class.parent
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,23 @@
1
+ require 'rubygems'
2
+ require 'litmus'
3
+ require 'action_mailer'
4
+
5
+ require File.join( File.dirname(__FILE__), 'litmus_mailer', 'settings' )
6
+ require File.join( File.dirname(__FILE__), 'litmus_mailer', 'mail_observer' )
7
+
8
+ module ActionMailer
9
+ class Base
10
+ alias :mail_without_litmus :mail
11
+
12
+ def mail(headers={}, &block)
13
+ result = mail_without_litmus(headers, &block)
14
+ mailer = self.class.name.to_s
15
+ action = caller[0][/`.*'/][1..-2].sub('block in ', '').to_s
16
+ result.class.instance_eval do
17
+ define_method(:litmus_test) { "#{LitmusMailer::Config.test_name_prefix}#{mailer}-#{action}" }
18
+ end
19
+ end
20
+ end
21
+ end
22
+
23
+ ActionMailer::Base.register_observer(LitmusMailer::MailObserver)
@@ -0,0 +1,72 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{litmus_mailer}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = [%q{Logan Koester}]
12
+ s.date = %q{2011-09-28}
13
+ s.description = %q{Litmus Mailer adds an ActionMailer observer to update your Litmus tests each time an email is delivered from development.}
14
+ s.email = %q{logan@logankoester.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rspec",
22
+ ".rvmrc",
23
+ "Gemfile",
24
+ "Gemfile.lock",
25
+ "LICENSE.txt",
26
+ "README.rdoc",
27
+ "Rakefile",
28
+ "VERSION",
29
+ "lib/litmus_mailer.rb",
30
+ "lib/litmus_mailer/mail_observer.rb",
31
+ "lib/litmus_mailer/settings.rb",
32
+ "litmus_mailer.gemspec",
33
+ "spec/litmus_mailer_spec.rb",
34
+ "spec/spec_helper.rb"
35
+ ]
36
+ s.homepage = %q{http://github.com/logankoester/litmus_mailer}
37
+ s.licenses = [%q{MIT}]
38
+ s.require_paths = [%q{lib}]
39
+ s.rubygems_version = %q{1.8.6.1}
40
+ s.summary = %q{Litmus Mailer adds an ActionMailer observer to update your Litmus tests each time an email is delivered from development.}
41
+
42
+ if s.respond_to? :specification_version then
43
+ s.specification_version = 3
44
+
45
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
46
+ s.add_runtime_dependency(%q<litmus>, [">= 0"])
47
+ s.add_runtime_dependency(%q<actionmailer>, [">= 0"])
48
+ s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
49
+ s.add_development_dependency(%q<yard>, ["~> 0.6.0"])
50
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
51
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
52
+ s.add_development_dependency(%q<rcov>, [">= 0"])
53
+ else
54
+ s.add_dependency(%q<litmus>, [">= 0"])
55
+ s.add_dependency(%q<actionmailer>, [">= 0"])
56
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
57
+ s.add_dependency(%q<yard>, ["~> 0.6.0"])
58
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
59
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
60
+ s.add_dependency(%q<rcov>, [">= 0"])
61
+ end
62
+ else
63
+ s.add_dependency(%q<litmus>, [">= 0"])
64
+ s.add_dependency(%q<actionmailer>, [">= 0"])
65
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
66
+ s.add_dependency(%q<yard>, ["~> 0.6.0"])
67
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
68
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
69
+ s.add_dependency(%q<rcov>, [">= 0"])
70
+ end
71
+ end
72
+
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "LitmusMailer" do
4
+ it "fails" do
5
+ fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'litmus_mailer'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
metadata ADDED
@@ -0,0 +1,144 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: litmus_mailer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Logan Koester
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-09-28 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: litmus
16
+ requirement: &10437640 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *10437640
25
+ - !ruby/object:Gem::Dependency
26
+ name: actionmailer
27
+ requirement: &10454500 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *10454500
36
+ - !ruby/object:Gem::Dependency
37
+ name: rspec
38
+ requirement: &10447180 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 2.3.0
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *10447180
47
+ - !ruby/object:Gem::Dependency
48
+ name: yard
49
+ requirement: &10470420 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 0.6.0
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *10470420
58
+ - !ruby/object:Gem::Dependency
59
+ name: bundler
60
+ requirement: &10468260 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: 1.0.0
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *10468260
69
+ - !ruby/object:Gem::Dependency
70
+ name: jeweler
71
+ requirement: &10464400 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ version: 1.6.4
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *10464400
80
+ - !ruby/object:Gem::Dependency
81
+ name: rcov
82
+ requirement: &10479120 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *10479120
91
+ description: Litmus Mailer adds an ActionMailer observer to update your Litmus tests
92
+ each time an email is delivered from development.
93
+ email: logan@logankoester.com
94
+ executables: []
95
+ extensions: []
96
+ extra_rdoc_files:
97
+ - LICENSE.txt
98
+ - README.rdoc
99
+ files:
100
+ - .document
101
+ - .rspec
102
+ - .rvmrc
103
+ - Gemfile
104
+ - Gemfile.lock
105
+ - LICENSE.txt
106
+ - README.rdoc
107
+ - Rakefile
108
+ - VERSION
109
+ - lib/litmus_mailer.rb
110
+ - lib/litmus_mailer/mail_observer.rb
111
+ - lib/litmus_mailer/settings.rb
112
+ - litmus_mailer.gemspec
113
+ - spec/litmus_mailer_spec.rb
114
+ - spec/spec_helper.rb
115
+ homepage: http://github.com/logankoester/litmus_mailer
116
+ licenses:
117
+ - MIT
118
+ post_install_message:
119
+ rdoc_options: []
120
+ require_paths:
121
+ - lib
122
+ required_ruby_version: !ruby/object:Gem::Requirement
123
+ none: false
124
+ requirements:
125
+ - - ! '>='
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ segments:
129
+ - 0
130
+ hash: 1260189043938000973
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ none: false
133
+ requirements:
134
+ - - ! '>='
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ requirements: []
138
+ rubyforge_project:
139
+ rubygems_version: 1.8.6.1
140
+ signing_key:
141
+ specification_version: 3
142
+ summary: Litmus Mailer adds an ActionMailer observer to update your Litmus tests each
143
+ time an email is delivered from development.
144
+ test_files: []