unisender-rails 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
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
18
+ .rvmrc
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in unisender-rails.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 freeze
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,49 @@
1
+ # Unisender::Rails
2
+
3
+ It is a wrapper to use uni_sender gem
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'unisender-rails'
10
+
11
+ And then execute:
12
+
13
+ $ bundle install
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install unisender-rails
18
+
19
+ ## Usage
20
+
21
+ Make a mailer:
22
+
23
+ rails g unisender_rails:mailer my_mailer
24
+ or
25
+ rails generate unisender_rails:mailer my_mailer
26
+
27
+ Make defaults in your mailer:
28
+
29
+ class MyMailer < ActionMailer::Base
30
+ default :from => "your@email.com"
31
+ self.unisender_settings = {:api_key => 'your api here',
32
+ :list_id => your users group list id }
33
+ def sign_up
34
+ mail(:to => 'your@client.com',
35
+ :subject => 'Subject')
36
+ end
37
+ end
38
+
39
+ Use the mailer:
40
+
41
+ MyMailer.sign_up.deliver!
42
+
43
+ ## Contributing
44
+
45
+ 1. Fork it
46
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
47
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
48
+ 4. Push to the branch (`git push origin my-new-feature`)
49
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,17 @@
1
+ module UnisenderRails
2
+ module Generators
3
+ class MailerGenerator < ::Rails::Generators::NamedBase
4
+ desc "This generator creates mailer with unisender defaults"
5
+ source_root File.expand_path("../templates", __FILE__)
6
+
7
+ argument :actions, :type => :array, :default => [], :banner => "method method"
8
+ check_class_collision
9
+
10
+ def generate_mailer
11
+ template 'mailer.rb', File.join(Rails.root, 'app/mailers', class_path, "#{file_name}.rb")
12
+ end
13
+
14
+ hook_for :template_engine, :test_framework
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,21 @@
1
+ <% module_namespacing do -%>
2
+ class <%= class_name %> < ActionMailer::Base
3
+ default <%= key_value :from, '"from@example.com"' %>
4
+ self.delivery_method = :unisender
5
+ self.unisender_settings = {:api_key => 'your api key',
6
+ :list_id => 'users group list id'}
7
+ <% actions.each do |action| -%>
8
+
9
+ # Subject can be set in your I18n file at config/locales/en.yml
10
+ # with the following lookup:
11
+ #
12
+ # en.<%= file_path.gsub("/",".") %>.<%= action %>.subject
13
+ #
14
+ def <%= action %>
15
+ @greeting = "Hi"
16
+
17
+ mail <%= key_value :to, '"to@example.org"' %>
18
+ end
19
+ <% end -%>
20
+ end
21
+ <% end -%>
@@ -0,0 +1,14 @@
1
+ require "unisender-rails/version"
2
+ require 'unisender-rails/sender'
3
+
4
+ module UnisenderRails
5
+ module Installer
6
+ extend self
7
+
8
+ def install
9
+ ActionMailer::Base.add_delivery_method :unisender, UnisenderRails::Sender
10
+ end
11
+ end
12
+ end
13
+
14
+ UnisenderRails::Installer.install
@@ -0,0 +1,30 @@
1
+ require 'uni_sender'
2
+
3
+ module UnisenderRails
4
+ class Sender
5
+
6
+
7
+ def initialize(args)
8
+ @settings = {:api_key => nil}
9
+ args.each do |arg_name, arg_value|
10
+ @settings[arg_name.to_sym] = arg_value
11
+ end
12
+ end
13
+
14
+ def settings
15
+ @settings
16
+ end
17
+
18
+ def deliver!(mail)
19
+ client = UniSender::Client.new(@settings[:api_key])
20
+ list_id = @settings[:list_id]
21
+ client.sendEmail :subject => mail.subject,
22
+ :body => mail.body,
23
+ :sender_email => mail.from,
24
+ :email => mail.to,
25
+ :sender_name => mail.to.split('@').first,
26
+ :list_id => list_id
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,5 @@
1
+ module Unisender
2
+ module Rails
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'unisender-rails/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "unisender-rails"
8
+ gem.version = Unisender::Rails::VERSION
9
+ gem.authors = ["Sergey Gribovski (Aforex)"]
10
+ gem.email = ["sgribovskiy@aforex.ru"]
11
+ gem.description = %q{It is a wrapper for uni_sender gem}
12
+ gem.summary = %q{It is a wrapper for uni_sender gem to use it like rails ActionMailer}
13
+ gem.homepage = ""
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_runtime_dependency "uni_sender", ">=0"
21
+ end
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: unisender-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Sergey Gribovski (Aforex)
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-09-15 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: uni_sender
16
+ requirement: &17119140 !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: *17119140
25
+ description: It is a wrapper for uni_sender gem
26
+ email:
27
+ - sgribovskiy@aforex.ru
28
+ executables: []
29
+ extensions: []
30
+ extra_rdoc_files: []
31
+ files:
32
+ - .gitignore
33
+ - Gemfile
34
+ - LICENSE.txt
35
+ - README.md
36
+ - Rakefile
37
+ - lib/generators/unisender_rails/mailer/mailer_generator.rb
38
+ - lib/generators/unisender_rails/mailer/templates/mailer.rb
39
+ - lib/unisender-rails.rb
40
+ - lib/unisender-rails/sender.rb
41
+ - lib/unisender-rails/version.rb
42
+ - unisender-rails.gemspec
43
+ homepage: ''
44
+ licenses: []
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ! '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ requirements: []
62
+ rubyforge_project:
63
+ rubygems_version: 1.8.5
64
+ signing_key:
65
+ specification_version: 3
66
+ summary: It is a wrapper for uni_sender gem to use it like rails ActionMailer
67
+ test_files: []