tzispa_utils 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +3 -0
- data/lib/tzispa/utils/tz_string.rb +35 -27
- data/lib/tzispa/utils/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3956cbb97d86021e1c2392fe4e4931c043723518a285e3d03b6ab0572f1e6540
|
4
|
+
data.tar.gz: b00ccbe0e15adc4a3a24e569e5b8b864a7535e46609095c52ceb643979c7724c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5bb6e9aa8ce1a70161b653968668356f3735f9d3d175a34a669943a46c01b1480dd3d4d666fda1c4c41d67a86b390e9d180be67dd8d2c6c013922da982db111a
|
7
|
+
data.tar.gz: 3fcba6d1fe5dd3535be90e5f0b8009a2793f5cc5aaf2ce30006581b09eb1b5f3dde7853c96e9ca3d5de87d627c88a45e18c00e75f36b9bd4af6e7c1b85fd47b7
|
data/CHANGELOG.md
CHANGED
@@ -13,6 +13,7 @@ module Tzispa
|
|
13
13
|
UNDERSCORE_SEPARATOR = '/'
|
14
14
|
DOT_SEPARATOR = '.'
|
15
15
|
UNDERSCORE_DIVISION_TARGET = '\1_\2'
|
16
|
+
DEFAULT_ENCODING = 'UTF-8'
|
16
17
|
|
17
18
|
refine String do
|
18
19
|
def constantize
|
@@ -30,7 +31,7 @@ module Tzispa
|
|
30
31
|
end
|
31
32
|
|
32
33
|
def camelize
|
33
|
-
|
34
|
+
dup.camelize!
|
34
35
|
end
|
35
36
|
|
36
37
|
def camelize!
|
@@ -38,13 +39,7 @@ module Tzispa
|
|
38
39
|
end
|
39
40
|
|
40
41
|
def dottize
|
41
|
-
dup.
|
42
|
-
s.gsub!(NAMESPACE_SEPARATOR, DOT_SEPARATOR)
|
43
|
-
s.gsub!(/([A-Z\d]+)([A-Z][a-z])/, UNDERSCORE_DIVISION_TARGET)
|
44
|
-
s.gsub!(/([a-z\d])([A-Z])/, UNDERSCORE_DIVISION_TARGET)
|
45
|
-
s.gsub!(/[[:space:]]|\-/, UNDERSCORE_DIVISION_TARGET)
|
46
|
-
s.downcase!
|
47
|
-
end
|
42
|
+
dup.dottize!
|
48
43
|
end
|
49
44
|
|
50
45
|
def dottize!
|
@@ -58,7 +53,7 @@ module Tzispa
|
|
58
53
|
end
|
59
54
|
|
60
55
|
def underscore
|
61
|
-
dup.
|
56
|
+
dup.underscore!
|
62
57
|
end
|
63
58
|
|
64
59
|
def underscore!
|
@@ -71,20 +66,29 @@ module Tzispa
|
|
71
66
|
end
|
72
67
|
end
|
73
68
|
|
69
|
+
def fix_encoding(src_enc, dest_enc = DEFAULT_ENCODING)
|
70
|
+
dup.fix_encoding src_enc, dest_enc
|
71
|
+
end
|
72
|
+
|
73
|
+
def fix_encoding!(src_enc, dest_enc = DEFAULT_ENCODING)
|
74
|
+
tap do |s|
|
75
|
+
s.force_encoding(src_enc).encode(dest_enc)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
74
79
|
def indentize(count, char = ' ')
|
75
|
-
dup.
|
80
|
+
dup.indentize!(count, char)
|
76
81
|
end
|
77
82
|
|
78
83
|
# Indent a string by count chars
|
79
84
|
def indentize!(count, char = ' ')
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
line
|
85
|
+
tap do |s|
|
86
|
+
s.gsub!(/([^\n]*)(\n|$)/) do
|
87
|
+
s1 = Regexp.last_match(1)
|
88
|
+
s2 = Regexp.last_match(2)
|
89
|
+
not_empty = s1 != '' || s2 != ''
|
90
|
+
"#{char * count}#{s1}#{s2}" if not_empty
|
91
|
+
end
|
88
92
|
end
|
89
93
|
end
|
90
94
|
|
@@ -103,14 +107,14 @@ module Tzispa
|
|
103
107
|
# * :convert_spaces => Convert space to underscore (defaults to true)
|
104
108
|
# * :regexp => matching characters that will be removed (defaults to /[^-_A-Za-z0-9]/)
|
105
109
|
def urlize(options = {})
|
106
|
-
options[:downcase] ||= true
|
107
|
-
options[:convert_spaces] ||= true
|
108
|
-
options[:regexp] ||= /[^-_A-Za-z0-9]/
|
109
|
-
|
110
|
-
transliterate(
|
111
|
-
str.downcase! if
|
112
|
-
str.tr!(' ', '_') if
|
113
|
-
str.gsub!(
|
110
|
+
downcase = options[:downcase] ||= true
|
111
|
+
convert_spaces = options[:convert_spaces] ||= true
|
112
|
+
regexp = options[:regexp] ||= /[^-_A-Za-z0-9]/
|
113
|
+
locale = options[:locale]
|
114
|
+
transliterate(locale).strip.tap do |str|
|
115
|
+
str.downcase! if downcase
|
116
|
+
str.tr!(' ', '_') if convert_spaces
|
117
|
+
str.gsub!(regexp, '')
|
114
118
|
end
|
115
119
|
end
|
116
120
|
|
@@ -147,7 +151,7 @@ module Tzispa
|
|
147
151
|
|
148
152
|
def integer?(base = 10)
|
149
153
|
Integer(self, base)
|
150
|
-
rescue
|
154
|
+
rescue StandardError
|
151
155
|
false
|
152
156
|
end
|
153
157
|
|
@@ -173,6 +177,10 @@ module Tzispa
|
|
173
177
|
String.new(str).constantize
|
174
178
|
end
|
175
179
|
|
180
|
+
def fix_encoding(str, src_enc, dest_enc = DEFAULT_ENCODING)
|
181
|
+
String.new(str).fix_encoding(src_enc, dest_enc)
|
182
|
+
end
|
183
|
+
|
176
184
|
def urlize(str)
|
177
185
|
String.new(str).urlize
|
178
186
|
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.6
|
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-12-31 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.
|
132
|
+
rubygems_version: 2.7.3
|
133
133
|
signing_key:
|
134
134
|
specification_version: 4
|
135
135
|
summary: Utilities for Tzispa
|