chimpster-rails 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
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
6
+ .rake_tasks
7
+ .bundle
data/CHANGELOG.rdoc ADDED
File without changes
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ group :test do
6
+ gem "ruby-debug", :platforms => [:ruby_18]
7
+ gem "ruby-debug19", :platforms => [:ruby_19]
8
+ gem "rspec"
9
+ gem "jeweler"
10
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,48 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ postmark-rails (0.4.0)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ archive-tar-minitar (0.5.2)
10
+ columnize (0.3.1)
11
+ gemcutter (0.6.1)
12
+ git (1.2.5)
13
+ jeweler (1.4.0)
14
+ gemcutter (>= 0.1.0)
15
+ git (>= 1.2.5)
16
+ rubyforge (>= 2.0.0)
17
+ json_pure (1.4.6)
18
+ linecache (0.43)
19
+ linecache19 (0.5.11)
20
+ ruby_core_source (>= 0.1.4)
21
+ rspec (1.3.0)
22
+ ruby-debug (0.10.3)
23
+ columnize (>= 0.1)
24
+ ruby-debug-base (~> 0.10.3.0)
25
+ ruby-debug-base (0.10.3)
26
+ linecache (>= 0.3)
27
+ ruby-debug-base19 (0.11.24)
28
+ columnize (>= 0.3.1)
29
+ linecache19 (>= 0.5.11)
30
+ ruby_core_source (>= 0.1.4)
31
+ ruby-debug19 (0.11.6)
32
+ columnize (>= 0.3.1)
33
+ linecache19 (>= 0.5.11)
34
+ ruby-debug-base19 (>= 0.11.19)
35
+ ruby_core_source (0.1.4)
36
+ archive-tar-minitar (>= 0.5.2)
37
+ rubyforge (2.0.4)
38
+ json_pure (>= 1.1.7)
39
+
40
+ PLATFORMS
41
+ ruby
42
+
43
+ DEPENDENCIES
44
+ jeweler
45
+ postmark-rails!
46
+ rspec
47
+ ruby-debug
48
+ ruby-debug19
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Michael Hart
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,89 @@
1
+ = postmark-rails gem
2
+
3
+ The Chimpster Rails Gem is a drop-in plug-in for ActionMailer to send emails via ses through MailChimp
4
+ == Supported Rails Versions
5
+
6
+
7
+ * 3.0
8
+
9
+ == Install
10
+
11
+ sudo gem install chimpster-rails
12
+
13
+ == Requirements
14
+
15
+ * "chimpster" gem version 0.1 and higher is required.
16
+ * You will also need a MailChimp account, server and sender signature set up to use it.
17
+
18
+ == Configuring your Rails application
19
+
20
+ === Rails 3
21
+
22
+ Add this to your Gemfile: (change version numbers if needed)
23
+
24
+ gem 'chimpster-rails', '0.1.0'
25
+
26
+ Don't forget to run "bundle install" command every time you change something in the Gemfile.
27
+
28
+ Add this to your config/application.rb:
29
+
30
+ config.action_mailer.delivery_method = :chimpster
31
+ config.action_mailer.chimpster_settings = { :api_key => "your-api-key" }
32
+
33
+ === Rails 2
34
+
35
+ Add this to config/environment.rb:
36
+
37
+ Rails::Initializer.run do |config|
38
+
39
+ ...
40
+
41
+ config.gem 'chimpster-rails'
42
+ require 'chimpster-rails'
43
+
44
+ config.action_mailer.chimpster_api_key = "your-api-key"
45
+ config.action_mailer.delivery_method = :chimpster
46
+
47
+ ...
48
+
49
+ end
50
+
51
+
52
+ === Rails 3
53
+
54
+ class TestMailer < ActionMailer::Base
55
+
56
+ def tagged_message
57
+ mail(
58
+ :subject => 'hello',
59
+ :to => 'sheldon@bigbangtheory.com',
60
+ :from => 'leonard@bigbangtheory.com',
61
+ :tag => 'my-tag'
62
+ )
63
+ end
64
+
65
+ end
66
+
67
+ === Rails 3
68
+
69
+ class TestMailer < ActionMailer::Base
70
+
71
+ def message_with_attachment
72
+ mail(
73
+ :subject => 'hello',
74
+ :to => 'sheldon@bigbangtheory.com',
75
+ :from => 'leonard@bigbangtheory.com',
76
+ :chimpster_attachments => [File.open("/path/to/file")]
77
+ )
78
+ end
79
+
80
+ end
81
+
82
+ == Authors & Contributors
83
+
84
+ * Michael Hart
85
+
86
+
87
+ == Copyright
88
+
89
+ Copyright © 2011 trahmmhart See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,58 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "chimpster-rails"
8
+ gem.summary = %Q{Chimpster adapter for ActionMailer}
9
+ gem.description = %Q{Use this plugin in your rails applications to send emails through SES via MailChimp API}
10
+ gem.email = "mike@fotomoto.com"
11
+ gem.homepage = "http://fotomoto.com"
12
+ gem.authors = ["Michael Hart"]
13
+
14
+ gem.add_dependency "actionmailer"
15
+ gem.add_dependency "chimpster", ">= 0.1.0"
16
+ gem.add_dependency "rake"
17
+
18
+ gem.post_install_message = %q[
19
+ ==================
20
+ Thanks for installing the chimpster-rails gem.
21
+ ==================
22
+ ]
23
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
24
+ end
25
+ Jeweler::GemcutterTasks.new
26
+ rescue LoadError
27
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
28
+ end
29
+
30
+ require 'spec/rake/spectask'
31
+ Spec::Rake::SpecTask.new(:spec) do |spec|
32
+ spec.libs << 'lib' << 'spec'
33
+ spec.spec_files = FileList['spec/**/*_spec.rb']
34
+ end
35
+
36
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
37
+ spec.libs << 'lib' << 'spec'
38
+ spec.pattern = 'spec/**/*_spec.rb'
39
+ spec.rcov = true
40
+ end
41
+
42
+ task :spec => :check_dependencies
43
+
44
+ task :default => :spec
45
+
46
+ require 'rake/rdoctask'
47
+ Rake::RDocTask.new do |rdoc|
48
+ if File.exist?('VERSION')
49
+ version = File.read('VERSION')
50
+ else
51
+ version = ""
52
+ end
53
+
54
+ rdoc.rdoc_dir = 'rdoc'
55
+ rdoc.title = "chimpster-rails #{version}"
56
+ rdoc.rdoc_files.include('README*')
57
+ rdoc.rdoc_files.include('lib/**/*.rb')
58
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,77 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{chimpster-rails}
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 = ["Michael Hart"]
12
+ s.date = %q{2011-07-21}
13
+ s.description = %q{Use this plugin in your rails applications to send emails through the SES/MailChimp API}
14
+ s.email = %q{mike@fotomoto.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "CHANGELOG.rdoc",
23
+ "Gemfile",
24
+ "Gemfile.lock",
25
+ "LICENSE",
26
+ "README.rdoc",
27
+ "Rakefile",
28
+ "VERSION",
29
+ "lib/chimpster-rails.rb",
30
+ "lib/chimpster_delivery_method.rb",
31
+ "chimpster-rails.gemspec",
32
+ "spec/fixtures/models/test_mailer.rb",
33
+ "spec/fixtures/views/test_mailer/multipart_message.html.erb",
34
+ "spec/fixtures/views/test_mailer/multipart_message.text.erb",
35
+ "spec/fixtures/views/test_mailer/simple_message.erb",
36
+ "spec/fixtures/views/test_mailer/tagged_message.erb",
37
+ "spec/chimpster-rails_spec.rb",
38
+ "spec/spec.opts",
39
+ "spec/spec_helper.rb"
40
+ ]
41
+ s.homepage = %q{http://chimpsterapp.com}
42
+ s.post_install_message = %q{
43
+ ==================
44
+ Thanks for installing the chimpster-rails gem. If you don't have an account, please sign up at http://chimpsterapp.com/.
45
+ Review the README.rdoc for implementation details and examples.
46
+ ==================
47
+ }
48
+ s.rdoc_options = ["--charset=UTF-8"]
49
+ s.require_paths = ["lib"]
50
+ s.rubygems_version = %q{1.3.7}
51
+ s.summary = %q{Postmark adapter for ActionMailer}
52
+ s.test_files = [
53
+ "spec/fixtures/models/test_mailer.rb",
54
+ "spec/chimpster-rails_spec.rb",
55
+ "spec/spec_helper.rb"
56
+ ]
57
+
58
+ if s.respond_to? :specification_version then
59
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
60
+ s.specification_version = 3
61
+
62
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
63
+ s.add_runtime_dependency(%q<actionmailer>, [">= 0"])
64
+ s.add_runtime_dependency(%q<chimpster>, [">= 0.9.0"])
65
+ s.add_runtime_dependency(%q<rake>, [">= 0"])
66
+ else
67
+ s.add_dependency(%q<actionmailer>, [">= 0"])
68
+ s.add_dependency(%q<chimpster>, [">= 0.9.0"])
69
+ s.add_dependency(%q<rake>, [">= 0"])
70
+ end
71
+ else
72
+ s.add_dependency(%q<actionmailer>, [">= 0"])
73
+ s.add_dependency(%q<chimpster>, [">= 0.9.0"])
74
+ s.add_dependency(%q<rake>, [">= 0"])
75
+ end
76
+ end
77
+
@@ -0,0 +1,21 @@
1
+ require 'action_mailer'
2
+ require 'chimpster'
3
+ require 'chimpster_delivery_method'
4
+
5
+ module ChimpsterInstaller
6
+ extend self
7
+
8
+ def auto_detect_and_install
9
+ install_in_rails_3
10
+ end
11
+
12
+
13
+
14
+ def install_in_rails_3
15
+ ActionMailer::Base.add_delivery_method :chimpster, Mail::Chimpster, :api_key => nil
16
+ Mail::Message.send(:include, Chimpster::AttachmentsFixForMail)
17
+ end
18
+
19
+ end
20
+
21
+ ChimpsterInstaller.auto_detect_and_install
@@ -0,0 +1,41 @@
1
+ #
2
+ # This module is only used for Rails 2.
3
+ #
4
+ module ChimpsterDeliveryMethod
5
+
6
+ module ClassMethods
7
+
8
+ def chimpster_api_key=(value)
9
+ Chimpster.api_key = value
10
+ end
11
+
12
+ end
13
+
14
+ def self.included(base)
15
+ base.extend(ClassMethods)
16
+
17
+ base.class_eval do
18
+ alias_method_chain :create_mail, :chimpster_extras
19
+ end
20
+ end
21
+
22
+ def perform_delivery_chimpster(message)
23
+ Chimpster.send_through_chimpster(message)
24
+ end
25
+
26
+ def tag(value)
27
+ @tag = value
28
+ end
29
+
30
+ def chimpster_attachments(value)
31
+ @attachments = value
32
+ end
33
+
34
+ def create_mail_with_chimpster_extras
35
+ create_mail_without_chimpster_extras.tap do |mail|
36
+ mail.tag = @tag if @tag
37
+ mail.chimpster_attachments = @attachments if @attachments
38
+ end
39
+ end
40
+
41
+ end
@@ -0,0 +1,34 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "ChimpsterRails3" do
4
+ it "should allow setting an api key" do
5
+ Chimpster.stub!(:send_through_chimpster)
6
+ ActionMailer::Base.chimpster_settings = {:api_key => 'api-key'}
7
+ ActionMailer::Base.chimpster_settings[:api_key].should == 'api-key'
8
+ Chimpster.should_receive(:api_key=).with('api-key')
9
+ TestMailer.simple_message.deliver
10
+ end
11
+
12
+ it "should use chimpster for delivery" do
13
+ Chimpster.should_receive(:send_through_chimpster) do |message|
14
+ message.subject.should == "hello"
15
+ end
16
+ TestMailer.simple_message.deliver
17
+ end
18
+
19
+ it "should allow tagging of message" do
20
+ Chimpster.should_receive(:send_through_chimpster) do |message|
21
+ message.tag.to_s.should == "delivery"
22
+ end
23
+ TestMailer.tagged_message.deliver
24
+ end
25
+
26
+ it "should work with multipart messages" do
27
+ Chimpster.should_receive(:send_through_chimpster) do |message|
28
+ message.should be_multipart
29
+ message.body_text.strip.should == "hello"
30
+ message.body_html.strip.should == "<b>hello</b>"
31
+ end
32
+ TestMailer.multipart_message.deliver
33
+ end
34
+ end
@@ -0,0 +1,20 @@
1
+ class TestMailer < ActionMailer::Base
2
+ default :subject => 'hello',
3
+ :to => 'sheldon@bigbangtheory.com',
4
+ :from => 'leonard@bigbangtheory.com'
5
+
6
+ def simple_message
7
+ mail
8
+ end
9
+
10
+ def tagged_message
11
+ mail(:tag => 'delivery')
12
+ end
13
+
14
+ def multipart_message
15
+ mail(:subject => "Your invitation to join Mixlr.") do |format|
16
+ format.text
17
+ format.html
18
+ end
19
+ end
20
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1,3 @@
1
+ --colour
2
+ --format specdoc
3
+ --loadby mtime
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+
4
+ require 'rubygems'
5
+ require 'chimpster'
6
+ require 'chimpster-rails'
7
+ require 'rspec'
8
+
9
+ ActionMailer::Base.delivery_method = :chimpster
10
+ ActionMailer::Base.prepend_view_path(File.join(File.dirname(__FILE__), "fixtures", "views"))
11
+
12
+ Dir["#{File.dirname(__FILE__)}/fixtures/models/*.rb"].each { |f| require f }
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: chimpster-rails
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Michael Hart
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-07-21 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: actionmailer
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: chimpster
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ hash: 59
43
+ segments:
44
+ - 0
45
+ - 9
46
+ - 0
47
+ version: 0.9.0
48
+ type: :runtime
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: rake
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ hash: 3
59
+ segments:
60
+ - 0
61
+ version: "0"
62
+ type: :runtime
63
+ version_requirements: *id003
64
+ description: Use this plugin in your rails applications to send emails through the SES/MailChimp API
65
+ email: mike@fotomoto.com
66
+ executables: []
67
+
68
+ extensions: []
69
+
70
+ extra_rdoc_files:
71
+ - LICENSE
72
+ - README.rdoc
73
+ files:
74
+ - .document
75
+ - .gitignore
76
+ - CHANGELOG.rdoc
77
+ - Gemfile
78
+ - Gemfile.lock
79
+ - LICENSE
80
+ - README.rdoc
81
+ - Rakefile
82
+ - VERSION
83
+ - lib/chimpster-rails.rb
84
+ - lib/chimpster_delivery_method.rb
85
+ - chimpster-rails.gemspec
86
+ - spec/fixtures/models/test_mailer.rb
87
+ - spec/fixtures/views/test_mailer/multipart_message.html.erb
88
+ - spec/fixtures/views/test_mailer/multipart_message.text.erb
89
+ - spec/fixtures/views/test_mailer/simple_message.erb
90
+ - spec/fixtures/views/test_mailer/tagged_message.erb
91
+ - spec/chimpster-rails_spec.rb
92
+ - spec/spec.opts
93
+ - spec/spec_helper.rb
94
+ homepage: http://chimpsterapp.com
95
+ licenses: []
96
+
97
+ post_install_message: "\n ==================\n Thanks for installing the chimpster-rails gem. If you don't have an account, please sign up at http://chimpsterapp.com/.\n Review the README.rdoc for implementation details and examples.\n ==================\n "
98
+ rdoc_options:
99
+ - --charset=UTF-8
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ none: false
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ hash: 3
108
+ segments:
109
+ - 0
110
+ version: "0"
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ none: false
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ hash: 3
117
+ segments:
118
+ - 0
119
+ version: "0"
120
+ requirements: []
121
+
122
+ rubyforge_project:
123
+ rubygems_version: 1.8.5
124
+ signing_key:
125
+ specification_version: 3
126
+ summary: Postmark adapter for ActionMailer
127
+ test_files:
128
+ - spec/fixtures/models/test_mailer.rb
129
+ - spec/chimpster-rails_spec.rb
130
+ - spec/spec_helper.rb