radiant-mailer_confirmation-extension 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,26 @@
1
+ # Mailer Confirmation
2
+
3
+ Allows you to set up a second email to the form submitter that differs from the email sent to regular mail receiver.
4
+
5
+ ## Requirements
6
+
7
+ [Radiant Mailer extension](https://github.com/radiant/radiant-mailer-extension/) is required.
8
+
9
+ ## Configuration
10
+
11
+ Create a page part 'confirmation_email' in which you can compose the email in the same way as in the usual 'email' page part. There is no code to cater for 'confirmation_html_email'. If you need that functionality and write it yourself, please send me a pull request. If you would like you can [contact me](mailto:hi@monkeypatch.be) to write this for you for a small fee.
12
+
13
+ In the 'mailer' page part, add these fields:
14
+
15
+ confirmation_from_field: foo@example.com
16
+
17
+ The from: that will be used for the confirmation mail. This is optional; if not present this will default to the 'from_field' or 'from' config entries.
18
+
19
+ confirmation_subject: Thank you for reaching out to us
20
+
21
+ The subject of the confirmation email. Will default to 'Confirmation email'.
22
+
23
+ confirmation_recipients_field: email
24
+
25
+ This is the only required field. It defines in which POSTed form field the recipient of the confirmation mail can be found.
26
+ Unlike the mailer extension, there is no 'confirmation_recipients' config entry, as it didn't make sense to me.
@@ -0,0 +1,123 @@
1
+ # I think this is the one that should be moved to the extension Rakefile template
2
+
3
+ # In rails 1.2, plugins aren't available in the path until they're loaded.
4
+ # Check to see if the rspec plugin is installed first and require
5
+ # it if it is. If not, use the gem version.
6
+
7
+ # Determine where the RSpec plugin is by loading the boot
8
+ unless defined? RADIANT_ROOT
9
+ ENV["RAILS_ENV"] = "test"
10
+ case
11
+ when ENV["RADIANT_ENV_FILE"]
12
+ require File.dirname(ENV["RADIANT_ENV_FILE"]) + "/boot"
13
+ when File.dirname(__FILE__) =~ %r{vendor/radiant/vendor/extensions}
14
+ require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../../")}/config/boot"
15
+ else
16
+ require "#{File.expand_path(File.dirname(__FILE__) + "/../../../")}/config/boot"
17
+ end
18
+ end
19
+
20
+ require 'rake'
21
+ require 'rake/rdoctask'
22
+ require 'rake/testtask'
23
+
24
+ rspec_base = File.expand_path(RADIANT_ROOT + '/vendor/plugins/rspec/lib')
25
+ $LOAD_PATH.unshift(rspec_base) if File.exist?(rspec_base)
26
+ require 'spec/rake/spectask'
27
+ require 'cucumber'
28
+ require 'cucumber/rake/task'
29
+
30
+ # Cleanup the RADIANT_ROOT constant so specs will load the environment
31
+ Object.send(:remove_const, :RADIANT_ROOT)
32
+
33
+ extension_root = File.expand_path(File.dirname(__FILE__))
34
+
35
+ task :default => :spec
36
+ task :stats => "spec:statsetup"
37
+
38
+ desc "Run all specs in spec directory"
39
+ Spec::Rake::SpecTask.new(:spec) do |t|
40
+ t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
41
+ t.spec_files = FileList['spec/**/*_spec.rb']
42
+ end
43
+
44
+ task :features => 'spec:integration'
45
+
46
+ namespace :spec do
47
+ desc "Run all specs in spec directory with RCov"
48
+ Spec::Rake::SpecTask.new(:rcov) do |t|
49
+ t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
50
+ t.spec_files = FileList['spec/**/*_spec.rb']
51
+ t.rcov = true
52
+ t.rcov_opts = ['--exclude', 'spec', '--rails']
53
+ end
54
+
55
+ desc "Print Specdoc for all specs"
56
+ Spec::Rake::SpecTask.new(:doc) do |t|
57
+ t.spec_opts = ["--format", "specdoc", "--dry-run"]
58
+ t.spec_files = FileList['spec/**/*_spec.rb']
59
+ end
60
+
61
+ [:models, :controllers, :views, :helpers].each do |sub|
62
+ desc "Run the specs under spec/#{sub}"
63
+ Spec::Rake::SpecTask.new(sub) do |t|
64
+ t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
65
+ t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
66
+ end
67
+ end
68
+
69
+ desc "Run the Cucumber features"
70
+ Cucumber::Rake::Task.new(:integration) do |t|
71
+ t.fork = true
72
+ t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'pretty')]
73
+ # t.feature_pattern = "#{extension_root}/features/**/*.feature"
74
+ t.profile = "default"
75
+ end
76
+
77
+ # Setup specs for stats
78
+ task :statsetup do
79
+ require 'code_statistics'
80
+ ::STATS_DIRECTORIES << %w(Model\ specs spec/models)
81
+ ::STATS_DIRECTORIES << %w(View\ specs spec/views)
82
+ ::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers)
83
+ ::STATS_DIRECTORIES << %w(Helper\ specs spec/views)
84
+ ::CodeStatistics::TEST_TYPES << "Model specs"
85
+ ::CodeStatistics::TEST_TYPES << "View specs"
86
+ ::CodeStatistics::TEST_TYPES << "Controller specs"
87
+ ::CodeStatistics::TEST_TYPES << "Helper specs"
88
+ ::STATS_DIRECTORIES.delete_if {|a| a[0] =~ /test/}
89
+ end
90
+
91
+ namespace :db do
92
+ namespace :fixtures do
93
+ desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y"
94
+ task :load => :environment do
95
+ require 'active_record/fixtures'
96
+ ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
97
+ (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(RAILS_ROOT, 'spec', 'fixtures', '*.{yml,csv}'))).each do |fixture_file|
98
+ Fixtures.create_fixtures('spec/fixtures', File.basename(fixture_file, '.*'))
99
+ end
100
+ end
101
+ end
102
+ end
103
+ end
104
+
105
+ desc 'Generate documentation for the mailer_confirmation extension.'
106
+ Rake::RDocTask.new(:rdoc) do |rdoc|
107
+ rdoc.rdoc_dir = 'rdoc'
108
+ rdoc.title = 'MailerConfirmationExtension'
109
+ rdoc.options << '--line-numbers' << '--inline-source'
110
+ rdoc.rdoc_files.include('README')
111
+ rdoc.rdoc_files.include('lib/**/*.rb')
112
+ end
113
+
114
+ # For extensions that are in transition
115
+ desc 'Test the mailer_confirmation extension.'
116
+ Rake::TestTask.new(:test) do |t|
117
+ t.libs << 'lib'
118
+ t.pattern = 'test/**/*_test.rb'
119
+ t.verbose = true
120
+ end
121
+
122
+ # Load any custom rakefiles for extension
123
+ Dir[File.dirname(__FILE__) + '/tasks/*.rake'].sort.each { |f| require f }
@@ -0,0 +1 @@
1
+ default: --format progress features --tags ~@proposed,~@in_progress
@@ -0,0 +1,16 @@
1
+ # Sets up the Rails environment for Cucumber
2
+ ENV["RAILS_ENV"] = "test"
3
+ # Extension root
4
+ extension_env = File.expand_path(File.dirname(__FILE__) + '/../../../../../config/environment')
5
+ require extension_env+'.rb'
6
+
7
+ Dir.glob(File.join(RADIANT_ROOT, "features", "**", "*.rb")).each {|step| require step}
8
+
9
+ Cucumber::Rails::World.class_eval do
10
+ include Dataset
11
+ datasets_directory "#{RADIANT_ROOT}/spec/datasets"
12
+ Dataset::Resolver.default = Dataset::DirectoryResolver.new("#{RADIANT_ROOT}/spec/datasets", File.dirname(__FILE__) + '/../../spec/datasets', File.dirname(__FILE__) + '/../datasets')
13
+ self.datasets_database_dump_path = "#{Rails.root}/tmp/dataset"
14
+
15
+ # dataset :mailer_confirmation
16
+ end
@@ -0,0 +1,14 @@
1
+ def path_to(page_name)
2
+ case page_name
3
+
4
+ when /the homepage/i
5
+ root_path
6
+
7
+ when /login/i
8
+ login_path
9
+ # Add more page name => path mappings here
10
+
11
+ else
12
+ raise "Can't find mapping from \"#{page_name}\" to a path."
13
+ end
14
+ end
@@ -0,0 +1,35 @@
1
+ module MailerConfirmation
2
+ module MailExtensions
3
+
4
+ def self.included(base)
5
+ base.class_eval {
6
+ alias_method_chain :send, :confirmation
7
+ }
8
+ end
9
+
10
+ def send_with_confirmation
11
+ if sent? && !page.part(:confirmation_email).nil? # Only if the original mail succeeded and confirmation mail is set up.
12
+ confirmation_body = page.render_part( :confirmation_email )
13
+ from_address = data[config[:confirmation_from_field]] || data[config[:from_field]] || config[:from]
14
+ subject = config[:confirmation_subject] || "Confirmation email"
15
+
16
+ headers = { 'Reply-To' => from_address, 'Return-Path' => from_address, 'Sender' => from_address }
17
+ recipients = data[config[:confirmation_recipients_field]].split(/,/).collect{|e| e.strip}
18
+
19
+ raise StandardError, "Recipients field was left blank, email not sent." if recipients.empty?
20
+
21
+ Mailer.deliver_generic_mail(
22
+ :recipients => recipients,
23
+ :from => from_address,
24
+ :subject => subject,
25
+ :plain_body => confirmation_body,
26
+ :headers => headers
27
+ )
28
+ send_without_confirmation
29
+ else
30
+ send_without_confirmation
31
+ end
32
+ end
33
+
34
+ end
35
+ end
@@ -0,0 +1,8 @@
1
+ module RadiantMailerConfirmationExtension
2
+ VERSION = "1.0.0"
3
+ SUMMARY = "Confirmation emails for Radiant CMS's mailer extension"
4
+ DESCRIPTION = "Allows you to set up a second email to the form submitter that differs from the email sent to regular mail receiver."
5
+ URL = "https://github.com/jomz/radiant-mailer_confirmation-extension"
6
+ AUTHORS = ["Benny Degezelle"]
7
+ EMAIL = ["benny@gorilla-webdesign.be"]
8
+ end
@@ -0,0 +1,15 @@
1
+ require "radiant-mailer_confirmation-extension"
2
+
3
+ class MailerConfirmationExtension < Radiant::Extension
4
+ version RadiantMailerConfirmationExtension::VERSION
5
+ description RadiantMailerConfirmationExtension::DESCRIPTION
6
+ url RadiantMailerConfirmationExtension::URL
7
+
8
+ def activate
9
+ Mail.send :include, MailerConfirmation::MailExtensions
10
+ end
11
+
12
+ def deactivate
13
+ end
14
+
15
+ end
@@ -0,0 +1,29 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "radiant-mailer_confirmation-extension"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "radiant-mailer_confirmation-extension"
7
+ s.version = RadiantMailerConfirmationExtension::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = RadiantMailerConfirmationExtension::AUTHORS
10
+ s.email = RadiantMailerConfirmationExtension::EMAIL
11
+ s.homepage = RadiantMailerConfirmationExtension::URL
12
+ s.summary = RadiantMailerConfirmationExtension::SUMMARY
13
+ s.description = RadiantMailerConfirmationExtension::DESCRIPTION
14
+
15
+ # Define gem dependencies here.
16
+ # Don't include a dependency on radiant itself: it causes problems when radiant is in vendor/radiant.
17
+ # s.add_dependency "something", "~> 1.0.0"
18
+ s.add_dependency "radiant-mailer-extension"
19
+
20
+ ignores = if File.exist?('.gitignore')
21
+ File.read('.gitignore').split("\n").inject([]) {|a,p| a + Dir[p] }
22
+ else
23
+ []
24
+ end
25
+ s.files = Dir['**/*'] - ignores
26
+ s.test_files = Dir['test/**/*','spec/**/*','features/**/*'] - ignores
27
+ # s.executables = Dir['bin/*'] - ignores
28
+ s.require_paths = ["lib"]
29
+ end
@@ -0,0 +1,6 @@
1
+ --colour
2
+ --format
3
+ progress
4
+ --loadby
5
+ mtime
6
+ --reverse
@@ -0,0 +1,36 @@
1
+ unless defined? RADIANT_ROOT
2
+ ENV["RAILS_ENV"] = "test"
3
+ case
4
+ when ENV["RADIANT_ENV_FILE"]
5
+ require ENV["RADIANT_ENV_FILE"]
6
+ when File.dirname(__FILE__) =~ %r{vendor/radiant/vendor/extensions}
7
+ require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../../../")}/config/environment"
8
+ else
9
+ require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../")}/config/environment"
10
+ end
11
+ end
12
+ require "#{RADIANT_ROOT}/spec/spec_helper"
13
+
14
+ Dataset::Resolver.default << (File.dirname(__FILE__) + "/datasets")
15
+
16
+ if File.directory?(File.dirname(__FILE__) + "/matchers")
17
+ Dir[File.dirname(__FILE__) + "/matchers/*.rb"].each {|file| require file }
18
+ end
19
+
20
+ Spec::Runner.configure do |config|
21
+ # config.use_transactional_fixtures = true
22
+ # config.use_instantiated_fixtures = false
23
+ # config.fixture_path = RAILS_ROOT + '/spec/fixtures'
24
+
25
+ # You can declare fixtures for each behaviour like this:
26
+ # describe "...." do
27
+ # fixtures :table_a, :table_b
28
+ #
29
+ # Alternatively, if you prefer to declare them only once, you can
30
+ # do so here, like so ...
31
+ #
32
+ # config.global_fixtures = :table_a, :table_b
33
+ #
34
+ # If you declare global fixtures, be aware that they will be declared
35
+ # for all of your examples, even those that don't use them.
36
+ end
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: radiant-mailer_confirmation-extension
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Benny Degezelle
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-03-28 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: radiant-mailer-extension
16
+ requirement: !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: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: Allows you to set up a second email to the form submitter that differs
31
+ from the email sent to regular mail receiver.
32
+ email:
33
+ - benny@gorilla-webdesign.be
34
+ executables: []
35
+ extensions: []
36
+ extra_rdoc_files: []
37
+ files:
38
+ - cucumber.yml
39
+ - features/support/env.rb
40
+ - features/support/paths.rb
41
+ - lib/mailer_confirmation/mail_extensions.rb
42
+ - lib/radiant-mailer_confirmation-extension.rb
43
+ - mailer_confirmation_extension.rb
44
+ - radiant-mailer_confirmation-extension.gemspec
45
+ - Rakefile
46
+ - README.md
47
+ - spec/spec.opts
48
+ - spec/spec_helper.rb
49
+ homepage: https://github.com/jomz/radiant-mailer_confirmation-extension
50
+ licenses: []
51
+ post_install_message:
52
+ rdoc_options: []
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ! '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ! '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ requirements: []
68
+ rubyforge_project:
69
+ rubygems_version: 1.8.26
70
+ signing_key:
71
+ specification_version: 3
72
+ summary: Confirmation emails for Radiant CMS's mailer extension
73
+ test_files:
74
+ - spec/spec.opts
75
+ - spec/spec_helper.rb
76
+ - features/support/env.rb
77
+ - features/support/paths.rb