madmimi-rails 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d3e2582ef296304ab3a272981aad44a9bbfa8ff5
4
+ data.tar.gz: 39fb3e2853d5a25c3efaf963bb4f14010b3b9c74
5
+ SHA512:
6
+ metadata.gz: 413a327713403d17cac75b6fb845382ce4482ae3d7f6b3d2f166316f4743dfc31e1c2114471f49a6a2af72f00d693fdb6bb8fbead12a4ea49a21969c1d1c08d7
7
+ data.tar.gz: 612b86069a4438c44fe621ef774b1ff626f5945e0949e9b0ddaf497cb884046f0fdca91165b017199b62343039b9f12fa155bb944037d5ed235e2c9d722f6c68
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in madmimi-rails.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 markevich
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # Madmimi::Rails
2
+
3
+ ActionMailer delivery method for sending emails via madmimi}
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'madmimi-rails'
10
+
11
+ Execute:
12
+
13
+ $ bundle
14
+
15
+ Run generator:
16
+
17
+ $ rails g madmimi:rails:install
18
+
19
+ Copy ```config/madmimi.yml.template``` to ```config/madmimi.yml```
20
+
21
+ Change delivery method in your enviroment
22
+
23
+ config.action_mailer.delivery_method = :madmimi
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,11 @@
1
+ require 'rails/generators'
2
+ class Madmimi::Rails::InstallGenerator < Rails::Generators::Base
3
+ desc 'Creates madmimi.yml config template'
4
+ def self.source_root
5
+ @source_root ||= File.expand_path('../templates', __FILE__)
6
+ end
7
+
8
+ def create_config_file
9
+ template 'madmimi.yml', File.join('config', 'madmimi.yml.template')
10
+ end
11
+ end
@@ -0,0 +1,13 @@
1
+ default:
2
+ email:
3
+ api_key:
4
+
5
+ development:
6
+ <<: *default
7
+
8
+ production:
9
+ <<: *default
10
+
11
+ test:
12
+ email: 'test@test.com'
13
+ api_key: 'secret'
@@ -0,0 +1,4 @@
1
+ require 'madmimi/rails/version'
2
+
3
+ require 'madmimi/rails/delivery_method'
4
+ require 'madmimi/rails/railtie' if defined? Rails
@@ -0,0 +1,28 @@
1
+ require 'madmimi'
2
+ module Madmimi
3
+ module Rails
4
+ class Madmimi::Rails::DeliveryMethod
5
+ class InvalidOptions < StandardError; end;
6
+
7
+ attr_accessor :settings
8
+
9
+ def initialize config = {}
10
+ fail(InvalidOptions, "Missing configuration") if config[:email].nil? || config[:api_key].nil?
11
+ self.settings = config
12
+ end
13
+
14
+ def deliver! mail
15
+ options = {
16
+ 'promotion_name' => mail.subject,
17
+ 'recipients' => mail.to.join(','),
18
+ 'from' => mail.from.join(','),
19
+ 'subject' => mail.subject,
20
+ 'remove_unsubscribe' => true
21
+ }
22
+ raw = mail.body.raw_source
23
+ mimi = MadMimi.new(settings[:email], settings[:api_key])
24
+ mimi.send_html(options, raw)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,14 @@
1
+ class Madmimi::Rails::Railtie < Rails::Railtie
2
+ initializer 'madmimi-rails.add_delivery_method' do
3
+ begin
4
+ settings = YAML.load_file("#{Rails.root}/config/madmimi.yml")[Rails.env]
5
+ rescue Errno::ENOENT
6
+ settings = {}
7
+ end
8
+ ActionMailer::Base.add_delivery_method :madmimi, Madmimi::Rails::DeliveryMethod, email: settings['email'], api_key: settings['api_key']
9
+ end
10
+
11
+ generators do
12
+ require 'generators/madmimi/rails/install_generator'
13
+ end
14
+ end
@@ -0,0 +1,5 @@
1
+ module Madmimi
2
+ module Rails
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'madmimi/rails/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "madmimi-rails"
8
+ spec.version = Madmimi::Rails::VERSION
9
+ spec.authors = ["Slava Markevich"]
10
+ spec.email = ["slava.markevich@gmail.com"]
11
+ spec.description = %q{ActionMailer delivery method for sending emails via madmimi}
12
+ spec.summary = %q{}
13
+ spec.homepage = "https://github.com/markevich/madmimi-rails"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "madmimi"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.3"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "rspec"
26
+ spec.add_development_dependency "debugger"
27
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+ require 'debugger'
3
+ describe DeliveryMethod do
4
+ let(:valid_params) { {api_key: 'api_secret', email: 'test@test.com'} }
5
+ describe '.new' do
6
+ context 'With incorrect options' do
7
+ it { expect{ DeliveryMethod.new }.to raise_error DeliveryMethod::InvalidOptions}
8
+ it { expect{ DeliveryMethod.new(email: 'test@test.com') }.to raise_error DeliveryMethod::InvalidOptions }
9
+ it { expect{ DeliveryMethod.new(api_key: 'api_secret') }.to raise_error DeliveryMethod::InvalidOptions }
10
+ end
11
+ context 'With correct options' do
12
+ it { expect{ DeliveryMethod.new(valid_params) }.to_not raise_error }
13
+ end
14
+ it 'Set settings' do
15
+ instance = DeliveryMethod.new(valid_params)
16
+ expect(instance.settings).to be_equal valid_params
17
+ end
18
+ end
19
+ describe '#deliver!' do
20
+ let(:instance) { DeliveryMethod.new(valid_params) }
21
+ it { expect(instance).to respond_to :deliver! }
22
+ end
23
+ end
@@ -0,0 +1,4 @@
1
+ require 'bundler/setup'
2
+ Bundler.require(:default)
3
+
4
+ include Madmimi::Rails
metadata ADDED
@@ -0,0 +1,131 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: madmimi-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Slava Markevich
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-06-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: madmimi
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: debugger
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: ActionMailer delivery method for sending emails via madmimi
84
+ email:
85
+ - slava.markevich@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - .gitignore
91
+ - .rspec
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - lib/generators/madmimi/rails/install_generator.rb
97
+ - lib/generators/madmimi/rails/templates/madmimi.yml
98
+ - lib/madmimi-rails.rb
99
+ - lib/madmimi/rails/delivery_method.rb
100
+ - lib/madmimi/rails/railtie.rb
101
+ - lib/madmimi/rails/version.rb
102
+ - madmimi-rails.gemspec
103
+ - spec/delivery_method_spec.rb
104
+ - spec/spec_helper.rb
105
+ homepage: https://github.com/markevich/madmimi-rails
106
+ licenses:
107
+ - MIT
108
+ metadata: {}
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - '>='
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubyforge_project:
125
+ rubygems_version: 2.0.2
126
+ signing_key:
127
+ specification_version: 4
128
+ summary: ''
129
+ test_files:
130
+ - spec/delivery_method_spec.rb
131
+ - spec/spec_helper.rb