rubyhelper 1.0.alpha3 → 1.0.alpha5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/README.md +2 -1
- data/lib/rubyhelper/{version.rb → gem-version.rb} +1 -1
- data/lib/rubyhelper/{stringhelper.rb → string.rb} +38 -23
- data/lib/rubyhelper.rb +6 -7
- data/rubyhelper.gemspec +11 -12
- data/test/{test_stringhelper.rb → test_string.rb} +2 -12
- data.tar.gz.sig +0 -0
- metadata +22 -24
- metadata.gz.sig +0 -0
- data/lib/rubyhelper/integerhelper.rb +0 -15
- /data/lib/rubyhelper/{arrayhelper.rb → array.rb} +0 -0
- /data/lib/rubyhelper/{hashhelper.rb → hash.rb} +0 -0
- /data/lib/rubyhelper/{numerichelper.rb → numeric.rb} +0 -0
- /data/lib/rubyhelper/{timehelper.rb → time.rb} +0 -0
- /data/test/{test_arrayhelper.rb → test_array.rb} +0 -0
- /data/test/{test_hashhelper.rb → test_hash.rb} +0 -0
- /data/test/{test_numerichelper.rb → test_numeric.rb} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec30ae585a7f5fee5aec17c55d3521e8d4fa22dc
|
4
|
+
data.tar.gz: 701521ae50eb5546d79ba7269d4eac51c0a45c50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb440a860a707ab5cb452d0e4b4469cb1997c1f18b7fe47586697b5527e96185b599a6f6ac572f2b8e4bdfd0228830c01c2c7dddf9dbe846771573ceabe9deb3
|
7
|
+
data.tar.gz: e4f6c89c97b76d268451e2ae5431bd0fb8017a00bc7be43d9d309f70907270cac06df490cdb77a1476f31a9af9471410b67d5e21ff7c7d88e9ea287c83eb0c43
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# rubyhelper
|
2
2
|
|
3
|
-
[](http://badge.fury.io/rb/rubyhelper)
|
3
|
+
Gem [](http://badge.fury.io/rb/rubyhelper)
|
4
|
+
Dev [](http://badge.fury.io/gh/pouleta%2Frubyhelper)
|
4
5
|
|
5
6
|
You can see the documentation here : https://www.omniref.com/ruby/gems/rubyhelper
|
6
7
|
|
@@ -5,26 +5,41 @@ require 'digest'
|
|
5
5
|
|
6
6
|
module StringHelper
|
7
7
|
|
8
|
+
# == Params:
|
9
|
+
# - replace: (String) replace invalids chars by other chas
|
10
|
+
def utf8 replace=''
|
11
|
+
return self.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: replace)
|
12
|
+
end
|
13
|
+
def utf8!
|
14
|
+
return self.replace(self.utf8)
|
15
|
+
end
|
16
|
+
|
8
17
|
# UTF-8 encoding and replace invalid chars, Remove accents from the string. Change the case as first argument if not nil
|
9
|
-
# == Params
|
10
|
-
# case_mod: nil (not changement), :upcase, :capitalize or :downcase
|
11
|
-
# replace: if a char is not utf8 valid, character will replace it
|
12
|
-
def to_plain(case_mod = nil, replace=
|
13
|
-
return self.p.
|
18
|
+
# == Params:
|
19
|
+
# - case_mod: nil (not changement), :upcase, :capitalize or :downcase
|
20
|
+
# - replace: (String) if a char is not utf8 valid, character will replace it
|
21
|
+
def to_plain(case_mod = nil, replace='')
|
22
|
+
return self.p(replace).utf8(replace).to_case(case_mod)
|
14
23
|
end
|
15
24
|
|
16
25
|
# Remove accents from the string, and replace it by the same letter in ASCII
|
17
|
-
|
18
|
-
|
19
|
-
|
26
|
+
# == Params:
|
27
|
+
# - replace: (String) replace by character default case
|
28
|
+
def p(replace='')
|
29
|
+
begin
|
30
|
+
return self.tr("ÀÁÂÃÄÅàáâãäåĀāĂ㥹ÇçĆćĈĉĊċČčÐðĎďĐđÈÉÊËèéêëĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħÌÍÎÏìíîïĨĩĪīĬĭĮįİıĴĵĶķĸĹĺĻļĽľĿŀŁłÑñŃńŅņŇňʼnŊŋÒÓÔÕÖØòóôõöøŌōŎŏŐőŔŕŖŗŘřŚśŜŝŞşŠšſŢţŤťŦŧÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųŴŵÝýÿŶŷŸŹźŻżŽž",
|
31
|
+
"AAAAAAaaaaaaAaAaAaCcCcCcCcCcDdDdDdEEEEeeeeEeEeEeEeEeGgGgGgGgHhHhIIIIiiiiIiIiIiIiIiJjKkkLlLlLlLlLlNnNnNnNnnNnOOOOOOooooooOoOoOoRrRrRrSsSsSsSssTtTtTtUUUUuuuuUuUuUuUuUuUuWwYyyYyYZzZzZz")
|
32
|
+
rescue Encoding::CompatibilityError => e
|
33
|
+
return self.utf8(replace)
|
34
|
+
end
|
20
35
|
end
|
21
36
|
def p!
|
22
37
|
return self.replace(self.p)
|
23
38
|
end
|
24
39
|
|
25
|
-
# == Params
|
26
|
-
# case_mod: nil (not changement), :upcase, :capitalize or :downcase
|
27
40
|
# permit to do upcase/downcase/capitalize easier with a simple param
|
41
|
+
# == Params:
|
42
|
+
# - case_mod: nil (not changement), :upcase, :capitalize or :downcase
|
28
43
|
def to_case(case_mod = :downcase)
|
29
44
|
case case_mod
|
30
45
|
when :upcase
|
@@ -43,9 +58,9 @@ module StringHelper
|
|
43
58
|
|
44
59
|
# Return a simple ascii string. Invalid characters will be replaced by "replace" (argument)
|
45
60
|
# Accents are removed first and replaced by the equivalent ASCII letter
|
46
|
-
# == Params
|
47
|
-
# replace: a caracter to replace non-ascii chars
|
48
|
-
# case_mod: nil (not changement), :upcase, :capitalize or :downcase
|
61
|
+
# == Params:
|
62
|
+
# - replace: a caracter to replace non-ascii chars
|
63
|
+
# - case_mod: nil (not changement), :upcase, :capitalize or :downcase
|
49
64
|
def to_ascii(replace="", case_mod = nil)
|
50
65
|
s = String.new
|
51
66
|
self.p.each_char do |c|
|
@@ -89,12 +104,12 @@ module StringHelper
|
|
89
104
|
# Get a str with a static length.
|
90
105
|
# If the str size > n, reduce the str (keep str from the (param place) )
|
91
106
|
# You should check the test files for examples
|
92
|
-
# == Params
|
93
|
-
# n: number of char
|
94
|
-
# char: char to replace if the initial str is too short
|
95
|
-
# place: :begin/:front :end/:back :center/:middle
|
96
|
-
# == Errors
|
97
|
-
# ArgumentError : if n in not an integer/char a String
|
107
|
+
# == Params:
|
108
|
+
# - n: number of char
|
109
|
+
# - char: char to replace if the initial str is too short
|
110
|
+
# - place: :begin/:front :end/:back :center/:middle
|
111
|
+
# == Errors:
|
112
|
+
# - ArgumentError : if n in not an integer/char a String
|
98
113
|
def static(n, char=' ', place= :back)
|
99
114
|
raise ArgumentError, 'char is not an Char (String)' unless char.is_a? String
|
100
115
|
raise ArgumentError, 'n is not an Integer' unless n.is_a? Integer
|
@@ -136,8 +151,8 @@ module StringHelper
|
|
136
151
|
end
|
137
152
|
|
138
153
|
#get only the digits and symbols in the string
|
139
|
-
# == Params
|
140
|
-
# sign: (true/false) if true, keep the - and + signs
|
154
|
+
# == Params:
|
155
|
+
# - sign: (true/false) if true, keep the - and + signs
|
141
156
|
def get_int(sign = true)
|
142
157
|
return self.gsub(/[^\-\+\d]/, "") if sign == true
|
143
158
|
return self.gsub(/[^\d]/, "")
|
@@ -147,8 +162,8 @@ module StringHelper
|
|
147
162
|
end
|
148
163
|
|
149
164
|
#as get_int but with . and ,
|
150
|
-
# == Params
|
151
|
-
# sign: (true/false) if true, keep the - and + signs
|
165
|
+
# == Params:
|
166
|
+
# - sign: (true/false) if true, keep the - and + signs
|
152
167
|
def get_float(sign = true)
|
153
168
|
return self.gsub(/[^\-\+\d\.\,]/, "") if sign == true
|
154
169
|
return self.gsub(/[^\d\.\,]/, "") if sign == true
|
data/lib/rubyhelper.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
#encoding: utf-8
|
2
2
|
|
3
|
-
require_relative 'rubyhelper/
|
4
|
-
require_relative 'rubyhelper/
|
5
|
-
require_relative 'rubyhelper/
|
6
|
-
require_relative 'rubyhelper/
|
7
|
-
require_relative 'rubyhelper/
|
8
|
-
require_relative 'rubyhelper/
|
3
|
+
require_relative 'rubyhelper/gem-version.rb'
|
4
|
+
require_relative 'rubyhelper/string.rb'
|
5
|
+
require_relative 'rubyhelper/array.rb'
|
6
|
+
require_relative 'rubyhelper/numeric.rb'
|
7
|
+
require_relative 'rubyhelper/time.rb'
|
8
|
+
require_relative 'rubyhelper/hash.rb'
|
9
9
|
require_relative 'rubyhelper/versionhelper.rb'
|
10
|
-
require_relative 'rubyhelper/version.rb'
|
data/rubyhelper.gemspec
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require_relative "lib/rubyhelper/version"
|
1
|
+
require_relative "lib/rubyhelper/gem-version"
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'rubyhelper'
|
@@ -12,21 +12,20 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.email = "poulet_a@epitech.eu",
|
13
13
|
s.files = [
|
14
14
|
"lib/rubyhelper.rb",
|
15
|
-
"lib/rubyhelper/version.rb",
|
16
|
-
"lib/rubyhelper/
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
"lib/rubyhelper/
|
21
|
-
"lib/rubyhelper/hashhelper.rb",
|
15
|
+
"lib/rubyhelper/gem-version.rb",
|
16
|
+
"lib/rubyhelper/string.rb",
|
17
|
+
"lib/rubyhelper/array.rb",
|
18
|
+
"lib/rubyhelper/numeric.rb",
|
19
|
+
"lib/rubyhelper/time.rb",
|
20
|
+
"lib/rubyhelper/hash.rb",
|
22
21
|
"lib/rubyhelper/versionhelper.rb",
|
23
22
|
"README.md",
|
24
23
|
"Rakefile",
|
25
24
|
"rubyhelper.gemspec",
|
26
|
-
"test/
|
27
|
-
"test/
|
28
|
-
"test/
|
29
|
-
"test/
|
25
|
+
"test/test_array.rb",
|
26
|
+
"test/test_hash.rb",
|
27
|
+
"test/test_numeric.rb",
|
28
|
+
"test/test_string.rb",
|
30
29
|
"test/test_versionhelper.rb",
|
31
30
|
]
|
32
31
|
s.homepage = "https://gitlab.com/Sopheny/rubyhelper"
|
@@ -8,18 +8,14 @@ class StringHelperTest < Minitest::Test
|
|
8
8
|
assert_equal("bonjour".to_plain, "bonjour")
|
9
9
|
assert_equal("bonjouré".to_plain, "bonjoure")
|
10
10
|
assert_equal("bonjo\\AAAur".to_plain, "bonjo\\AAAur")
|
11
|
+
assert_equal("bonjo€".to_plain, "bonjo")
|
11
12
|
end
|
12
13
|
|
13
14
|
def test_p
|
14
15
|
assert_equal("bonjour".p, "bonjour")
|
15
16
|
assert_equal("bonjouré".p, "bonjoure")
|
16
17
|
assert_equal("bonjo\\AAAur".p, "bonjo\\AAAur")
|
17
|
-
|
18
|
-
|
19
|
-
def test_p!
|
20
|
-
assert_equal("bonjour".p!, "bonjour")
|
21
|
-
assert_equal("bonjouré".p!, "bonjoure")
|
22
|
-
assert_equal("bonjo\\AAAur".p!, "bonjo\\AAAur")
|
18
|
+
assert_equal("bonjo€".p, "bonjo€")
|
23
19
|
end
|
24
20
|
|
25
21
|
def test_to_case
|
@@ -28,12 +24,6 @@ class StringHelperTest < Minitest::Test
|
|
28
24
|
assert_equal("bonJour".to_case(:capitalize), "Bonjour")
|
29
25
|
end
|
30
26
|
|
31
|
-
def test_to_case!
|
32
|
-
assert_equal("bonjour".to_case!(:downcase), "bonjour")
|
33
|
-
assert_equal("bonJour".to_case!(:upcase), "BONJOUR")
|
34
|
-
assert_equal("bonJour".to_case!(:capitalize), "Bonjour")
|
35
|
-
end
|
36
|
-
|
37
27
|
def test_to_ascii
|
38
28
|
assert_equal("bonjoure".to_ascii(""), "bonjoure")
|
39
29
|
assert_equal("bonjouré".to_ascii(""), "bonjoure")
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubyhelper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.alpha5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- poulet_a
|
@@ -31,27 +31,26 @@ cert_chain:
|
|
31
31
|
+lG6tRo8QaFrH3afOmy4VUaG84Jm1XjNYnyaOfLb9ItpcQgVySn2c3aJ2PLcPljM
|
32
32
|
EhZUryAiV8KNMQ==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2014-09-
|
34
|
+
date: 2014-09-05 00:00:00.000000000 Z
|
35
35
|
dependencies: []
|
36
36
|
description: A list of utils for the basic Class of ruby.
|
37
37
|
email:
|
38
38
|
- poulet_a@epitech.eu
|
39
39
|
- - lib/rubyhelper.rb
|
40
|
-
- lib/rubyhelper/version.rb
|
41
|
-
- lib/rubyhelper/
|
42
|
-
- lib/rubyhelper/
|
43
|
-
- lib/rubyhelper/
|
44
|
-
- lib/rubyhelper/
|
45
|
-
- lib/rubyhelper/
|
46
|
-
- lib/rubyhelper/hashhelper.rb
|
40
|
+
- lib/rubyhelper/gem-version.rb
|
41
|
+
- lib/rubyhelper/string.rb
|
42
|
+
- lib/rubyhelper/array.rb
|
43
|
+
- lib/rubyhelper/numeric.rb
|
44
|
+
- lib/rubyhelper/time.rb
|
45
|
+
- lib/rubyhelper/hash.rb
|
47
46
|
- lib/rubyhelper/versionhelper.rb
|
48
47
|
- README.md
|
49
48
|
- Rakefile
|
50
49
|
- rubyhelper.gemspec
|
51
|
-
- test/
|
52
|
-
- test/
|
53
|
-
- test/
|
54
|
-
- test/
|
50
|
+
- test/test_array.rb
|
51
|
+
- test/test_hash.rb
|
52
|
+
- test/test_numeric.rb
|
53
|
+
- test/test_string.rb
|
55
54
|
- test/test_versionhelper.rb
|
56
55
|
executables: []
|
57
56
|
extensions: []
|
@@ -60,19 +59,18 @@ files:
|
|
60
59
|
- README.md
|
61
60
|
- Rakefile
|
62
61
|
- lib/rubyhelper.rb
|
63
|
-
- lib/rubyhelper/
|
64
|
-
- lib/rubyhelper/
|
65
|
-
- lib/rubyhelper/
|
66
|
-
- lib/rubyhelper/
|
67
|
-
- lib/rubyhelper/
|
68
|
-
- lib/rubyhelper/
|
69
|
-
- lib/rubyhelper/version.rb
|
62
|
+
- lib/rubyhelper/array.rb
|
63
|
+
- lib/rubyhelper/gem-version.rb
|
64
|
+
- lib/rubyhelper/hash.rb
|
65
|
+
- lib/rubyhelper/numeric.rb
|
66
|
+
- lib/rubyhelper/string.rb
|
67
|
+
- lib/rubyhelper/time.rb
|
70
68
|
- lib/rubyhelper/versionhelper.rb
|
71
69
|
- rubyhelper.gemspec
|
72
|
-
- test/
|
73
|
-
- test/
|
74
|
-
- test/
|
75
|
-
- test/
|
70
|
+
- test/test_array.rb
|
71
|
+
- test/test_hash.rb
|
72
|
+
- test/test_numeric.rb
|
73
|
+
- test/test_string.rb
|
76
74
|
- test/test_versionhelper.rb
|
77
75
|
homepage: https://gitlab.com/Sopheny/rubyhelper
|
78
76
|
licenses:
|
metadata.gz.sig
CHANGED
Binary file
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|