markerb 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b3111a5755207d9dfb330521b7bea559108f5190
4
- data.tar.gz: 614b823e13c5c9d345e08916d30604be92ac0a5b
3
+ metadata.gz: 9bd7b5190ebf252b9548185f66b1652ef1660e23
4
+ data.tar.gz: 5294a6472a029bbcf3494892dc8e2ff44ee8ead1
5
5
  SHA512:
6
- metadata.gz: 34d1b7b2686139c9e9d9dbed0c957256dce2c7658413ca629d661f234f57adbae870687594ae37279cca15487571d9d086652ab9574ab42900aa97f408aff1b1
7
- data.tar.gz: 4c0f822bdfa2a984f8dbe5ba0ce1cfd87c2af79642f1661307b3fedf39860151c1de4066be3cc0a6be3124eb63e5826b0c4206f3448e0b6e2f341d698219c5db
6
+ metadata.gz: ba587a666a3394d8ce656c9685ec12dba5eb7d791956ad4bc50ad0264746e2150e44689f5fcf4fe0e897a520df8839a630b52ec9870122fa684a7a696861e43d
7
+ data.tar.gz: 54d187b157c8df8fb3f19876e948c834264a65285556ef506c7057a91325c53c7dc3764bcefbfaa7cb1a99f87cc13e6dfff101f103638787cbc04055664e5fce
@@ -1,4 +1,4 @@
1
- Copyright 2011-2014 Plataformatec (http://blog.plataformatec.com.br)
1
+ Copyright 2011-2015 Plataformatec (http://blog.plataformatec.com.br)
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -34,6 +34,22 @@ It will generate two parts, one in text and another in html when delivered. Befo
34
34
 
35
35
  Enjoy!
36
36
 
37
+ ## Installation
38
+
39
+ Add it to your Gemfile, with either the `redcarpet` or `kramdown` parser:
40
+
41
+ ```ruby
42
+ gem 'markerb'
43
+ gem 'redcarpet', '>= 2.0'
44
+ # gem 'kramdown'
45
+ ```
46
+
47
+ Run the following command to install it:
48
+
49
+ ```console
50
+ bundle install
51
+ ```
52
+
37
53
  ## Bug reports
38
54
 
39
55
  If you discover any bugs, feel free to create an issue on GitHub. Please add as much information as
@@ -48,4 +64,4 @@ https://github.com/plataformatec/markerb/issues
48
64
 
49
65
  ## License
50
66
 
51
- MIT License. Copyright 2011-2014 Plataformatec. http://plataformatec.com.br
67
+ MIT License. Copyright 2011-2015 Plataformatec. http://plataformatec.com.br
@@ -1,13 +1,9 @@
1
1
  require "action_view"
2
2
  require "action_view/template"
3
- require "redcarpet"
3
+ require "markerb/markdown"
4
4
  require "markerb/railtie"
5
5
 
6
6
  module Markerb
7
- mattr_accessor :processing_options, :renderer
8
- @@processing_options = {}
9
- @@renderer = Redcarpet::Render::HTML
10
-
11
7
  class Handler
12
8
  def erb_handler
13
9
  @erb_handler ||= ActionView::Template.registered_template_handler(:erb)
@@ -16,7 +12,7 @@ module Markerb
16
12
  def call(template)
17
13
  compiled_source = erb_handler.call(template)
18
14
  if template.formats.include?(:html)
19
- "Redcarpet::Markdown.new(Markerb.renderer, Markerb.processing_options).render(begin;#{compiled_source};end).html_safe"
15
+ "Markerb::Markdown.to_html(begin;#{compiled_source};end).html_safe"
20
16
  else
21
17
  compiled_source
22
18
  end
@@ -0,0 +1,17 @@
1
+ module Markerb
2
+ mattr_accessor :processing_options, :renderer
3
+ @@processing_options = {}
4
+
5
+ class Markdown
6
+ def self.to_html(compiled_source)
7
+ if defined?(Redcarpet)
8
+ Markerb.renderer ||= Redcarpet::Render::HTML
9
+ Redcarpet::Markdown.new(Markerb.renderer, Markerb.processing_options).render(compiled_source)
10
+ elsif defined?(Kramdown)
11
+ Kramdown::Document.new(compiled_source, Markerb.processing_options).to_html
12
+ else
13
+ raise StandardError, "Markdown processor unavailable, please add either Redcarpet or Kramdown to your project"
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,3 +1,3 @@
1
1
  module Markerb
2
- VERSION = "1.0.2"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -0,0 +1,30 @@
1
+ require "test_helper"
2
+
3
+ class MarkdownTest < ActiveSupport::TestCase
4
+ setup do
5
+ @original_redcarpet = Redcarpet
6
+ @original_kramdown = Kramdown
7
+ end
8
+
9
+ teardown do
10
+ Object.const_set(:Redcarpet, @original_redcarpet) unless defined?(Redcarpet)
11
+ Object.const_set(:Kramdown, @original_kramdown) unless defined?(Kramdown)
12
+ end
13
+
14
+ test 'with Redcarpet markdown processor' do
15
+ Object.send(:remove_const, :Kramdown)
16
+ assert_equal "<p>Dual templates <strong>rocks</strong>!</p>", Markerb::Markdown.to_html("Dual templates **rocks**!").strip
17
+ end
18
+
19
+ test 'with Kramdown markdown processor' do
20
+ Object.send(:remove_const, :Redcarpet)
21
+ assert_equal "<p>Dual templates <strong>rocks</strong>!</p>", Markerb::Markdown.to_html("Dual templates **rocks**!").strip
22
+ end
23
+
24
+ test 'when there is no known markdown processor available' do
25
+ Object.send(:remove_const, :Redcarpet)
26
+ Object.send(:remove_const, :Kramdown)
27
+
28
+ assert_raise(StandardError) { Markerb::Markdown.to_html("Dual templates **rocks**!") }
29
+ end
30
+ end
@@ -9,10 +9,14 @@ require "action_mailer"
9
9
  require "rails/railtie"
10
10
  require "rails/generators"
11
11
  require "rails/generators/test_case"
12
+ require "redcarpet"
13
+ require "kramdown"
12
14
 
13
15
  $:.unshift File.expand_path("../../lib", __FILE__)
14
16
  require "markerb"
15
17
 
18
+ ActiveSupport::TestCase.test_order = :sorted if ActiveSupport::TestCase.respond_to? :test_order=
19
+
16
20
  # Avoid annoying warning from I18n.
17
21
  I18n.enforce_available_locales = false
18
22
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markerb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - José Valim
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-06 00:00:00.000000000 Z
11
+ date: 2015-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redcarpet
@@ -17,13 +17,27 @@ dependencies:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '2.0'
20
- type: :runtime
20
+ type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: kramdown
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  description: Multipart templates made easy with Markdown + ERb
28
42
  email: contact@plataformatec.com.br
29
43
  executables: []
@@ -33,11 +47,14 @@ files:
33
47
  - MIT-LICENSE
34
48
  - README.md
35
49
  - lib/generators/markerb/mailer/mailer_generator.rb
50
+ - lib/generators/markerb/mailer/templates/layout.markerb
36
51
  - lib/generators/markerb/mailer/templates/view.markerb
37
52
  - lib/markerb.rb
53
+ - lib/markerb/markdown.rb
38
54
  - lib/markerb/railtie.rb
39
55
  - lib/markerb/version.rb
40
56
  - test/generator_test.rb
57
+ - test/markdown_test.rb
41
58
  - test/markerb_test.rb
42
59
  - test/test_helper.rb
43
60
  homepage: http://github.com/plataformatec/markerb
@@ -60,11 +77,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
60
77
  version: '0'
61
78
  requirements: []
62
79
  rubyforge_project:
63
- rubygems_version: 2.2.2
80
+ rubygems_version: 2.4.8
64
81
  signing_key:
65
82
  specification_version: 4
66
83
  summary: Multipart templates made easy with Markdown + ERb
67
84
  test_files:
68
85
  - test/generator_test.rb
86
+ - test/markdown_test.rb
69
87
  - test/markerb_test.rb
70
88
  - test/test_helper.rb