texterb 0.1.4

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.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ .bundle
2
+ test/tmp
3
+ *.gem
4
+ .rvmrc
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "rails", "3.0.7"
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,79 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ texterb (0.1.4)
5
+ RedCloth
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ RedCloth (4.2.9)
11
+ abstract (1.0.0)
12
+ actionmailer (3.0.7)
13
+ actionpack (= 3.0.7)
14
+ mail (~> 2.2.15)
15
+ actionpack (3.0.7)
16
+ activemodel (= 3.0.7)
17
+ activesupport (= 3.0.7)
18
+ builder (~> 2.1.2)
19
+ erubis (~> 2.6.6)
20
+ i18n (~> 0.5.0)
21
+ rack (~> 1.2.1)
22
+ rack-mount (~> 0.6.14)
23
+ rack-test (~> 0.5.7)
24
+ tzinfo (~> 0.3.23)
25
+ activemodel (3.0.7)
26
+ activesupport (= 3.0.7)
27
+ builder (~> 2.1.2)
28
+ i18n (~> 0.5.0)
29
+ activerecord (3.0.7)
30
+ activemodel (= 3.0.7)
31
+ activesupport (= 3.0.7)
32
+ arel (~> 2.0.2)
33
+ tzinfo (~> 0.3.23)
34
+ activeresource (3.0.7)
35
+ activemodel (= 3.0.7)
36
+ activesupport (= 3.0.7)
37
+ activesupport (3.0.7)
38
+ arel (2.0.9)
39
+ builder (2.1.2)
40
+ erubis (2.6.6)
41
+ abstract (>= 1.0.0)
42
+ i18n (0.5.0)
43
+ mail (2.2.18)
44
+ activesupport (>= 2.3.6)
45
+ i18n (>= 0.4.0)
46
+ mime-types (~> 1.16)
47
+ treetop (~> 1.4.8)
48
+ mime-types (1.16)
49
+ polyglot (0.3.1)
50
+ rack (1.2.2)
51
+ rack-mount (0.6.14)
52
+ rack (>= 1.0.0)
53
+ rack-test (0.5.7)
54
+ rack (>= 1.0)
55
+ rails (3.0.7)
56
+ actionmailer (= 3.0.7)
57
+ actionpack (= 3.0.7)
58
+ activerecord (= 3.0.7)
59
+ activeresource (= 3.0.7)
60
+ activesupport (= 3.0.7)
61
+ bundler (~> 1.0)
62
+ railties (= 3.0.7)
63
+ railties (3.0.7)
64
+ actionpack (= 3.0.7)
65
+ activesupport (= 3.0.7)
66
+ rake (>= 0.8.7)
67
+ thor (~> 0.14.4)
68
+ rake (0.8.7)
69
+ thor (0.14.6)
70
+ treetop (1.4.9)
71
+ polyglot (>= 0.3.1)
72
+ tzinfo (0.3.26)
73
+
74
+ PLATFORMS
75
+ ruby
76
+
77
+ DEPENDENCIES
78
+ rails (= 3.0.7)
79
+ texterb!
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2011 Roberto Vasquez Angel (blog.robotex.de)
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,9 @@
1
+ = Texterb
2
+
3
+ Texterb allows you to render multipart e-mails from a single template. The
4
+ template is written in Textile, which is delivered as a text part, but also
5
+ rendered and delivered as an HTML part.
6
+
7
+ == Copyright and License
8
+
9
+ Copied 99% form the markerb gem, created by the fine folks at PlataformaTec under the MIT-LICENSE (please check MIT-LICENSE file for more info).
data/Rakefile ADDED
@@ -0,0 +1,29 @@
1
+ # encoding: UTF-8
2
+ require 'rubygems'
3
+ begin
4
+ require 'bundler/setup'
5
+ rescue LoadError
6
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
7
+ end
8
+
9
+ require 'rake'
10
+ require 'rake/rdoctask'
11
+
12
+ require 'rake/testtask'
13
+
14
+ Rake::TestTask.new(:test) do |t|
15
+ t.libs << 'lib'
16
+ t.libs << 'test'
17
+ t.pattern = 'test/**/*_test.rb'
18
+ t.verbose = false
19
+ end
20
+
21
+ task :default => :test
22
+
23
+ Rake::RDocTask.new(:rdoc) do |rdoc|
24
+ rdoc.rdoc_dir = 'rdoc'
25
+ rdoc.title = 'Handlers'
26
+ rdoc.options << '--line-numbers' << '--inline-source'
27
+ rdoc.rdoc_files.include('README.rdoc')
28
+ rdoc.rdoc_files.include('lib/**/*.rb')
29
+ end
@@ -0,0 +1,19 @@
1
+ require "rails/generators/erb/mailer/mailer_generator"
2
+
3
+ module Texterb
4
+ module Generators
5
+ class MailerGenerator < Erb::Generators::MailerGenerator
6
+ source_root File.expand_path("../templates", __FILE__)
7
+
8
+ protected
9
+
10
+ def format
11
+ nil # Our templates have no format
12
+ end
13
+
14
+ def handler
15
+ :texterb
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,3 @@
1
+ <%= class_name %>#<%= @action %>
2
+
3
+ <%%= @greeting %>, find me in app/views/<%= @path %>
data/lib/texterb.rb ADDED
@@ -0,0 +1,25 @@
1
+ require "action_view/template"
2
+ require "redcloth"
3
+ require "texterb/railtie"
4
+
5
+ module Texterb
6
+ mattr_accessor :processing_options
7
+ @@processing_options = []
8
+
9
+ class Handler
10
+ def erb_handler
11
+ @erb_handler ||= ActionView::Template.registered_template_handler(:erb)
12
+ end
13
+
14
+ def call(template)
15
+ compiled_source = erb_handler.call(template)
16
+ if template.formats.include?(:html)
17
+ "RedCloth.new(begin;#{compiled_source};end).to_html.html_safe"
18
+ else
19
+ compiled_source
20
+ end
21
+ end
22
+ end
23
+ end
24
+
25
+ ActionView::Template.register_template_handler :texterb, Texterb::Handler.new
@@ -0,0 +1,6 @@
1
+ module Texterb
2
+ class Railtie < ::Rails::Railtie
3
+ config.texterb = Texterb
4
+ config.app_generators.mailer :template_engine => :texterb
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ module Texterb
2
+ VERSION = "0.1.4"
3
+ end
@@ -0,0 +1,16 @@
1
+ require "test_helper"
2
+ require "generators/markerb/mailer/mailer_generator"
3
+
4
+ class GeneratorTest < Rails::Generators::TestCase
5
+ tests Markerb::Generators::MailerGenerator
6
+ destination File.expand_path("../tmp", __FILE__)
7
+ setup :prepare_destination
8
+
9
+ test "assert all views are properly created with given name" do
10
+ run_generator %w(notifier foo bar baz)
11
+
12
+ assert_file "app/views/notifier/foo.markerb"
13
+ assert_file "app/views/notifier/bar.markerb"
14
+ assert_file "app/views/notifier/baz.markerb"
15
+ end
16
+ end
@@ -0,0 +1,49 @@
1
+ require "test_helper"
2
+
3
+ class Notifier < ActionMailer::Base
4
+ self.view_paths = File.expand_path("../views", __FILE__)
5
+
6
+ layout false
7
+
8
+ def contact(recipient, format_type)
9
+ @recipient = recipient
10
+ mail(:to => @recipient, :from => "john.doe@example.com") do |format|
11
+ format.send(format_type)
12
+ end
13
+ end
14
+
15
+ def multiple_format_contact(recipient)
16
+ @recipient = recipient
17
+ mail(:to => @recipient, :from => "john.doe@example.com", :template => "contact") do |format|
18
+ format.text { render 'contact' }
19
+ format.html { render 'contact' }
20
+ end
21
+ end
22
+ end
23
+
24
+ class MarkerbTest < ActiveSupport::TestCase
25
+
26
+ test "plain text should be sent as a plain text" do
27
+ email = Notifier.contact("you@example.com", :text)
28
+ assert_equal "text/plain", email.mime_type
29
+ assert_equal "Dual templates **rocks**!", email.body.encoded.strip
30
+ end
31
+
32
+ test "html should be sent as html" do
33
+ email = Notifier.contact("you@example.com", :html)
34
+ assert_equal "text/html", email.mime_type
35
+ assert_equal "<p>Dual templates <strong>rocks</strong>!</p>", email.body.encoded.strip
36
+ end
37
+
38
+ test 'dealing with multipart e-mails' do
39
+ email = Notifier.multiple_format_contact("you@example.com")
40
+ assert_equal 2, email.parts.size
41
+ assert_equal "multipart/alternative", email.mime_type
42
+ assert_equal "text/plain", email.parts[0].mime_type
43
+ assert_equal "Dual templates **rocks**!",
44
+ email.parts[0].body.encoded.strip
45
+ assert_equal "text/html", email.parts[1].mime_type
46
+ assert_equal "<p>Dual templates <strong>rocks</strong>!</p>",
47
+ email.parts[1].body.encoded.strip
48
+ end
49
+ end
@@ -0,0 +1,17 @@
1
+ require "rubygems"
2
+ require "bundler"
3
+ Bundler.setup
4
+
5
+ require "test/unit"
6
+ require "active_support/test_case"
7
+
8
+ require "action_mailer"
9
+ require "rails/railtie"
10
+ require "rails/generators"
11
+ require "rails/generators/test_case"
12
+
13
+ $:.unshift File.expand_path("../../lib", __FILE__)
14
+ require "markerb"
15
+
16
+ ActionMailer::Base.delivery_method = :test
17
+ ActionMailer::Base.perform_deliveries = true
@@ -0,0 +1 @@
1
+ Dual templates **rocks**!
data/texterb.gemspec ADDED
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "texterb/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "texterb"
7
+ s.version = Texterb::VERSION.dup
8
+ s.platform = Gem::Platform::RUBY
9
+ s.summary = "Multipart templates made easy with Textile + ERb"
10
+ s.email = "roberto@vasquez-angel.de"
11
+ s.homepage = "http://github.com/robotex/texterb"
12
+ s.description = "Multipart templates made easy with Textile + ERb"
13
+ s.authors = ['Roberto Vasquez Angel']
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ["lib"]
19
+
20
+ s.add_dependency "RedCloth"
21
+ end
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: texterb
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.1.4
6
+ platform: ruby
7
+ authors:
8
+ - Roberto Vasquez Angel
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2012-06-22 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: RedCloth
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ type: :runtime
25
+ version_requirements: *id001
26
+ description: Multipart templates made easy with Textile + ERb
27
+ email: roberto@vasquez-angel.de
28
+ executables: []
29
+
30
+ extensions: []
31
+
32
+ extra_rdoc_files: []
33
+
34
+ files:
35
+ - .gitignore
36
+ - Gemfile
37
+ - Gemfile.lock
38
+ - MIT-LICENSE
39
+ - README.rdoc
40
+ - Rakefile
41
+ - lib/generators/texterb/mailer/mailer_generator.rb
42
+ - lib/generators/texterb/mailer/templates/view.texterb
43
+ - lib/texterb.rb
44
+ - lib/texterb/railtie.rb
45
+ - lib/texterb/version.rb
46
+ - test/generator_test.rb
47
+ - test/markerb_test.rb
48
+ - test/test_helper.rb
49
+ - test/views/notifier/contact.markerb
50
+ - texterb-0.1.0.gem
51
+ - texterb.gemspec
52
+ homepage: http://github.com/robotex/texterb
53
+ licenses: []
54
+
55
+ post_install_message:
56
+ rdoc_options: []
57
+
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: "0"
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: "0"
72
+ requirements: []
73
+
74
+ rubyforge_project:
75
+ rubygems_version: 1.8.24
76
+ signing_key:
77
+ specification_version: 3
78
+ summary: Multipart templates made easy with Textile + ERb
79
+ test_files: []
80
+