markerb 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem "rails", "3.0.7"
4
- gemspec
3
+ gem "rails", "~> 3.0"
4
+ gemspec
data/Gemfile.lock CHANGED
@@ -1,79 +1,94 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- markerb (1.0.0)
4
+ markerb (1.0.1)
5
5
  redcarpet (>= 2.0)
6
6
 
7
7
  GEM
8
8
  remote: http://rubygems.org/
9
9
  specs:
10
- abstract (1.0.0)
11
- actionmailer (3.0.7)
12
- actionpack (= 3.0.7)
13
- mail (~> 2.2.15)
14
- actionpack (3.0.7)
15
- activemodel (= 3.0.7)
16
- activesupport (= 3.0.7)
17
- builder (~> 2.1.2)
18
- erubis (~> 2.6.6)
19
- i18n (~> 0.5.0)
20
- rack (~> 1.2.1)
21
- rack-mount (~> 0.6.14)
22
- rack-test (~> 0.5.7)
23
- tzinfo (~> 0.3.23)
24
- activemodel (3.0.7)
25
- activesupport (= 3.0.7)
26
- builder (~> 2.1.2)
27
- i18n (~> 0.5.0)
28
- activerecord (3.0.7)
29
- activemodel (= 3.0.7)
30
- activesupport (= 3.0.7)
31
- arel (~> 2.0.2)
32
- tzinfo (~> 0.3.23)
33
- activeresource (3.0.7)
34
- activemodel (= 3.0.7)
35
- activesupport (= 3.0.7)
36
- activesupport (3.0.7)
37
- arel (2.0.9)
38
- builder (2.1.2)
39
- erubis (2.6.6)
40
- abstract (>= 1.0.0)
41
- i18n (0.5.0)
42
- mail (2.2.18)
43
- activesupport (>= 2.3.6)
10
+ actionmailer (3.2.11)
11
+ actionpack (= 3.2.11)
12
+ mail (~> 2.4.4)
13
+ actionpack (3.2.11)
14
+ activemodel (= 3.2.11)
15
+ activesupport (= 3.2.11)
16
+ builder (~> 3.0.0)
17
+ erubis (~> 2.7.0)
18
+ journey (~> 1.0.4)
19
+ rack (~> 1.4.0)
20
+ rack-cache (~> 1.2)
21
+ rack-test (~> 0.6.1)
22
+ sprockets (~> 2.2.1)
23
+ activemodel (3.2.11)
24
+ activesupport (= 3.2.11)
25
+ builder (~> 3.0.0)
26
+ activerecord (3.2.11)
27
+ activemodel (= 3.2.11)
28
+ activesupport (= 3.2.11)
29
+ arel (~> 3.0.2)
30
+ tzinfo (~> 0.3.29)
31
+ activeresource (3.2.11)
32
+ activemodel (= 3.2.11)
33
+ activesupport (= 3.2.11)
34
+ activesupport (3.2.11)
35
+ i18n (~> 0.6)
36
+ multi_json (~> 1.0)
37
+ arel (3.0.2)
38
+ builder (3.0.4)
39
+ erubis (2.7.0)
40
+ hike (1.2.1)
41
+ i18n (0.6.1)
42
+ journey (1.0.4)
43
+ json (1.7.6)
44
+ mail (2.4.4)
44
45
  i18n (>= 0.4.0)
45
46
  mime-types (~> 1.16)
46
47
  treetop (~> 1.4.8)
47
- mime-types (1.16)
48
- polyglot (0.3.1)
49
- rack (1.2.2)
50
- rack-mount (0.6.14)
51
- rack (>= 1.0.0)
52
- rack-test (0.5.7)
48
+ mime-types (1.19)
49
+ multi_json (1.5.0)
50
+ polyglot (0.3.3)
51
+ rack (1.4.4)
52
+ rack-cache (1.2)
53
+ rack (>= 0.4)
54
+ rack-ssl (1.3.2)
55
+ rack
56
+ rack-test (0.6.2)
53
57
  rack (>= 1.0)
54
- rails (3.0.7)
55
- actionmailer (= 3.0.7)
56
- actionpack (= 3.0.7)
57
- activerecord (= 3.0.7)
58
- activeresource (= 3.0.7)
59
- activesupport (= 3.0.7)
58
+ rails (3.2.11)
59
+ actionmailer (= 3.2.11)
60
+ actionpack (= 3.2.11)
61
+ activerecord (= 3.2.11)
62
+ activeresource (= 3.2.11)
63
+ activesupport (= 3.2.11)
60
64
  bundler (~> 1.0)
61
- railties (= 3.0.7)
62
- railties (3.0.7)
63
- actionpack (= 3.0.7)
64
- activesupport (= 3.0.7)
65
+ railties (= 3.2.11)
66
+ railties (3.2.11)
67
+ actionpack (= 3.2.11)
68
+ activesupport (= 3.2.11)
69
+ rack-ssl (~> 1.3.2)
65
70
  rake (>= 0.8.7)
