text_sanitizer 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
@@ -1,3 +1,3 @@
1
1
  module TextSanitizer
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  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
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-04-25 00:00:00.000000000 Z
12
+ date: 2013-05-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails