string_pattern 1.4.0 → 1.4.1
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
- data/.yardopts +4 -4
- data/LICENSE +21 -21
- data/README.md +323 -321
- data/lib/string/pattern/add_to_ruby.rb +67 -67
- data/lib/string_pattern.rb +920 -918
- metadata +2 -2
@@ -1,67 +1,67 @@
|
|
1
|
-
class Array
|
2
|
-
# It will generate an string following the pattern specified
|
3
|
-
# The positions with string patterns need to be supplied like symbols:
|
4
|
-
# [:"10:N", "fixed", :"10-20:XN/x/"].generate #> "1024320001fixed4OZjNMTnuBibwwj"
|
5
|
-
def generate(expected_errors: [], **synonyms)
|
6
|
-
StringPattern.generate(self, expected_errors: expected_errors, **synonyms)
|
7
|
-
end
|
8
|
-
|
9
|
-
alias_method :gen, :generate
|
10
|
-
|
11
|
-
# it will validate an string following the pattern specified
|
12
|
-
def validate(string_to_validate, expected_errors: [], not_expected_errors: [], **synonyms)
|
13
|
-
StringPattern.validate(text: string_to_validate, pattern: self, expected_errors: expected_errors, not_expected_errors: not_expected_errors, **synonyms)
|
14
|
-
end
|
15
|
-
|
16
|
-
alias_method :val, :validate
|
17
|
-
end
|
18
|
-
|
19
|
-
class String
|
20
|
-
# it will generate an string following the pattern specified
|
21
|
-
def generate(expected_errors: [], **synonyms)
|
22
|
-
StringPattern.generate(self, expected_errors: expected_errors, **synonyms)
|
23
|
-
end
|
24
|
-
|
25
|
-
alias_method :gen, :generate
|
26
|
-
|
27
|
-
# it will validate an string following the pattern specified
|
28
|
-
def validate(string_to_validate, expected_errors: [], not_expected_errors: [], **synonyms)
|
29
|
-
StringPattern.validate(text: string_to_validate, pattern: self, expected_errors: expected_errors, not_expected_errors: not_expected_errors, **synonyms)
|
30
|
-
end
|
31
|
-
|
32
|
-
alias_method :val, :validate
|
33
|
-
end
|
34
|
-
|
35
|
-
|
36
|
-
class Symbol
|
37
|
-
# it will generate an string following the pattern specified
|
38
|
-
def generate(expected_errors: [], **synonyms)
|
39
|
-
StringPattern.generate(self, expected_errors: expected_errors, **synonyms)
|
40
|
-
end
|
41
|
-
|
42
|
-
alias_method :gen, :generate
|
43
|
-
|
44
|
-
# it will validate an string following the pattern specified
|
45
|
-
def validate(string_to_validate, expected_errors: [], not_expected_errors: [], **synonyms)
|
46
|
-
StringPattern.validate(text: string_to_validate, pattern: self.to_s, expected_errors: expected_errors, not_expected_errors: not_expected_errors, **synonyms)
|
47
|
-
end
|
48
|
-
|
49
|
-
alias_method :val, :validate
|
50
|
-
end
|
51
|
-
|
52
|
-
|
53
|
-
module Kernel
|
54
|
-
public
|
55
|
-
# if string or symbol supplied it will generate a string with the supplied pattern specified on the string
|
56
|
-
# if array supplied then it will generate a string with the supplied patterns. If a position contains a pattern supply it as symbol, for example: [:"10:N", "fixed", :"10-20:XN/x/"]
|
57
|
-
def generate(pattern, expected_errors: [], **synonyms)
|
58
|
-
if pattern.kind_of?(String) or pattern.kind_of?(Array) or pattern.kind_of?(Symbol)
|
59
|
-
StringPattern.generate(pattern, expected_errors: expected_errors, **synonyms)
|
60
|
-
else
|
61
|
-
puts " Kernel generate method: class not recognized:#{pattern.class}"
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
alias_method :gen, :generate
|
66
|
-
end
|
67
|
-
|
1
|
+
class Array
|
2
|
+
# It will generate an string following the pattern specified
|
3
|
+
# The positions with string patterns need to be supplied like symbols:
|
4
|
+
# [:"10:N", "fixed", :"10-20:XN/x/"].generate #> "1024320001fixed4OZjNMTnuBibwwj"
|
5
|
+
def generate(expected_errors: [], **synonyms)
|
6
|
+
StringPattern.generate(self, expected_errors: expected_errors, **synonyms)
|
7
|
+
end
|
8
|
+
|
9
|
+
alias_method :gen, :generate
|
10
|
+
|
11
|
+
# it will validate an string following the pattern specified
|
12
|
+
def validate(string_to_validate, expected_errors: [], not_expected_errors: [], **synonyms)
|
13
|
+
StringPattern.validate(text: string_to_validate, pattern: self, expected_errors: expected_errors, not_expected_errors: not_expected_errors, **synonyms)
|
14
|
+
end
|
15
|
+
|
16
|
+
alias_method :val, :validate
|
17
|
+
end
|
18
|
+
|
19
|
+
class String
|
20
|
+
# it will generate an string following the pattern specified
|
21
|
+
def generate(expected_errors: [], **synonyms)
|
22
|
+
StringPattern.generate(self, expected_errors: expected_errors, **synonyms)
|
23
|
+
end
|
24
|
+
|
25
|
+
alias_method :gen, :generate
|
26
|
+
|
27
|
+
# it will validate an string following the pattern specified
|
28
|
+
def validate(string_to_validate, expected_errors: [], not_expected_errors: [], **synonyms)
|
29
|
+
StringPattern.validate(text: string_to_validate, pattern: self, expected_errors: expected_errors, not_expected_errors: not_expected_errors, **synonyms)
|
30
|
+
end
|
31
|
+
|
32
|
+
alias_method :val, :validate
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
class Symbol
|
37
|
+
# it will generate an string following the pattern specified
|
38
|
+
def generate(expected_errors: [], **synonyms)
|
39
|
+
StringPattern.generate(self, expected_errors: expected_errors, **synonyms)
|
40
|
+
end
|
41
|
+
|
42
|
+
alias_method :gen, :generate
|
43
|
+
|
44
|
+
# it will validate an string following the pattern specified
|
45
|
+
def validate(string_to_validate, expected_errors: [], not_expected_errors: [], **synonyms)
|
46
|
+
StringPattern.validate(text: string_to_validate, pattern: self.to_s, expected_errors: expected_errors, not_expected_errors: not_expected_errors, **synonyms)
|
47
|
+
end
|
48
|
+
|
49
|
+
alias_method :val, :validate
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
module Kernel
|
54
|
+
public
|
55
|
+
# if string or symbol supplied it will generate a string with the supplied pattern specified on the string
|
56
|
+
# if array supplied then it will generate a string with the supplied patterns. If a position contains a pattern supply it as symbol, for example: [:"10:N", "fixed", :"10-20:XN/x/"]
|
57
|
+
def generate(pattern, expected_errors: [], **synonyms)
|
58
|
+
if pattern.kind_of?(String) or pattern.kind_of?(Array) or pattern.kind_of?(Symbol)
|
59
|
+
StringPattern.generate(pattern, expected_errors: expected_errors, **synonyms)
|
60
|
+
else
|
61
|
+
puts " Kernel generate method: class not recognized:#{pattern.class}"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
alias_method :gen, :generate
|
66
|
+
end
|
67
|
+
|