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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b5615257a8bef642bab7284f23935bce5530ddf8
4
- data.tar.gz: dd62e501324557fb3690fa1862ad97df60c7f755
3
+ metadata.gz: 8ca269dd4ce8aa0d9c01866f459106812008e8da
4
+ data.tar.gz: 03823ae8ac2cf88d2c6e3c32eaf66ff9e0c221ce
5
5
  SHA512:
6
- metadata.gz: e889cef6a123b218a122fcc7a6ec2ceca5535f9ebc2d189b37c14bd0b9b6c65af9f250e32d9e91153ea943958ab21ff57b8a59c4dd1666cfd0890b0f3e73955a
7
- data.tar.gz: 5b7105ce249ec2237884a4182b15649ad12242a162546f90455c1cb58183cfb7d641ffdf6f31ab81628e6bd6da9e9b412fce0e0d9f98d8691f3863676ddd3d08
6
+ metadata.gz: f2a3367f315b4234206f52bb01d61b5206083a11303af1027dc0c9594d9734094ac9eac6f481e4a157d445e391c0b59098c346e9c17d615c051bbccf6e1a069a
7
+ data.tar.gz: 43cbad5a0cd8a350e9181fbc037e0fa8bd5f3636a4b3f127b3dc1e75b6ba9ed3688ba9bac35d9609c75c2710ac09f0c7dd31555b91580cf9e20a2d7536771fe0
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  module XmlEscape
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -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 &amp; &quot;virum&quot;' }
10
+
8
11
  describe "#xml_encode" do
9
12
  it "encodes xml characters" do
10
- txt = '& text, - " \' < >'
11
13
  dummy.xml_encode(txt).should == '&amp; text, - &quot; &apos; &lt; &gt;'
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
- txt = 'arma &amp; &quot;virum&quot;'
18
- dummy.xml_decode(txt).should == 'arma & "virum"'
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xml_escape
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - LFDM