text_sanitizer 0.0.4 → 0.0.5
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.
@@ -52,6 +52,11 @@ module TextSanitizer
|
|
52
52
|
text.gsub(/\b\w+\b/){$&.capitalize}
|
53
53
|
end
|
54
54
|
|
55
|
+
def convert_newlines_to_html_for text
|
56
|
+
paragraphs = text.split(/\r\n/)
|
57
|
+
paragraphs.map { |p| p.present? ? "<p>#{p}</p>" : "<br>" }.join('')
|
58
|
+
end
|
59
|
+
|
55
60
|
def downcase text
|
56
61
|
text.downcase
|
57
62
|
end
|
@@ -71,6 +76,7 @@ end
|
|
71
76
|
ActiveRecord::Base.class_eval do
|
72
77
|
include TextSanitizer
|
73
78
|
register_sanitizer :capitalize
|
79
|
+
register_sanitizer :convert_newlines_to_html_for
|
74
80
|
register_sanitizer :downcase
|
75
81
|
register_sanitizer :sanitize
|
76
82
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: text_sanitizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-05-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|