auto_html 1.4.0 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -29,7 +29,10 @@ module AutoHtmlFor
29
29
  write_attribute("#{raw_attr}#{suffix}", val)
30
30
  end
31
31
  define_method("#{raw_attr}#{suffix}") do
32
- read_attribute("#{raw_attr}#{suffix}") || send("auto_html_prepare_#{raw_attr}")
32
+ result = read_attribute("#{raw_attr}#{suffix}") || send("auto_html_prepare_#{raw_attr}")
33
+ result.respond_to?(:html_safe) ?
34
+ result.html_safe :
35
+ result
33
36
  end
34
37
  define_method("auto_html_prepare_#{raw_attr}") do
35
38
  self.send(raw_attr.to_s + suffix + "=",
@@ -1,4 +1,6 @@
1
1
  module AutoHtml
2
+ extend self
3
+
2
4
  def self.add_filter(name, &block)
3
5
  AutoHtml::Builder.add_filter(name, &block)
4
6
  end
@@ -7,8 +9,10 @@ module AutoHtml
7
9
  return "" if raw.blank?
8
10
  builder = Builder.new(raw)
9
11
  result = builder.instance_eval(&proc)
12
+ return raw if result.nil?
10
13
  result.respond_to?(:html_safe) ?
11
14
  result.html_safe :
12
15
  result
13
16
  end
17
+
14
18
  end
@@ -3,9 +3,10 @@ require File.expand_path('../unit_test_helper', __FILE__)
3
3
 
4
4
  class AutoHtmlTest < Test::Unit::TestCase
5
5
 
6
- def test_should_be_nil_no_filters_provided
7
- result = auto_html("Hey check out my blog => http://rors.org") { }
8
- assert_nil result
6
+ def test_should_be_raw_input_when_no_filters_provided
7
+ input = "Hey check out my blog => http://rors.org"
8
+ result = auto_html(input) { }
9
+ assert_equal result, input
9
10
  end
10
11
 
11
12
  def test_should_apply_simple_format_filter
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auto_html
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 5
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 4
9
- - 0
10
- version: 1.4.0
9
+ - 1
10
+ version: 1.4.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dejan Simic