activerecord-obscuredid 0.1.0 → 0.2.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba24a717b4184483875e367e36d6088fee5a4699a9305ff4487b8522b60b81c6
|
4
|
+
data.tar.gz: 0f04af937c13b4cffab241062b9972f9f761555b331f4016cdd5b660d44fca8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b53d9d4eedf6f3516c6a39c745d9936b9b9fcfe65ed7931707b8fb1485781f4f04b632282d6a533f0ea84efc292d132e23352572dfa6d70f19039cd0a9122952
|
7
|
+
data.tar.gz: 51908341f08140c0bc146fd5ecec3f1efe11b913fed822114e8547d6b51bedbf59f87548307e0680ab465e18e0b708628d700480ee45f10ead164a558f507e18
|
data/README.md
CHANGED
@@ -6,13 +6,13 @@
|
|
6
6
|
Install the gem and add to the application's Gemfile by executing:
|
7
7
|
|
8
8
|
```bash
|
9
|
-
$ bundle add
|
9
|
+
$ bundle add activerecord-obscuredid
|
10
10
|
```
|
11
11
|
|
12
12
|
If bundler is not being used to manage dependencies, install the gem by executing:
|
13
13
|
|
14
14
|
```bash
|
15
|
-
$ gem install
|
15
|
+
$ gem install activerecord-obscuredid
|
16
16
|
```
|
17
17
|
|
18
18
|
## Configuration
|
@@ -23,6 +23,9 @@ By default, the gem uses example.com as the domain for generating obscured email
|
|
23
23
|
# config/initializers/obscured_id.rb
|
24
24
|
ActiveRecord::ObscuredId.configure do |config|
|
25
25
|
config.domain = 'yourdomain.com'
|
26
|
+
|
27
|
+
# if you change your domain, and still need records to be findable by the old domain name
|
28
|
+
config.old_domains = ['yourolddomain.com']
|
26
29
|
end
|
27
30
|
```
|
28
31
|
|
@@ -5,10 +5,11 @@ module ActiveRecord
|
|
5
5
|
module ObscuredId
|
6
6
|
# Holds configuration options for obscured id
|
7
7
|
class Configuration
|
8
|
-
attr_accessor :domain
|
8
|
+
attr_accessor :domain, :old_domains
|
9
9
|
|
10
10
|
def initialize
|
11
11
|
@domain = 'example.com'
|
12
|
+
@old_domains = []
|
12
13
|
end
|
13
14
|
end
|
14
15
|
|
@@ -15,9 +15,12 @@ module ActiveRecord
|
|
15
15
|
class_methods do
|
16
16
|
def from_obscured_email_address(obscured_email_address)
|
17
17
|
domain = obscured_id_email_domain
|
18
|
+
old_domains = obscured_id_email_old_domains
|
18
19
|
subdomain = obscured_id_email_subdomain
|
19
20
|
|
20
|
-
|
21
|
+
matched = obscured_email_address.match?(/@#{subdomain}.#{domain}\z/)
|
22
|
+
matched ||= obscured_email_address.match?(/@#{subdomain}.(#{old_domains.join('|')})\z/) if old_domains.any?
|
23
|
+
return nil unless matched
|
21
24
|
|
22
25
|
find_obscured(obscured_email_address.remove(/@.*\z/))
|
23
26
|
end
|
@@ -25,6 +28,7 @@ module ActiveRecord
|
|
25
28
|
private
|
26
29
|
|
27
30
|
def obscured_id_email_domain = ActiveRecord::ObscuredId.config.domain
|
31
|
+
def obscured_id_email_old_domains = ActiveRecord::ObscuredId.config.old_domains
|
28
32
|
def obscured_id_email_subdomain = name.pluralize.underscore.dasherize.downcase
|
29
33
|
end
|
30
34
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-obscuredid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- darthrighteous
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|