tzispa_utils 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/tzispa/utils/hash.rb +24 -20
- data/lib/tzispa/utils/string.rb +15 -0
- data/lib/tzispa/utils/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84afafd3fd443191e29cfaaa958c1f78c83d292b
|
4
|
+
data.tar.gz: aad3274bc70c5260e89137f85b8e86703bfba7e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c31286198ed0a482900d3d9d7627148873eb6dbeac75b8685fba44770a9665a5cb7864c725191d341b586232599a4dc42adb50e6bb9a2f04671c70182da9602
|
7
|
+
data.tar.gz: ebf06ff22e556514145b72097c80431fb20291be7dbce30d2ad1e8b4b1d22468950d5331fb42dd45c359c211a6b461626659aed1ff9e59ae99686f1d8f43a368
|
data/CHANGELOG.md
CHANGED
data/lib/tzispa/utils/hash.rb
CHANGED
@@ -22,45 +22,49 @@ module Tzispa
|
|
22
22
|
|
23
23
|
def symbolize!
|
24
24
|
keys.each do |k|
|
25
|
-
|
26
|
-
self[k.to_sym] = v
|
25
|
+
self[k.to_sym] = delete(k) if k.respond_to? :to_sym
|
27
26
|
end
|
28
27
|
|
29
28
|
self
|
30
29
|
end
|
31
30
|
|
32
|
-
def deep_symbolize
|
33
|
-
dup.tap do |hsh|
|
34
|
-
hsh.keys.each do |k|
|
35
|
-
v = hsh.delete(k)
|
36
|
-
v = v.dup.deep_symbolize if v.respond_to?(:to_hash)
|
37
|
-
|
38
|
-
hsh[k.to_sym] = v
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
31
|
def deep_symbolize!
|
44
32
|
keys.each do |k|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
self[k.to_sym] = v
|
33
|
+
ks = k.respond_to?(:to_sym) ? k.to_sym : k
|
34
|
+
self[ks] = delete k # Preserve order even when k == ks
|
35
|
+
self[ks].deep_symbolize! if self[ks].is_a? ::Hash
|
49
36
|
end
|
50
37
|
|
51
38
|
self
|
52
39
|
end
|
53
40
|
|
41
|
+
def deep_symbolize
|
42
|
+
dup.tap do |hs|
|
43
|
+
hs.keys.each do |k|
|
44
|
+
ks = k.respond_to?(:to_sym) ? k.to_sym : k
|
45
|
+
hs[ks] = hs.delete k # Preserve order even when k == ks
|
46
|
+
hs[ks] = hs[ks].deep_symbolize if hs[ks].is_a? ::Hash
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
54
51
|
def stringify
|
55
52
|
dup.tap(&:stringify!)
|
56
53
|
end
|
57
54
|
|
58
55
|
def stringify!
|
59
56
|
keys.each do |k|
|
60
|
-
|
61
|
-
|
57
|
+
self[k.to_s] = delete(k) if k.respond_to? :to_s
|
58
|
+
end
|
62
59
|
|
63
|
-
|
60
|
+
self
|
61
|
+
end
|
62
|
+
|
63
|
+
def deep_stringify!
|
64
|
+
keys.each do |k|
|
65
|
+
ks = k.respond_to?(:to_s) ? k.to_s : k
|
66
|
+
self[ks] = delete k # Preserve order even when k == ks
|
67
|
+
self[ks].deep_symbolize! if self[ks].is_a? ::Hash
|
64
68
|
end
|
65
69
|
|
66
70
|
self
|
data/lib/tzispa/utils/string.rb
CHANGED
@@ -124,6 +124,10 @@ module Tzispa
|
|
124
124
|
end
|
125
125
|
alias_method :sanitize_htm, :sanitize_html
|
126
126
|
|
127
|
+
def sanitize_filename
|
128
|
+
gsub(%r{[\x00\/\\:\*\?\"\,\'<>\|]}, '')
|
129
|
+
end
|
130
|
+
|
127
131
|
def escape_html
|
128
132
|
EscapeUtils.escape_html(self)
|
129
133
|
end
|
@@ -133,6 +137,13 @@ module Tzispa
|
|
133
137
|
EscapeUtils.unescape_html(self)
|
134
138
|
end
|
135
139
|
alias_method :unescape_htm, :unescape_html
|
140
|
+
|
141
|
+
def to_bool
|
142
|
+
return true if self == true || self =~ /^(true|t|yes|y|1)$/i
|
143
|
+
return false if self == false || self =~ /^(false|f|no|n|0)$/i
|
144
|
+
raise ArgumentError.new("invalid value for Boolean: \"#{self}\"")
|
145
|
+
end
|
146
|
+
alias_method :to_boolean, :to_bool
|
136
147
|
end
|
137
148
|
|
138
149
|
refine String.singleton_class do
|
@@ -165,6 +176,10 @@ module Tzispa
|
|
165
176
|
end
|
166
177
|
alias_method :sanitize_htm, :sanitize_html
|
167
178
|
|
179
|
+
def sanitize_filename(str)
|
180
|
+
String.new(str).sanitize_filename
|
181
|
+
end
|
182
|
+
|
168
183
|
def escape_html(str)
|
169
184
|
String.new(str).escape_html
|
170
185
|
end
|
data/lib/tzispa/utils/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tzispa_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Antonio Piñero
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
@@ -129,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
129
|
version: '0'
|
130
130
|
requirements: []
|
131
131
|
rubyforge_project:
|
132
|
-
rubygems_version: 2.6.
|
132
|
+
rubygems_version: 2.6.11
|
133
133
|
signing_key:
|
134
134
|
specification_version: 4
|
135
135
|
summary: Utilities for Tzispa
|