htmlentities 4.0.0 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,26 +0,0 @@
1
- require 'htmlentities'
2
-
3
- #
4
- # This file extends the String class with methods to allow encoding and decoding of
5
- # HTML/XML entities from/to their corresponding UTF-8 codepoints.
6
- #
7
- class String
8
-
9
- #
10
- # Decode XML and HTML 4.01 entities in a string into their UTF-8
11
- # equivalents.
12
- #
13
- def decode_entities
14
- return HTMLEntities.decode_entities(self)
15
- end
16
-
17
- #
18
- # Encode codepoints in a string into their corresponding entities. See
19
- # the documentation of HTMLEntities.encode_entities for a list of possible
20
- # instructions.
21
- #
22
- def encode_entities(*instructions)
23
- return HTMLEntities.encode_entities(self, *instructions)
24
- end
25
-
26
- end
data/test/string_test.rb DELETED
@@ -1,24 +0,0 @@
1
- $:.unshift(File.dirname(__FILE__) + '/../lib')
2
- require 'htmlentities/string'
3
- require 'test/unit'
4
-
5
- $KCODE = 'u'
6
-
7
- class TestHTMLEntities < Test::Unit::TestCase
8
-
9
- def test_string_responds_correctly_to_decode_entities
10
- assert_equal('±', '&plusmn;'.decode_entities)
11
- end
12
-
13
- def test_string_responds_correctly_to_encode_entities_with_no_parameters
14
- assert_equal('&quot;', '"'.encode_entities)
15
- end
16
-
17
- def test_string_responds_correctly_to_encode_entities_with_multiple_parameters
18
- assert_equal(
19
- '&quot;bient&ocirc;t&quot; &amp; &#x6587;&#x5b57;',
20
- '"bientôt" & 文字'.encode_entities(:basic, :named, :hexadecimal)
21
- )
22
- end
23
-
24
- end