hache 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/benchmarks/escaping.rb +20 -0
- data/hache.gemspec +1 -1
- data/lib/hache.rb +2 -2
- data/test/hache.rb +2 -10
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b9f5c147e9e42d09d6542a90d5078fda2dae3e6
|
4
|
+
data.tar.gz: 0a40d7774cbd300f116e9ffc66124592833589dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9089048bab221a9b99ea953cf2955e19394c2ccbe07c422cb4780c392f330fed13f0a97245a7b094a078e03aa1ba51eb2f7009969ef4ba2eb6c14b6620218494
|
7
|
+
data.tar.gz: 84bce11cf3bf4977504b05e0a726f9c93213cafc927d48d11a05ee40cf6bd137cd1ea952a207fc93de9c94582800df341bee30fc70a8c5cb3c1d5c7b6215358e
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "benchmark/ips"
|
2
|
+
require "rack/utils"
|
3
|
+
require_relative "../lib/hache"
|
4
|
+
|
5
|
+
text = %q(some < text > inside & these " escapable' characters/1234)
|
6
|
+
|
7
|
+
Benchmark.ips do |x|
|
8
|
+
x.report("encode") { text.encode(xml: :text) } # encode doesn't escape `'`, `"` and `/`.
|
9
|
+
x.report("rack") { Rack::Utils.escape_html(text) }
|
10
|
+
x.report("hache") { Hache.h(text) }
|
11
|
+
end
|
12
|
+
|
13
|
+
# Calculating -------------------------------------
|
14
|
+
# encode 16385 i/100ms
|
15
|
+
# rack 9626 i/100ms
|
16
|
+
# hache 10211 i/100ms
|
17
|
+
# -------------------------------------------------
|
18
|
+
# encode 241085.8 (±11.8%) i/s - 1163335 in 5.004123s
|
19
|
+
# rack 127905.8 (±4.5%) i/s - 644942 in 5.053418s
|
20
|
+
# hache 153666.9 (±11.5%) i/s - 745403 in 5.056082s
|
data/hache.gemspec
CHANGED
data/lib/hache.rb
CHANGED
data/test/hache.rb
CHANGED
@@ -1,18 +1,10 @@
|
|
1
1
|
require "cutest"
|
2
2
|
require_relative "../lib/hache"
|
3
3
|
|
4
|
-
def h(str)
|
5
|
-
Hache.h(str)
|
6
|
-
end
|
7
|
-
|
8
4
|
test "not escapes safe string" do
|
9
|
-
assert_equal "hola", h("hola")
|
10
|
-
end
|
11
|
-
|
12
|
-
test "not raises an error with nil values" do
|
13
|
-
assert_equal "", h(nil)
|
5
|
+
assert_equal "hola", Hache.h("hola")
|
14
6
|
end
|
15
7
|
|
16
8
|
test "escapes unsafe characters" do
|
17
|
-
assert_equal "<>&"'/", h(%q(<>&"'/))
|
9
|
+
assert_equal "<>&"'/", Hache.h(%q(<>&"'/))
|
18
10
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Francesco Rodríguez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cutest
|
@@ -34,6 +34,7 @@ files:
|
|
34
34
|
- .gems
|
35
35
|
- LICENSE
|
36
36
|
- README.md
|
37
|
+
- benchmarks/escaping.rb
|
37
38
|
- hache.gemspec
|
38
39
|
- lib/hache.rb
|
39
40
|
- test/hache.rb
|