66
- thor (~> 0.14.4)
67
- rake (0.8.7)
68
- redcarpet (2.1.0)
69
- thor (0.14.6)
70
- treetop (1.4.9)
71
+ rdoc (~> 3.4)
72
+ thor (>= 0.14.6, < 2.0)
73
+ rake (10.0.3)
74
+ rdoc (3.12)
75
+ json (~> 1.4)
76
+ redcarpet (2.2.2)
77
+ sprockets (2.2.2)
78
+ hike (~> 1.2)
79
+ multi_json (~> 1.0)
80
+ rack (~> 1.0)
81
+ tilt (~> 1.1, != 1.3.0)
82
+ thor (0.16.0)
83
+ tilt (1.3.3)
84
+ treetop (1.4.12)
85
+ polyglot
71
86
  polyglot (>= 0.3.1)
72
- tzinfo (0.3.26)
87
+ tzinfo (0.3.35)
73
88
 
74
89
  PLATFORMS
75
90
  ruby
76
91
 
77
92
  DEPENDENCIES
78
93
  markerb!
79
- rails (= 3.0.7)
94
+ rails (~> 3.0)
data/Rakefile CHANGED
@@ -1,29 +1,25 @@
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'
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
11
3
 
12
4
  require 'rake/testtask'
5
+ require 'rdoc/task'
6
+
7
+ desc 'Default: run unit tests.'
8
+ task :default => :test
13
9
 
10
+ desc 'Test the simple_form plugin.'
14
11
  Rake::TestTask.new(:test) do |t|
15
12
  t.libs << 'lib'
16
13
  t.libs << 'test'
17
14
  t.pattern = 'test/**/*_test.rb'
18
- t.verbose = false
15
+ t.verbose = true
19
16
  end
20
17
 
21
- task :default => :test
22
-
23
- Rake::RDocTask.new(:rdoc) do |rdoc|
18
+ desc 'Generate documentation for the markerb plugin.'
19
+ RDoc::Task.new(:rdoc) do |rdoc|
24
20
  rdoc.rdoc_dir = 'rdoc'
25
- rdoc.title = 'Handlers'
26
- rdoc.options << '--line-numbers' << '--inline-source'
27
- rdoc.rdoc_files.include('README.rdoc')
21
+ rdoc.title = 'Markerb'
22
+ rdoc.options << '--line-numbers'
23
+ rdoc.rdoc_files.include('README.md')
28
24
  rdoc.rdoc_files.include('lib/**/*.rb')
29
- end
25
+ end
data/lib/markerb.rb CHANGED
@@ -3,8 +3,9 @@ require "redcarpet"
3
3
  require "markerb/railtie"
4
4
 
5
5
  module Markerb
6
- mattr_accessor :processing_options
7
- @@processing_options = []
6
+ mattr_accessor :processing_options, :renderer
7
+ @@processing_options = {}
8
+ @@renderer = Redcarpet::Render::HTML
8
9
 
9
10
  class Handler
10
11
  def erb_handler
@@ -14,7 +15,7 @@ module Markerb
14
15
  def call(template)
15
16
  compiled_source = erb_handler.call(template)
16
17
  if template.formats.include?(:html)
17
- "Redcarpet::Markdown.new(Redcarpet::Render::HTML, *Markerb.processing_options).render(begin;#{compiled_source};end)"
18
+ "Redcarpet::Markdown.new(Markerb.renderer, Markerb.processing_options).render(begin;#{compiled_source};end).html_safe"
18
19
  else
19
20
  compiled_source
20
21
  end
@@ -1,3 +1,3 @@
1
1
  module Markerb
2
- VERSION = "1.0.0"
3
- end
2
+ VERSION = "1.0.1"
3
+ end
data/test/markerb_test.rb CHANGED
@@ -12,6 +12,18 @@ class Notifier < ActionMailer::Base
12
12
  end
13
13
  end
14
14
 
15
+ def link(format_type)
16
+ mail(:to => 'foo@bar.com', :from => "john.doe@example.com") do |format|
17
+ format.send(format_type)
18
+ end
19
+ end
20
+
21
+ def user(format_type)
22
+ mail(:to => 'foo@bar.com', :from => "john.doe@example.com") do |format|
23
+ format.send(format_type)
24
+ end
25
+ end
26
+
15
27
  def multiple_format_contact(recipient)
16
28
  @recipient = recipient
17
29
  mail(:to => @recipient, :from => "john.doe@example.com", :template => "contact") do |format|
@@ -21,8 +33,30 @@ class Notifier < ActionMailer::Base
21
33
  end
22
34
  end
23
35
 
36
+ class TestRenderer < Redcarpet::Render::HTML
37
+ attr_accessor :show_text
38
+ def initialize(render_options = {})
39
+ @show_text = render_options.delete(:show_text)
40
+ super(render_options)
41
+ end
42
+
43
+ def normal_text(text)
44
+ show_text ? "TEST #{text}" : "TEST"
45
+ end
46
+ end
47
+
24
48
  class MarkerbTest < ActiveSupport::TestCase
25
49
 
