maildown 2.0.0 → 2.0.1

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: dc3cbe06b036b2b31896e94b04c323ff7b62ee2a
4
- data.tar.gz: 0569b01477e18c99bbb4bb5d5193b8e867878f21
3
+ metadata.gz: 793a913246a2706d4336913e23b351e8c255c3f3
4
+ data.tar.gz: 0d5295b0a21a1e5d918af96c2ff3d0ed48ad5c3c
5
5
  SHA512:
6
- metadata.gz: cca81efba9a4c9f6e1e86243c33ca4f3e4f2678cd81270699386782da509c13b6410598b629864f436838b28134e24c6c84876f3d635a1bbd845a0fd3ec225b7
7
- data.tar.gz: 459d8382ce237bb3c88773a45990fd3bbd85616ea6f084bde744089645fefe636efb5d8f793a87bb12742692a73bd8a53e7c28ac080836a47016567955788648
6
+ metadata.gz: 32c8aaeaeaa264b09bea442e80e80e5652c6f3b3eaeb22051841b17da1508ded3b020b2980c9dd059597e66f8a684e55f9d331b338d6ff4cd69d6903e9500d09
7
+ data.tar.gz: 0bf4c6835f2e1b74f029eea5214e9ab00cc58d6dddc55b46ed51a8599d777ebe20916ca00c3d5b4f4c1f1557e63b6ea572b8982ec02c3eef466bebdfaaeceadc
data/Rakefile CHANGED
@@ -10,7 +10,7 @@ RDoc::Task.new(:rdoc) do |rdoc|
10
10
  rdoc.rdoc_dir = 'rdoc'
11
11
  rdoc.title = 'Maildown'
12
12
  rdoc.options << '--line-numbers'
13
- rdoc.rdoc_files.include('README.rdoc')
13
+ rdoc.rdoc_files.include('README.md')
14
14
  rdoc.rdoc_files.include('lib/**/*.rb')
15
15
  end
16
16
 
@@ -32,5 +32,4 @@ end
32
32
 
33
33
  task default: :test
34
34
 
35
-
36
35
  require "bundler/gem_tasks"
@@ -1,3 +1,5 @@
1
+ require 'action_mailer'
2
+
1
3
  mail_view_klass = ActionMailer::Base.view_context_class
2
4
  mail_view_klass.default_formats = (mail_view_klass.default_formats << :md)
3
5
  Mime::Type.register "text/md", :md, [], %w(md)
@@ -1,21 +1,46 @@
1
1
  module Maildown
2
2
  module MarkdownEngine
3
3
  def self.to_html(string)
4
- block.call(string)
4
+ html_block.call(string)
5
+ end
6
+
7
+ def self.to_text(string)
8
+ text_block.call(string)
9
+ end
10
+
11
+ def self.set_html(&block)
12
+ @maildown_markdown_engine_html_block = block
5
13
  end
6
14
 
7
15
  def self.set(&block)
8
- Thread.current[:maildown_markdown_engine_block] = block
16
+ set_html(&block)
17
+ end
18
+
19
+ class << self
20
+ extend Gem::Deprecate
21
+ deprecate :set, :set_html, 2017, 6
9
22
  end
10
23
 
11
- def self.block
12
- Thread.current[:maildown_markdown_engine_block] || default
24
+ def self.set_text(&block)
25
+ @maildown_markdown_engine_text_block = block
13
26
  end
14
27
 
15
- def self.default
28
+ def self.html_block
29
+ @maildown_markdown_engine_html_block || default_html_block
30
+ end
31
+
32
+ def self.text_block
33
+ @maildown_markdown_engine_text_block || default_text_block
34
+ end
35
+
36
+ def self.default_html_block
16
37
  require 'kramdown' unless defined? Kramdown
17
38
 
18
39
  ->(string) { Kramdown::Document.new(string).to_html }
19
40
  end
41
+
42
+ def self.default_text_block
43
+ ->(string) { string }
44
+ end
20
45
  end
21
46
  end
@@ -13,7 +13,7 @@ module Maildown
13
13
  end
14
14
 
15
15
  def to_text
16
- string
16
+ Maildown::MarkdownEngine.to_text(string)
17
17
  end
18
18
 
19
19
  def to_html
@@ -1,3 +1,3 @@
1
1
  module Maildown
2
- VERSION = "2.0.0"
2
+ VERSION = "2.0.1"
3
3
  end
@@ -23,4 +23,15 @@ class MarkdownEngineTest < ActiveSupport::TestCase
23
23
  end
24
24
  thread.join
25
25
  end
26
+
27
+ test "custom engine works in multiple threads" do
28
+ Maildown::MarkdownEngine.set do |text|
29
+ "foo: #{text}"
30
+ end
31
+
32
+ thread = Thread.new do
33
+ assert_equal "foo: bar", Maildown::MarkdownEngine.to_html("bar")
34
+ end
35
+ thread.join
36
+ end
26
37
  end
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maildown
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - schneems
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-13 00:00:00.000000000 Z
11
+ date: 2016-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rails
14
+ name: actionmailer
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: railties
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: sqlite3
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -52,6 +66,20 @@ dependencies:
52
66
  - - ">="
53
67
  - !ruby/object:Gem::Version
54
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
55
83
  description: Best practice is to send text/plain && text/html markdown works great
56
84
  for both, so why write your templates twices?
57
85
  email:
@@ -125,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
153
  version: '0'
126
154
  requirements: []
127
155
  rubyforge_project:
128
- rubygems_version: 2.5.1
156
+ rubygems_version: 2.5.2
129
157
  signing_key:
130
158
  specification_version: 4
131
159
  summary: Markdown in your mailbox