secret_string 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/secret_string.rb +10 -1
- data/lib/secret_string/core_extensions/string.rb +15 -1
- data/lib/secret_string/version.rb +1 -1
- data/spec/secret_string_test/tests/secret_string_spec.rb +16 -0
- data/spec/secret_string_test/tests/string_spec.rb +5 -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: 5f912f9e56675854f647fb6a965c6e3cfac83e999827249cdac00bbe096c3fc8
|
4
|
+
data.tar.gz: dc352220e6220adc7555be9064855990f6171938621634db7eca177bf6ede15f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18344af3842f3a6e1198bb29b85165ac8dd72a5b9de990a6c4d690882792b63b8cd29c2440293bbdefc7b3b1980334b0fba3da053f302d708ee1348451a9d4f7
|
7
|
+
data.tar.gz: 20a5236e50e545c04df1e8de38187c92386dde543b76888681d3209fe9a05e46aa2dc38faa24b806523c034e899e250ecac9a7f351c91339f693001393b69f5c
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
# [v1.1.0](https://github.com/Muriel-Salvan/secret_string/compare/v1.0.1...v1.1.0) (2021-07-07 10:21:42)
|
2
|
+
|
3
|
+
### Features
|
4
|
+
|
5
|
+
* [[Feature] Add equality and pattern matching facilities between String and SecretString](https://github.com/Muriel-Salvan/secret_string/commit/8bc056e66b21ee2d289e0c14fce43be9a0104434)
|
6
|
+
|
1
7
|
# [v1.0.1](https://github.com/Muriel-Salvan/secret_string/compare/v1.0.0...v1.0.1) (2021-06-30 10:46:43)
|
2
8
|
|
3
9
|
### Patches
|
data/lib/secret_string.rb
CHANGED
@@ -46,13 +46,22 @@ class SecretString
|
|
46
46
|
@silenced_str = silenced_str
|
47
47
|
end
|
48
48
|
|
49
|
-
# Delegate the String representations methods to the silenced String by default
|
50
49
|
extend Forwardable
|
50
|
+
|
51
|
+
# Delegate the String representations methods to the silenced String
|
51
52
|
def_delegators :@silenced_str, *%i[
|
52
53
|
inspect
|
53
54
|
to_s
|
54
55
|
]
|
55
56
|
|
57
|
+
# Delegate the String identity methods to the unprotected String
|
58
|
+
def_delegators :@str, *%i[
|
59
|
+
==
|
60
|
+
=~
|
61
|
+
match
|
62
|
+
size
|
63
|
+
]
|
64
|
+
|
56
65
|
# Return the unprotected String
|
57
66
|
#
|
58
67
|
# Result::
|
@@ -19,10 +19,24 @@ class SecretString
|
|
19
19
|
# Nothing to do
|
20
20
|
end
|
21
21
|
|
22
|
+
# Compare the String with another object
|
23
|
+
#
|
24
|
+
# Parameters::
|
25
|
+
# * *other* (Object): Other object
|
26
|
+
# Result::
|
27
|
+
# * Boolean: Are objects equal?
|
28
|
+
def ==(other)
|
29
|
+
if other.is_a?(SecretString)
|
30
|
+
other == self
|
31
|
+
else
|
32
|
+
super
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
22
36
|
end
|
23
37
|
|
24
38
|
end
|
25
39
|
|
26
40
|
end
|
27
41
|
|
28
|
-
String.
|
42
|
+
String.prepend SecretString::CoreExtensions::String
|
@@ -21,6 +21,22 @@ describe SecretString do
|
|
21
21
|
expect(secret.to_unprotected).not_to eq 'MySecret'
|
22
22
|
end
|
23
23
|
|
24
|
+
it 'equals correctly with a string having the same content' do
|
25
|
+
expect(secret).to eq 'MySecret'
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'matches correctly with a string having the same content' do
|
29
|
+
expect(secret).to match(/Secret/)
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'matches correctly using the =~ operator with a string having the same content' do
|
33
|
+
expect(secret =~ /Secret/).not_to be nil
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'reports the correct size' do
|
37
|
+
expect(secret.size).to eq 'MySecret'.size
|
38
|
+
end
|
39
|
+
|
24
40
|
end
|
25
41
|
|
26
42
|
describe 'erase' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: secret_string
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Muriel Salvan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|