mongoid_markdown_extension 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.coveralls.yml +1 -0
- data/README.md +14 -7
- data/lib/mongoid_markdown_extension.rb +2 -1
- data/lib/mongoid_markdown_extension/inline_renderer.rb +49 -0
- data/lib/mongoid_markdown_extension/markdown.rb +9 -1
- data/lib/mongoid_markdown_extension/version.rb +1 -1
- data/test/mongoid_markdown_extension/markdown_test.rb +10 -1
- data/test/test_helper.rb +4 -2
- metadata +19 -20
- data/test/.coveralls.yml +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cbfe523aa17cfbb7cb2df3483b9ca8dc6b82259b
|
4
|
+
data.tar.gz: feeec25b634804a5d648105834190ee34a4d8698
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f58d0894890f64f1d829f55973585656e025ee697dfd6911c734c26902b2d97e4f21a7e1c2ded5f099d38e2df16aba422338ead70b3ee64582fd4fc8ffa41fc3
|
7
|
+
data.tar.gz: a7bc508926ea2a90dac30359dc1048ae00e86cb87c8f7b8f456d1a9895cb6f41e5842e30f3fb907cf44c5baa88c76bf4bcfda18c80dc8292c1fd3619a7ddc12d
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Mongoid Markdown Extension
|
2
2
|
|
3
|
-
[![Build Status](https://travis-ci.org/tomasc/mongoid_markdown_extension.svg)](https://travis-ci.org/tomasc/mongoid_markdown_extension) [![Coverage Status](https://img.shields.io/coveralls/tomasc/mongoid_markdown_extension.svg)](https://coveralls.io/r/tomasc/mongoid_markdown_extension)
|
3
|
+
[![Build Status](https://travis-ci.org/tomasc/mongoid_markdown_extension.svg)](https://travis-ci.org/tomasc/mongoid_markdown_extension) [![Gem Version](https://badge.fury.io/rb/mongoid_markdown_extension.svg)](http://badge.fury.io/rb/mongoid_markdown_extension) [![Coverage Status](https://img.shields.io/coveralls/tomasc/mongoid_markdown_extension.svg)](https://coveralls.io/r/tomasc/mongoid_markdown_extension)
|
4
4
|
|
5
5
|
[Mongoid](https://github.com/mongoid/mongoid) field extension that returns an object with `to_html` method returning the content converted from Markdown syntax to html. The Markdown conversion is done using the [Redcarpet](https://github.com/vmg/redcarpet) library.
|
6
6
|
|
@@ -50,14 +50,21 @@ See [Redcarpet documentation](https://github.com/vmg/redcarpet) for available ex
|
|
50
50
|
|
51
51
|
Add to a Mongoid model:
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
53
|
+
```Ruby
|
54
|
+
class MyModel
|
55
|
+
include Mongoid::Document
|
56
|
+
field :text, type: MongoidMarkdownExtension::Markdown
|
57
|
+
end
|
58
|
+
```
|
57
59
|
|
58
|
-
Use it
|
60
|
+
Use it:
|
59
61
|
|
60
|
-
|
62
|
+
```Ruby
|
63
|
+
my_model.text = "*foo*"
|
64
|
+
|
65
|
+
my_model.text.to_html # => <strong>foo</strong>
|
66
|
+
my_model.text.to_s # => *foo*
|
67
|
+
```
|
61
68
|
|
62
69
|
## Contributing
|
63
70
|
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'redcarpet'
|
2
|
+
|
3
|
+
module MongoidMarkdownExtension
|
4
|
+
class InlineRenderer < Redcarpet::Render::HTML
|
5
|
+
|
6
|
+
include Redcarpet::Render::SmartyPants
|
7
|
+
|
8
|
+
def block_code code, language
|
9
|
+
nil
|
10
|
+
end
|
11
|
+
|
12
|
+
def block_quote quote
|
13
|
+
nil
|
14
|
+
end
|
15
|
+
|
16
|
+
def block_html raw_html
|
17
|
+
nil
|
18
|
+
end
|
19
|
+
|
20
|
+
def footnotes content
|
21
|
+
nil
|
22
|
+
end
|
23
|
+
|
24
|
+
def footnote_def content, number
|
25
|
+
nil
|
26
|
+
end
|
27
|
+
|
28
|
+
def header text, header_level
|
29
|
+
nil
|
30
|
+
end
|
31
|
+
|
32
|
+
def hrule
|
33
|
+
nil
|
34
|
+
end
|
35
|
+
|
36
|
+
def list contents, list_type
|
37
|
+
nil
|
38
|
+
end
|
39
|
+
|
40
|
+
def list_item text, list_type
|
41
|
+
nil
|
42
|
+
end
|
43
|
+
|
44
|
+
def paragraph text
|
45
|
+
text
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
@@ -16,6 +16,10 @@ module MongoidMarkdownExtension
|
|
16
16
|
markdown_renderer.render(@str).html_safe
|
17
17
|
end
|
18
18
|
|
19
|
+
def to_inline_html
|
20
|
+
markdown_inline_renderer.render(@str).html_safe
|
21
|
+
end
|
22
|
+
|
19
23
|
def mongoize
|
20
24
|
@str
|
21
25
|
end
|
@@ -29,6 +33,10 @@ module MongoidMarkdownExtension
|
|
29
33
|
)
|
30
34
|
end
|
31
35
|
|
36
|
+
def markdown_inline_renderer
|
37
|
+
Redcarpet::Markdown.new(InlineRenderer, tables: false)
|
38
|
+
end
|
39
|
+
|
32
40
|
# ---------------------------------------------------------------------
|
33
41
|
|
34
42
|
class << self
|
@@ -85,4 +93,4 @@ module MongoidMarkdownExtension
|
|
85
93
|
end
|
86
94
|
|
87
95
|
# ---------------------------------------------------------------------
|
88
|
-
end
|
96
|
+
end
|
@@ -53,6 +53,15 @@ module MongoidMarkdownExtension
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
+
describe '#to_inline_html' do
|
57
|
+
it 'survives nil' do
|
58
|
+
MongoidMarkdownExtension::Markdown.new(nil).to_inline_html.must_equal ''
|
59
|
+
end
|
60
|
+
it 'converts the string to html' do
|
61
|
+
subject.to_inline_html.wont_include "<p>"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
56
65
|
describe '#mongoize' do
|
57
66
|
it 'returns string' do
|
58
67
|
subject.mongoize.must_equal string
|
@@ -85,4 +94,4 @@ module MongoidMarkdownExtension
|
|
85
94
|
end
|
86
95
|
|
87
96
|
end
|
88
|
-
end
|
97
|
+
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,83 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid_markdown_extension
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomas Celizna
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redcarpet
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 3.1.2
|
20
20
|
type: :runtime
|
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: 3.1.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: mongoid
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '4.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '4.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '1.6'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.6'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: coveralls
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
description: Custom field type for Mongoid that handles Markdown conversion via Redcarpet
|
@@ -88,17 +88,18 @@ executables: []
|
|
88
88
|
extensions: []
|
89
89
|
extra_rdoc_files: []
|
90
90
|
files:
|
91
|
-
- .
|
92
|
-
- .
|
91
|
+
- ".coveralls.yml"
|
92
|
+
- ".gitignore"
|
93
|
+
- ".travis.yml"
|
93
94
|
- Gemfile
|
94
95
|
- LICENSE
|
95
96
|
- README.md
|
96
97
|
- Rakefile
|
97
98
|
- lib/mongoid_markdown_extension.rb
|
99
|
+
- lib/mongoid_markdown_extension/inline_renderer.rb
|
98
100
|
- lib/mongoid_markdown_extension/markdown.rb
|
99
101
|
- lib/mongoid_markdown_extension/version.rb
|
100
102
|
- mongoid_markdown_extension.gemspec
|
101
|
-
- test/.coveralls.yml
|
102
103
|
- test/mongoid_markdown_extension/markdown_test.rb
|
103
104
|
- test/test_helper.rb
|
104
105
|
homepage: https://github.com/tomasc/mongoid_markdown_extension
|
@@ -111,23 +112,21 @@ require_paths:
|
|
111
112
|
- lib
|
112
113
|
required_ruby_version: !ruby/object:Gem::Requirement
|
113
114
|
requirements:
|
114
|
-
- -
|
115
|
+
- - ">="
|
115
116
|
- !ruby/object:Gem::Version
|
116
117
|
version: '0'
|
117
118
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
119
|
requirements:
|
119
|
-
- -
|
120
|
+
- - ">="
|
120
121
|
- !ruby/object:Gem::Version
|
121
122
|
version: '0'
|
122
123
|
requirements: []
|
123
124
|
rubyforge_project:
|
124
|
-
rubygems_version: 2.
|
125
|
+
rubygems_version: 2.4.8
|
125
126
|
signing_key:
|
126
127
|
specification_version: 4
|
127
128
|
summary: Custom field type for Mongoid that handles Markdown conversion via Redcarpet
|
128
129
|
gem.
|
129
130
|
test_files:
|
130
|
-
- test/.coveralls.yml
|
131
131
|
- test/mongoid_markdown_extension/markdown_test.rb
|
132
132
|
- test/test_helper.rb
|
133
|
-
has_rdoc:
|
data/test/.coveralls.yml
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
service_name: travis-ci
|