xml_escape 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/xml_escape.rb +2 -0
- data/lib/xml_escape/version.rb +1 -1
- data/spec/lib/xml_escape_spec.rb +16 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ca269dd4ce8aa0d9c01866f459106812008e8da
|
4
|
+
data.tar.gz: 03823ae8ac2cf88d2c6e3c32eaf66ff9e0c221ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2a3367f315b4234206f52bb01d61b5206083a11303af1027dc0c9594d9734094ac9eac6f481e4a157d445e391c0b59098c346e9c17d615c051bbccf6e1a069a
|
7
|
+
data.tar.gz: 43cbad5a0cd8a350e9181fbc037e0fa8bd5f3636a4b3f127b3dc1e75b6ba9ed3688ba9bac35d9609c75c2710ac09f0c7dd31555b91580cf9e20a2d7536771fe0
|
data/lib/xml_escape.rb
CHANGED
@@ -2,10 +2,12 @@ module XmlEscape
|
|
2
2
|
def xml_encode(str)
|
3
3
|
str.gsub(DECODED_CHARACTERS, ENCODE_MAP)
|
4
4
|
end
|
5
|
+
alias_method :escape_xml, :xml_encode
|
5
6
|
|
6
7
|
def xml_decode(str)
|
7
8
|
str.gsub(ENCODED_CHARACTERS, DECODE_MAP)
|
8
9
|
end
|
10
|
+
alias_method :unescape_xml, :xml_decode
|
9
11
|
|
10
12
|
private
|
11
13
|
|
data/lib/xml_escape/version.rb
CHANGED
data/spec/lib/xml_escape_spec.rb
CHANGED
@@ -5,17 +5,30 @@ describe XmlEscape do
|
|
5
5
|
Class.new { include XmlEscape }.new
|
6
6
|
end
|
7
7
|
|
8
|
+
let(:txt) { '& text, - " \' < >' }
|
9
|
+
let(:encoded_txt) { 'arma & "virum"' }
|
10
|
+
|
8
11
|
describe "#xml_encode" do
|
9
12
|
it "encodes xml characters" do
|
10
|
-
txt = '& text, - " \' < >'
|
11
13
|
dummy.xml_encode(txt).should == '& text, - " ' < >'
|
12
14
|
end
|
13
15
|
end
|
14
16
|
|
17
|
+
describe "#escape_xml" do
|
18
|
+
it "is an alias of #xml_encode" do
|
19
|
+
dummy.xml_encode(txt).should == dummy.escape_xml(txt)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
15
23
|
describe "#xml_decode" do
|
16
24
|
it "decodes xml characters" do
|
17
|
-
|
18
|
-
|
25
|
+
dummy.xml_decode(encoded_txt).should == 'arma & "virum"'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "#unescape_xml" do
|
30
|
+
it "is an alias to #xml_decode" do
|
31
|
+
dummy.xml_decode(encoded_txt).should == dummy.unescape_xml(encoded_txt)
|
19
32
|
end
|
20
33
|
end
|
21
34
|
end
|