50
+ setup do
51
+ @original_renderer = Markerb.renderer
52
+ @original_processing_options = Markerb.processing_options
53
+ end
54
+
55
+ teardown do
56
+ Markerb.renderer = @original_renderer
57
+ Markerb.processing_options = @original_processing_options
58
+ end
59
+
26
60
  test "plain text should be sent as a plain text" do
27
61
  email = Notifier.contact("you@example.com", :text)
28
62
  assert_equal "text/plain", email.mime_type
@@ -46,4 +80,31 @@ class MarkerbTest < ActiveSupport::TestCase
46
80
  assert_equal "<p>Dual templates <strong>rocks</strong>!</p>",
47
81
  email.parts[1].body.encoded.strip
48
82
  end
49
- end
83
+
84
+ test "with a custom renderer" do
85
+ Markerb.renderer = TestRenderer
86
+ email = Notifier.contact("you@example.com", :html)
87
+ assert_equal "text/html", email.mime_type
88
+ assert_equal "<p>TEST<strong>TEST</strong>TEST</p>", email.body.encoded.strip
89
+ end
90
+
91
+ test "with a custom renderer and options" do
92
+ Markerb.renderer = TestRenderer.new(:show_text => true)
93
+ email = Notifier.contact("you@example.com", :html)
94
+ assert_equal "text/html", email.mime_type
95
+ assert_equal "<p>TEST Dual templates <strong>TEST rocks</strong>TEST !</p>", email.body.encoded.strip
96
+ end
97
+
98
+ test 'with custom markdown processing options' do
99
+ Markerb.processing_options = {:autolink => true}
100
+ email = Notifier.link(:html)
101
+ assert_equal "text/html", email.mime_type
102
+ assert_equal '<p>Hello from <a href="http://www.fcstpauli.com">http://www.fcstpauli.com</a></p>', email.body.encoded.strip
103
+ end
104
+
105
+ test 'with partial' do
106
+ email = Notifier.user(:html)
107
+ assert_equal "text/html", email.mime_type
108
+ assert_equal '<p>woot! <strong>Partial</strong></p>', email.body.encoded.strip
109
+ end
110
+ end
@@ -0,0 +1 @@
1
+ woot! **Partial**
@@ -0,0 +1 @@
1
+ Hello from http://www.fcstpauli.com
@@ -0,0 +1 @@
1
+ <%= render :partial => 'user_info' %>
metadata CHANGED
@@ -1,27 +1,32 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markerb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
5
4
  prerelease:
5
+ version: 1.0.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - José Valim
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-05 00:00:00.000000000 Z
12
+ date: 2013-01-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
+ type: :runtime
16
+ prerelease: false
15
17
  name: redcarpet
16
- requirement: &2152594060 !ruby/object:Gem::Requirement
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ! '>='
22
+ - !ruby/object:Gem::Version
23
+ version: '2.0'
24
+ requirement: !ruby/object:Gem::Requirement
17
25
  none: false
18
26
  requirements:
19
27
  - - ! '>='
20
28
  - !ruby/object:Gem::Version
21
29
  version: '2.0'
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: *2152594060
25
30
  description: Multipart templates made easy with Markdown + ERb
26
31
  email: contact@plataformatec.com.br
27
32
  executables: []
@@ -43,7 +48,10 @@ files:
43
48
  - test/generator_test.rb
44
49
  - test/markerb_test.rb
45
50
  - test/test_helper.rb
51
+ - test/views/notifier/_user_info.markerb
46
52
  - test/views/notifier/contact.markerb
53
+ - test/views/notifier/link.markerb
54
+ - test/views/notifier/user.markerb
47
55
  homepage: http://github.com/plataformatec/markerb
48
56
  licenses: []
49
57
  post_install_message:
@@ -55,16 +63,22 @@ required_ruby_version: !ruby/object:Gem::Requirement
55
63
  requirements:
56
64
  - - ! '>='
57
65
  - !ruby/object:Gem::Version
66
+ segments:
67
+ - 0
68
+ hash: 4054513018052400510
58
69
  version: '0'
59
70
  required_rubygems_version: !ruby/object:Gem::Requirement
60
71
  none: false
61
72
  requirements:
62
73
  - - ! '>='
63
74
  - !ruby/object:Gem::Version
75
+ segments:
76
+ - 0
77
+ hash: 4054513018052400510
64
78
  version: '0'
65
79
  requirements: []
66
80
  rubyforge_project:
67
- rubygems_version: 1.8.15
81
+ rubygems_version: 1.8.24
68
82
  signing_key:
69
83
  specification_version: 3
70
84
  summary: Multipart templates made easy with Markdown + ERb
@@ -72,4 +86,7 @@ test_files:
72
86
  - test/generator_test.rb
73
87
  - test/markerb_test.rb
74
88
  - test/test_helper.rb
89
+ - test/views/notifier/_user_info.markerb
75
90
  - test/views/notifier/contact.markerb
91
+ - test/views/notifier/link.markerb
92
+ - test/views/notifier/user.markerb