mongoid_markdown_extension 0.1.1 → 0.1.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 03c4b02c10ad8781fb5c2a38dbe9274656e00fd1
4
- data.tar.gz: 7ecd48c6d029381424e1b485b97e072eaeba4107
3
+ metadata.gz: ed5543f899cfbb9a773dbb7a05f05d6f8e9c0037
4
+ data.tar.gz: da87d5dc825cdeeffb2ad3742041ba4c0c579673
5
5
  SHA512:
6
- metadata.gz: 549ad3c2e30fc62e3396da409a1c860bfdedb285f25ed31b2a097e5afd82f6bf3af7f18bee5697dfa3180672ada70011ab9ce3b3ac361037efd8c822de5da6a5
7
- data.tar.gz: 9ef5d2486dc80d828034a63dc4e6ee6b4b877458f88a145848c34d3a526e09bdb43413e305e00173f93195afa0ed6e8e6a3e1dbe3b3557475a7a93175e6181d2
6
+ metadata.gz: 88f89f6fcad77e454afd7084cf6ceef3302b83a370fd8989cb2f3fe8e4d092791965cfcd62eeaae4575f59f8babd940f864aaf1d68a4a68f186b8a6d3929a62b
7
+ data.tar.gz: 9c0ad7920542db4e0038fbab17b7c7ad5edbbf951f96db80d0eb41cedbba29913b61c514fb8cb2af413e2974f577d236c0ace6a1aeebc9ab80c062e9964a54fc
data/.travis.yml CHANGED
@@ -1,10 +1,11 @@
1
1
  language: ruby
2
2
  cache: bundler
3
3
  script: 'bundle exec rake'
4
+ sudo: false
4
5
 
5
6
  notifications:
6
7
  email:
7
8
  recipients:
8
9
  - tomas.celizna@gmail.com
9
10
  on_failure: change
10
- on_success: never
11
+ on_success: never
@@ -2,30 +2,29 @@ require 'redcarpet'
2
2
 
3
3
  module MongoidMarkdownExtension
4
4
  class InlineRenderer < Redcarpet::Render::HTML
5
-
6
5
  include Redcarpet::Render::SmartyPants
7
6
 
8
- def block_code code, language
7
+ def block_code(_code, _language)
9
8
  nil
10
9
  end
11
10
 
12
- def block_quote quote
11
+ def block_quote(_quote)
13
12
  nil
14
13
  end
15
14
 
16
- def block_html raw_html
15
+ def block_html(_raw_html)
17
16
  nil
18
17
  end
19
18
 
20
- def footnotes content
19
+ def footnotes(_content)
21
20
  nil
22
21
  end
23
22
 
24
- def footnote_def content, number
23
+ def footnote_def(_content, _number)
25
24
  nil
26
25
  end
27
26
 
28
- def header text, header_level
27
+ def header(_text, _header_level)
29
28
  nil
30
29
  end
31
30
 
@@ -33,17 +32,16 @@ module MongoidMarkdownExtension
33
32
  nil
34
33
  end
35
34
 
36
- def list contents, list_type
35
+ def list(_contents, _list_type)
37
36
  nil
38
37
  end
39
38
 
40
- def list_item text, list_type
39
+ def list_item(_text, _list_type)
41
40
  nil
42
41
  end
43
42
 
44
- def paragraph text
45
- text
43
+ def paragraph(text)
44
+ text + "<br /><br />"
46
45
  end
47
-
48
46
  end
49
47
  end
@@ -3,8 +3,7 @@ require 'redcarpet/render_strip'
3
3
 
4
4
  module MongoidMarkdownExtension
5
5
  class Markdown < String
6
-
7
- def initialize str
6
+ def initialize(str)
8
7
  super str.to_s
9
8
  @str = str.to_s
10
9
  end
@@ -18,7 +17,7 @@ module MongoidMarkdownExtension
18
17
  end
19
18
 
20
19
  def to_inline_html
21
- markdown_inline_renderer.render(@str).html_safe
20
+ markdown_inline_renderer.render(@str).html_safe.gsub(/(<br\s?\/?>)+?\Z/, '')
22
21
  end
