mongoid-markdown 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -0
- data/Gemfile.lock +19 -0
- data/{README.rdoc → README.md} +19 -8
- data/VERSION +1 -1
- data/lib/mongoid-markdown.rb +4 -107
- data/lib/mongoid-markdown/mongoid_new.rb +133 -0
- data/lib/mongoid-markdown/mongoid_old.rb +109 -0
- data/mongoid-markdown.gemspec +71 -0
- data/spec/mongoid-markdown_spec.rb +22 -3
- data/spec/spec_helper.rb +10 -7
- metadata +39 -4
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,14 +1,30 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
+
activemodel (3.2.8)
|
5
|
+
activesupport (= 3.2.8)
|
6
|
+
builder (~> 3.0.0)
|
7
|
+
activesupport (3.2.8)
|
8
|
+
i18n (~> 0.6)
|
9
|
+
multi_json (~> 1.0)
|
10
|
+
builder (3.0.0)
|
4
11
|
diff-lcs (1.1.3)
|
5
12
|
git (1.2.5)
|
13
|
+
i18n (0.6.1)
|
6
14
|
jeweler (1.8.4)
|
7
15
|
bundler (~> 1.0)
|
8
16
|
git (>= 1.2.5)
|
9
17
|
rake
|
10
18
|
rdoc
|
11
19
|
json (1.7.5)
|
20
|
+
mongoid (3.0.5)
|
21
|
+
activemodel (~> 3.1)
|
22
|
+
moped (~> 1.1)
|
23
|
+
origin (~> 1.0)
|
24
|
+
tzinfo (~> 0.3.22)
|
25
|
+
moped (1.2.1)
|
26
|
+
multi_json (1.3.6)
|
27
|
+
origin (1.0.7)
|
12
28
|
rake (0.9.2.2)
|
13
29
|
rdiscount (1.6.8)
|
14
30
|
rdoc (3.12)
|
@@ -21,6 +37,7 @@ GEM
|
|
21
37
|
rspec-expectations (2.11.3)
|
22
38
|
diff-lcs (~> 1.1.3)
|
23
39
|
rspec-mocks (2.11.2)
|
40
|
+
tzinfo (0.3.33)
|
24
41
|
|
25
42
|
PLATFORMS
|
26
43
|
ruby
|
@@ -28,6 +45,8 @@ PLATFORMS
|
|
28
45
|
DEPENDENCIES
|
29
46
|
bundler (>= 1.0.0)
|
30
47
|
jeweler (>= 1.8.4)
|
48
|
+
mongoid (>= 2.0)
|
49
|
+
moped
|
31
50
|
rdiscount
|
32
51
|
rdoc (>= 3.12)
|
33
52
|
rspec (>= 2.8.0)
|
data/{README.rdoc → README.md}
RENAMED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
1
|
+
# Mongoid Markdown
|
2
2
|
|
3
|
-
Add Markdown functionality
|
3
|
+
Add Markdown functionality to any Mongoid object.
|
4
4
|
|
5
5
|
```ruby
|
6
6
|
|
@@ -11,23 +11,34 @@ class Message
|
|
11
11
|
field :body, :markdown => true
|
12
12
|
end
|
13
13
|
|
14
|
+
message = Message.new :body => "## Hello world"
|
14
15
|
|
15
|
-
message
|
16
|
+
message.marked_down? # => false
|
16
17
|
|
17
|
-
message.
|
18
|
+
message.markdown!
|
18
19
|
|
19
|
-
message.
|
20
|
+
message.marked_down? # => true
|
20
21
|
|
21
|
-
message.body
|
22
|
+
puts message.body # => "<h2>Hello world</h2>"
|
22
23
|
|
23
|
-
message.body
|
24
|
+
message.body = "## Goodbye cruel world..."
|
25
|
+
|
26
|
+
message.reload # not sure about this!
|
27
|
+
|
28
|
+
message.marked_down? # => true
|
24
29
|
```
|
25
30
|
|
26
31
|
Enjoy!
|
27
32
|
|
28
33
|
Extracted from: https://github.com/baphled/chat-engine/blob/master/lib/mongoid/markdown.rb
|
29
34
|
|
30
|
-
|
35
|
+
See specs for more usage examples
|
36
|
+
|
37
|
+
Should work on both Mongoid pre 2.4 and later, including 3.x.
|
38
|
+
|
39
|
+
Please help fix any bugs or come with suggestions to improvements.
|
40
|
+
|
41
|
+
## Contributing to mongoid-markdown
|
31
42
|
|
32
43
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
33
44
|
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/lib/mongoid-markdown.rb
CHANGED
@@ -1,110 +1,7 @@
|
|
1
1
|
require 'rdiscount'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
end
|
8
|
-
|
9
|
-
module ClassMethods
|
10
|
-
def markdown(*attributes)
|
11
|
-
write_inheritable_attribute(:markdown_attributes, markdown_attributes + Array(attributes))
|
12
|
-
@markdown_unicode = String.new.respond_to? :chars
|
13
|
-
|
14
|
-
type_options = %w( plain source )
|
15
|
-
|
16
|
-
attributes.each do |attribute|
|
17
|
-
define_method(attribute) do |*type|
|
18
|
-
type = type.first
|
19
|
-
value = read_attribute(attribute)
|
20
|
-
|
21
|
-
if type.nil? && value
|
22
|
-
marked_down[attribute.to_sym] ||= RDiscount.new(value).to_html.html_safe
|
23
|
-
elsif type.nil? && value.nil?
|
24
|
-
nil
|
25
|
-
elsif type_options.include?(type.to_s)
|
26
|
-
send("#{attribute}_#{type}")
|
27
|
-
else
|
28
|
-
raise "I don't understand the `#{type}' option. Try #{type_options.join(' or ')}."
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
define_method("#{attribute}_plain", proc { strip_markdown_html(__send__(attribute)) if __send__(attribute) } )
|
33
|
-
define_method("#{attribute}_source", proc { read_attribute(attribute) } )
|
34
|
-
end
|
35
|
-
|
36
|
-
include InstanceMethods
|
37
|
-
end
|
38
|
-
|
39
|
-
def markdown_attributes
|
40
|
-
read_inheritable_attribute(:markdown_attributes) ||
|
41
|
-
write_inheritable_attribute(:markdown_attributes, [])
|
42
|
-
end
|
43
|
-
|
44
|
-
def field(name, options = {})
|
45
|
-
returning super(name, options.reject { |k, v| k == :markdown }) do
|
46
|
-
markdown name if options[:markdown]
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
module InstanceMethods
|
52
|
-
def marked_down
|
53
|
-
marked_down? ? (@marked_down ||= {}) : @attributes.dup
|
54
|
-
end
|
55
|
-
|
56
|
-
def marked_down?
|
57
|
-
@is_marked_down != false
|
58
|
-
end
|
59
|
-
|
60
|
-
def marked_down=(value)
|
61
|
-
@is_marked_down = !!value
|
62
|
-
end
|
63
|
-
|
64
|
-
def markdown!
|
65
|
-
self.class.markdown_attributes.each { |attr| __send__(attr) }
|
66
|
-
end
|
67
|
-
|
68
|
-
def reload
|
69
|
-
marked_down.clear
|
70
|
-
super
|
71
|
-
end
|
72
|
-
|
73
|
-
def write_attribute(attr_name, value)
|
74
|
-
marked_down[attr_name.to_s] = nil
|
75
|
-
super
|
76
|
-
end
|
77
|
-
|
78
|
-
private
|
79
|
-
def strip_markdown_html(html)
|
80
|
-
returning html.dup.gsub(html_regexp, '') do |h|
|
81
|
-
markdown_glyphs.each do |(entity, char)|
|
82
|
-
sub = [ :gsub!, entity, char ]
|
83
|
-
@textiled_unicode ? h.chars.send(*sub) : h.send(*sub)
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
def markdown_glyphs
|
89
|
-
[[ '’', "'" ],
|
90
|
-
[ '‘', "'" ],
|
91
|
-
[ '<', '<' ],
|
92
|
-
[ '>', '>' ],
|
93
|
-
[ '”', '"' ],
|
94
|
-
[ '“', '"' ],
|
95
|
-
[ '…', '...' ],
|
96
|
-
[ '\1—', '--' ],
|
97
|
-
[ ' → ', '->' ],
|
98
|
-
[ ' – ', '-' ],
|
99
|
-
[ '×', 'x' ],
|
100
|
-
[ '™', '(TM)' ],
|
101
|
-
[ '®', '(R)' ],
|
102
|
-
[ '©', '(C)' ]]
|
103
|
-
end
|
104
|
-
|
105
|
-
def html_regexp
|
106
|
-
%r{<(?:[^>"']+|"(?:\\.|[^\\"]+)*"|'(?:\\.|[^\\']+)*')*>}xm
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
3
|
+
if Mongoid::VERSION < '2.4.0'
|
4
|
+
require 'mongoid-markdown/mongoid_old'
|
5
|
+
else
|
6
|
+
require 'mongoid-markdown/mongoid_new'
|
110
7
|
end
|
@@ -0,0 +1,133 @@
|
|
1
|
+
require 'rdiscount'
|
2
|
+
|
3
|
+
Mongoid::Fields.option :markdown do |model,field,options|
|
4
|
+
options = {} unless options.kind_of?(Hash)
|
5
|
+
|
6
|
+
attribute = field.name.to_sym
|
7
|
+
|
8
|
+
model.class_eval do
|
9
|
+
(self.markdown_attributes ||= []) << attribute
|
10
|
+
|
11
|
+
define_method(attribute) do |*type|
|
12
|
+
type = type.first
|
13
|
+
value = read_attribute(attribute)
|
14
|
+
|
15
|
+
if type.nil? && value
|
16
|
+
marked_down[attribute] ||= RDiscount.new(value).to_html.html_safe
|
17
|
+
elsif type.nil? && value.nil?
|
18
|
+
nil
|
19
|
+
elsif type_options.include?(type.to_s)
|
20
|
+
send("#{attribute}_#{type}")
|
21
|
+
else
|
22
|
+
raise "I don't understand the `#{type}' option. Try #{type_options.join(' or ')}."
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
define_method("#{attribute}_plain", proc { strip_markdown_html(__send__(attribute)) if __send__(attribute) } )
|
27
|
+
define_method("#{attribute}_source", proc { read_attribute(attribute) } )
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
module Mongoid
|
32
|
+
module Markdown
|
33
|
+
extend ActiveSupport::Concern
|
34
|
+
|
35
|
+
included do
|
36
|
+
# attr_accessor :geo
|
37
|
+
cattr_accessor :markdown_attributes
|
38
|
+
@@markdown_attributes = []
|
39
|
+
|
40
|
+
self.send :include, InstanceMethods
|
41
|
+
end
|
42
|
+
|
43
|
+
def marked_down
|
44
|
+
marked_down? ? (@marked_down ||= {}) : @attributes.dup
|
45
|
+
end
|
46
|
+
|
47
|
+
def marked_down?
|
48
|
+
@is_marked_down != false
|
49
|
+
end
|
50
|
+
|
51
|
+
def marked_down=(value)
|
52
|
+
@is_marked_down = !!value
|
53
|
+
end
|
54
|
+
|
55
|
+
def markdown!
|
56
|
+
self.class.markdown_attributes.each { |attr| __send__(attr) }
|
57
|
+
end
|
58
|
+
|
59
|
+
def reload
|
60
|
+
marked_down.clear
|
61
|
+
super
|
62
|
+
end
|
63
|
+
|
64
|
+
def write_attribute(attr_name, value)
|
65
|
+
marked_down[attr_name.to_s] = nil
|
66
|
+
super
|
67
|
+
end
|
68
|
+
|
69
|
+
module InstanceMethods
|
70
|
+
private
|
71
|
+
|
72
|
+
def strip_markdown_html(html)
|
73
|
+
returning html.dup.gsub(html_regexp, '') do |h|
|
74
|
+
markdown_glyphs.each do |(entity, char)|
|
75
|
+
sub = [ :gsub!, entity, char ]
|
76
|
+
@textiled_unicode ? h.chars.send(*sub) : h.send(*sub)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def markdown_glyphs
|
82
|
+
[[ '’', "'" ],
|
83
|
+
[ '‘', "'" ],
|
84
|
+
[ '<', '<' ],
|
85
|
+
[ '>', '>' ],
|
86
|
+
[ '”', '"' ],
|
87
|
+
[ '“', '"' ],
|
88
|
+
[ '…', '...' ],
|
89
|
+
[ '\1—', '--' ],
|
90
|
+
[ ' → ', '->' ],
|
91
|
+
[ ' – ', '-' ],
|
92
|
+
[ '×', 'x' ],
|
93
|
+
[ '™', '(TM)' ],
|
94
|
+
[ '®', '(R)' ],
|
95
|
+
[ '©', '(C)' ]]
|
96
|
+
end
|
97
|
+
|
98
|
+
def html_regexp
|
99
|
+
%r{<(?:[^>"']+|"(?:\\.|[^\\"]+)*"|'(?:\\.|[^\\']+)*')*>}xm
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
module ClassMethods
|
104
|
+
def markdown(*attributes)
|
105
|
+
@markdown_unicode = String.new.respond_to? :chars
|
106
|
+
|
107
|
+
type_options = %w( plain source )
|
108
|
+
|
109
|
+
attributes.each do |attribute|
|
110
|
+
define_method(attribute) do |*type|
|
111
|
+
type = type.first
|
112
|
+
value = read_attribute(attribute)
|
113
|
+
|
114
|
+
if type.nil? && value
|
115
|
+
marked_down[attribute.to_sym] ||= RDiscount.new(value).to_html.html_safe
|
116
|
+
elsif type.nil? && value.nil?
|
117
|
+
nil
|
118
|
+
elsif type_options.include?(type.to_s)
|
119
|
+
send("#{attribute}_#{type}")
|
120
|
+
else
|
121
|
+
raise "I don't understand the `#{type}' option. Try #{type_options.join(' or ')}."
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
define_method("#{attribute}_plain", proc { strip_markdown_html(__send__(attribute)) if __send__(attribute) } )
|
126
|
+
define_method("#{attribute}_source", proc { read_attribute(attribute) } )
|
127
|
+
end
|
128
|
+
|
129
|
+
include InstanceMethods
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
require 'rdiscount'
|
2
|
+
|
3
|
+
module Mongoid
|
4
|
+
module Markdown
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
module ClassMethods
|
8
|
+
# For mongoid < 2.4 only
|
9
|
+
def markdown(*attributes)
|
10
|
+
write_inheritable_attribute(:markdown_attributes, markdown_attributes + Array(attributes))
|
11
|
+
@markdown_unicode = String.new.respond_to? :chars
|
12
|
+
|
13
|
+
type_options = %w( plain source )
|
14
|
+
|
15
|
+
attributes.each do |attribute|
|
16
|
+
define_method(attribute) do |*type|
|
17
|
+
type = type.first
|
18
|
+
value = read_attribute(attribute)
|
19
|
+
|
20
|
+
if type.nil? && value
|
21
|
+
marked_down[attribute.to_sym] ||= RDiscount.new(value).to_html.html_safe
|
22
|
+
elsif type.nil? && value.nil?
|
23
|
+
nil
|
24
|
+
elsif type_options.include?(type.to_s)
|
25
|
+
send("#{attribute}_#{type}")
|
26
|
+
else
|
27
|
+
raise "I don't understand the `#{type}' option. Try #{type_options.join(' or ')}."
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
define_method("#{attribute}_plain", proc { strip_markdown_html(__send__(attribute)) if __send__(attribute) } )
|
32
|
+
define_method("#{attribute}_source", proc { read_attribute(attribute) } )
|
33
|
+
end
|
34
|
+
|
35
|
+
include InstanceMethods
|
36
|
+
end
|
37
|
+
|
38
|
+
def markdown_attributes
|
39
|
+
read_inheritable_attribute(:markdown_attributes) ||
|
40
|
+
write_inheritable_attribute(:markdown_attributes, [])
|
41
|
+
end
|
42
|
+
|
43
|
+
def field(name, options = {})
|
44
|
+
returning super(name, options.reject { |k, v| k == :markdown }) do
|
45
|
+
markdown name if options[:markdown]
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
module InstanceMethods
|
51
|
+
def marked_down
|
52
|
+
marked_down? ? (@marked_down ||= {}) : @attributes.dup
|
53
|
+
end
|
54
|
+
|
55
|
+
def marked_down?
|
56
|
+
@is_marked_down != false
|
57
|
+
end
|
58
|
+
|
59
|
+
def marked_down=(value)
|
60
|
+
@is_marked_down = !!value
|
61
|
+
end
|
62
|
+
|
63
|
+
def markdown!
|
64
|
+
self.class.markdown_attributes.each { |attr| __send__(attr) }
|
65
|
+
end
|
66
|
+
|
67
|
+
def reload
|
68
|
+
marked_down.clear
|
69
|
+
super
|
70
|
+
end
|
71
|
+
|
72
|
+
def write_attribute(attr_name, value)
|
73
|
+
marked_down[attr_name.to_s] = nil
|
74
|
+
super
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
def strip_markdown_html(html)
|
79
|
+
returning html.dup.gsub(html_regexp, '') do |h|
|
80
|
+
markdown_glyphs.each do |(entity, char)|
|
81
|
+
sub = [ :gsub!, entity, char ]
|
82
|
+
@textiled_unicode ? h.chars.send(*sub) : h.send(*sub)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def markdown_glyphs
|
88
|
+
[[ '’', "'" ],
|
89
|
+
[ '‘', "'" ],
|
90
|
+
[ '<', '<' ],
|
91
|
+
[ '>', '>' ],
|
92
|
+
[ '”', '"' ],
|
93
|
+
[ '“', '"' ],
|
94
|
+
[ '…', '...' ],
|
95
|
+
[ '\1—', '--' ],
|
96
|
+
[ ' → ', '->' ],
|
97
|
+
[ ' – ', '-' ],
|
98
|
+
[ '×', 'x' ],
|
99
|
+
[ '™', '(TM)' ],
|
100
|
+
[ '®', '(R)' ],
|
101
|
+
[ '©', '(C)' ]]
|
102
|
+
end
|
103
|
+
|
104
|
+
def html_regexp
|
105
|
+
%r{<(?:[^>"']+|"(?:\\.|[^\\"]+)*"|'(?:\\.|[^\\']+)*')*>}xm
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "mongoid-markdown"
|
8
|
+
s.version = "0.1.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Kristian Mandrup"]
|
12
|
+
s.date = "2012-09-14"
|
13
|
+
s.description = "Easily use markdown with mongoid texts"
|
14
|
+
s.email = "kmandrup@gmail.com"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.md"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".rspec",
|
22
|
+
"Gemfile",
|
23
|
+
"Gemfile.lock",
|
24
|
+
"LICENSE.txt",
|
25
|
+
"README.md",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"lib/mongoid-markdown.rb",
|
29
|
+
"lib/mongoid-markdown/mongoid_new.rb",
|
30
|
+
"lib/mongoid-markdown/mongoid_old.rb",
|
31
|
+
"mongoid-markdown.gemspec",
|
32
|
+
"spec/mongoid-markdown_spec.rb",
|
33
|
+
"spec/spec_helper.rb"
|
34
|
+
]
|
35
|
+
s.homepage = "http://github.com/kristianmandrup/mongoid-markdown"
|
36
|
+
s.licenses = ["MIT"]
|
37
|
+
s.require_paths = ["lib"]
|
38
|
+
s.rubygems_version = "1.8.24"
|
39
|
+
s.summary = "Add markdown functionality to any mongoid text field"
|
40
|
+
|
41
|
+
if s.respond_to? :specification_version then
|
42
|
+
s.specification_version = 3
|
43
|
+
|
44
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
45
|
+
s.add_runtime_dependency(%q<rdiscount>, [">= 0"])
|
46
|
+
s.add_runtime_dependency(%q<moped>, [">= 0"])
|
47
|
+
s.add_runtime_dependency(%q<mongoid>, [">= 2.0"])
|
48
|
+
s.add_development_dependency(%q<rspec>, [">= 2.8.0"])
|
49
|
+
s.add_development_dependency(%q<rdoc>, [">= 3.12"])
|
50
|
+
s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
|
51
|
+
s.add_development_dependency(%q<jeweler>, [">= 1.8.4"])
|
52
|
+
else
|
53
|
+
s.add_dependency(%q<rdiscount>, [">= 0"])
|
54
|
+
s.add_dependency(%q<moped>, [">= 0"])
|
55
|
+
s.add_dependency(%q<mongoid>, [">= 2.0"])
|
56
|
+
s.add_dependency(%q<rspec>, [">= 2.8.0"])
|
57
|
+
s.add_dependency(%q<rdoc>, [">= 3.12"])
|
58
|
+
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
59
|
+
s.add_dependency(%q<jeweler>, [">= 1.8.4"])
|
60
|
+
end
|
61
|
+
else
|
62
|
+
s.add_dependency(%q<rdiscount>, [">= 0"])
|
63
|
+
s.add_dependency(%q<moped>, [">= 0"])
|
64
|
+
s.add_dependency(%q<mongoid>, [">= 2.0"])
|
65
|
+
s.add_dependency(%q<rspec>, [">= 2.8.0"])
|
66
|
+
s.add_dependency(%q<rdoc>, [">= 3.12"])
|
67
|
+
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
68
|
+
s.add_dependency(%q<jeweler>, [">= 1.8.4"])
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
@@ -1,7 +1,26 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class Message
|
4
|
+
include Mongoid::Document
|
5
|
+
include Mongoid::Markdown
|
6
|
+
|
7
|
+
field :body, :markdown => true
|
8
|
+
end
|
2
9
|
|
3
10
|
describe "MongoidMarkdown" do
|
4
|
-
|
5
|
-
|
11
|
+
subject { Message.new :body => markdown_text }
|
12
|
+
|
13
|
+
let(:markdown_text) { '## Hello world '}
|
14
|
+
|
15
|
+
describe '.markdown!' do
|
16
|
+
before :each do
|
17
|
+
subject.markdown!
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should markup text" do
|
21
|
+
subject.marked_down?.should be_true
|
22
|
+
puts subject.body
|
23
|
+
subject.body.should_not == markdown_text
|
24
|
+
end
|
6
25
|
end
|
7
26
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,12 +1,15 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
1
|
require 'rspec'
|
2
|
+
require 'moped'
|
3
|
+
require 'mongoid'
|
4
|
+
|
4
5
|
require 'mongoid-markdown'
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
7
|
+
Mongoid.configure do |config|
|
8
|
+
config.connect_to('mongoid_markdown-test')
|
9
|
+
end
|
9
10
|
|
10
|
-
RSpec.configure do |config|
|
11
|
-
|
11
|
+
RSpec.configure do |config|
|
12
|
+
config.before(:each) do
|
13
|
+
Mongoid.purge!
|
14
|
+
end
|
12
15
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid-markdown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -27,6 +27,38 @@ dependencies:
|
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: moped
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: mongoid
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '2.0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.0'
|
30
62
|
- !ruby/object:Gem::Dependency
|
31
63
|
name: rspec
|
32
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -97,17 +129,20 @@ executables: []
|
|
97
129
|
extensions: []
|
98
130
|
extra_rdoc_files:
|
99
131
|
- LICENSE.txt
|
100
|
-
- README.
|
132
|
+
- README.md
|
101
133
|
files:
|
102
134
|
- .document
|
103
135
|
- .rspec
|
104
136
|
- Gemfile
|
105
137
|
- Gemfile.lock
|
106
138
|
- LICENSE.txt
|
107
|
-
- README.
|
139
|
+
- README.md
|
108
140
|
- Rakefile
|
109
141
|
- VERSION
|
110
142
|
- lib/mongoid-markdown.rb
|
143
|
+
- lib/mongoid-markdown/mongoid_new.rb
|
144
|
+
- lib/mongoid-markdown/mongoid_old.rb
|
145
|
+
- mongoid-markdown.gemspec
|
111
146
|
- spec/mongoid-markdown_spec.rb
|
112
147
|
- spec/spec_helper.rb
|
113
148
|
homepage: http://github.com/kristianmandrup/mongoid-markdown
|
@@ -125,7 +160,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
125
160
|
version: '0'
|
126
161
|
segments:
|
127
162
|
- 0
|
128
|
-
hash:
|
163
|
+
hash: -68746546745012311
|
129
164
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
165
|
none: false
|
131
166
|
requirements:
|