string_pattern 1.3.2 → 1.4.0
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/README.md +13 -0
- data/lib/string_pattern.rb +12 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c56944f9a6e4dd6c11c84813c12f02f72add7960a232c05a81aae8447aa81c71
|
4
|
+
data.tar.gz: 5bb325bfe497068222720536125816831f2bcc83a3d32cb71afc6ad5c6b2af1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9e2f38f33d7c3bf8e9c7af925f1c1a7d92971fa7836d0860aa8e47ce5f6e81eb36becf2303d643b1e97d2ed352be759507c8463c216223a3ec0c6e51cc049ee
|
7
|
+
data.tar.gz: fa6f8de323ba93f65a0a94735d9aea799e96162f4e18406d23960f938fb90b2fa5366fb75e5e92fd24a8ca34896fc6b5a48ce4f444fb2fdb9562b473d3964ead
|
data/README.md
CHANGED
@@ -85,6 +85,19 @@ StringPattern.dont_repeat = true #default: false
|
|
85
85
|
StringPattern.cache_values = Hash.new() #to clean the generated values from memory
|
86
86
|
```
|
87
87
|
|
88
|
+
Using dont_repeat all the generated string during the current run will be unique.
|
89
|
+
|
90
|
+
In case you just want one particular string to be unique but not the rest then add to the pattern just in the end the symbol: &
|
91
|
+
|
92
|
+
The pattern needs to be a symbol object.
|
93
|
+
|
94
|
+
```ruby
|
95
|
+
1000.times {
|
96
|
+
puts :"6-20:L/N/&".gen #will be unique
|
97
|
+
puts :"10:N".gen
|
98
|
+
}
|
99
|
+
```
|
100
|
+
|
88
101
|
#### Custom characters
|
89
102
|
|
90
103
|
Also, it's possible to provide the characters we want. To do that we'll use the symbol_type [characters]
|
data/lib/string_pattern.rb
CHANGED
@@ -669,6 +669,18 @@ class StringPattern
|
|
669
669
|
good_result=true
|
670
670
|
end
|
671
671
|
end
|
672
|
+
if pattern.kind_of?(Symbol) and symbol_type[-1]=="&"
|
673
|
+
if @cache_values[pattern.__id__].nil?
|
674
|
+
@cache_values[pattern.__id__]=Array.new()
|
675
|
+
@cache_values[pattern.__id__].push(string)
|
676
|
+
good_result=true
|
677
|
+
elsif @cache_values[pattern.__id__].include?(string)
|
678
|
+
good_result = false
|
679
|
+
else
|
680
|
+
@cache_values[pattern.__id__].push(string)
|
681
|
+
good_result=true
|
682
|
+
end
|
683
|
+
end
|
672
684
|
end until good_result or tries>10000
|
673
685
|
unless good_result
|
674
686
|
puts "Not possible to generate the string on StringPattern.generate: #{pattern.inspect}, expected_errors: #{expected_errors.inspect}"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: string_pattern
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mario Ruiz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-09-
|
11
|
+
date: 2018-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: You can easily generate strings supplying a very simple pattern. Also,
|
14
14
|
you can validate if a text fulfills a specific pattern or even generate a string
|