23
22
 
24
23
  def to_stripped_s
@@ -49,7 +48,6 @@ module MongoidMarkdownExtension
49
48
  # ---------------------------------------------------------------------
50
49
 
51
50
  class << self
52
-
53
51
  attr_accessor :configuration
54
52
 
55
53
  def configure
@@ -61,24 +59,23 @@ module MongoidMarkdownExtension
61
59
  @configuration ||= Configuration.new
62
60
  end
63
61
 
64
- def demongoize value
62
+ def demongoize(value)
65
63
  Markdown.new(value)
66
64
  end
67
65
 
68
- def mongoize value
66
+ def mongoize(value)
69
67
  case value
70
68
  when Markdown then value.mongoize
71
69
  else value
72
70
  end
73
71
  end
74
72
 
75
- def evolve value
73
+ def evolve(value)
76
74
  case value
77
75
  when Markdown then value.mongoize
78
76
  else value
79
77
  end
80
78
  end
81
-
82
79
  end
83
80
  end
84
81
 
@@ -1,3 +1,3 @@
1
1
  module MongoidMarkdownExtension
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -11,7 +11,6 @@ end
11
11
 
12
12
  module MongoidMarkdownExtension
13
13
  describe Markdown do
14
-
15
14
  let(:string) { 'some text with _italic_' }
16
15
  subject { MongoidMarkdownExtension::Markdown.new(string) }
17
16
 
@@ -23,14 +22,7 @@ module MongoidMarkdownExtension
23
22
  end
24
23
  end
25
24
  it 'returns default values' do
26
- MongoidMarkdownExtension::Markdown.configuration.extensions.must_equal({
27
- autolink: true,
28
- footnotes: true,
29
- highlight: true,
30
- space_after_headers: true,
31
- strikethrough: true,
32
- superscript: true
33
- })
25
+ MongoidMarkdownExtension::Markdown.configuration.extensions.must_equal(autolink: true, footnotes: true, highlight: true, space_after_headers: true, strikethrough: true, superscript: true)
34
26
  MongoidMarkdownExtension::Markdown.configuration.render_options.must_equal({})
35
27
  end
36
28
  end
@@ -54,11 +46,16 @@ module MongoidMarkdownExtension
54
46
  end
55
47
 
56
48
  describe '#to_inline_html' do
49
+ let(:string) { "some text with _italic_\n\nfoo" }
50
+
57
51
  it 'survives nil' do
58
52
  MongoidMarkdownExtension::Markdown.new(nil).to_inline_html.must_equal ''
59
53
  end
60
54
  it 'converts the string to html' do
61
- subject.to_inline_html.wont_include "<p>"
55
+ subject.to_inline_html.wont_include '<p>'
56
+ end
57
+ it 'replaces <p> with <br />' do
58
+ subject.to_inline_html.must_equal 'some text with <em>italic</em><br /><br />foo'
62
59
  end
63
60
  end
64
61
 
@@ -67,7 +64,7 @@ module MongoidMarkdownExtension
67
64
  MongoidMarkdownExtension::Markdown.new(nil).to_stripped_s.must_equal ''
68
65
  end
69
66
  it 'converts the markdown to stripped string' do
70
- subject.to_stripped_s.wont_include "_"
67
+ subject.to_stripped_s.wont_include '_'
71
68
  end
72
69
  end
73
70
 
@@ -101,6 +98,5 @@ module MongoidMarkdownExtension
101
98
  MongoidMarkdownExtension::Markdown.demongoize(string).must_be_kind_of MongoidMarkdownExtension::Markdown
102
99
  end
103
100
  end
104
-
105
101
  end
106
102
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid_markdown_extension
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomáš Celizna
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-05 00:00:00.000000000 Z
11
+ date: 2016-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redcarpet
@@ -128,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
128
  version: '0'
129
129
  requirements: []
130
130
  rubyforge_project:
131
- rubygems_version: 2.4.8
131
+ rubygems_version: 2.4.6
132
132
  signing_key:
133
133
  specification_version: 4
134
134
  summary: Custom field type for Mongoid that handles Markdown conversion via Redcarpet