rails-gdpr-export 1.0.0 → 1.0.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/Gemfile.lock +1 -1
- data/README.md +12 -9
- data/lib/gdpr_exporter/version.rb +1 -1
- data/lib/gdpr_exporter.rb +5 -2
- 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: 7dab6bb312d7424d72e84050f79b87ca1fd01a1c68ff14deb3210a33c8c6df7b
|
4
|
+
data.tar.gz: 3d6f9cfc9fc7751d138c332d6e85bccdcb48d80530ee621982f9dc0cd69d3837
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c255cfee87d8e55b73e0be2e2ac9150461c9d8e122148e78660945503f6ff914ae48e0a93ad76453852e536b431dc083ead653d669088da5a4560fd24d89a95
|
7
|
+
data.tar.gz: 6cb1209cce21e957771ca83467eb32e016bd1144149c8fe4f21cdc65a8bbccf02e266a6a608a6c3870c71267966f6a40690be06813ef26e72221fe6b4343b9a5
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -32,20 +32,22 @@ ActiveRecord::Base.send :include, GdprExporter
|
|
32
32
|
|
33
33
|
### Data collection
|
34
34
|
|
35
|
-
In order to specify the fields
|
36
|
-
The call target is a rails model and its arguments are
|
37
|
-
* set of simple fields
|
38
|
-
* a hash of params:
|
39
|
-
|
35
|
+
In order to specify the fields you want to return to the user you need to call `gdpr_collect`.
|
36
|
+
The call target is a rails model and its arguments are:
|
37
|
+
* a set of simple fields, i.e. fields that will be output as is,
|
38
|
+
* followed by a hash of params:
|
39
|
+
```ruby
|
40
|
+
{user_id: <the field in the model used as alias for the user_id field>
|
40
41
|
renamed_fields: {<field_from_db> => <field_name_in_output>}
|
41
42
|
table_name: <the new table name in output>
|
42
43
|
description: <a comment>
|
43
44
|
join: <an association>}
|
45
|
+
```
|
44
46
|
|
47
|
+
#### Example
|
45
48
|
|
46
49
|
```ruby
|
47
|
-
User.gdpr_collect :email, :last_sign_in_at, :
|
48
|
-
:type, :forward_mailbox,
|
50
|
+
User.gdpr_collect :email, :last_sign_in_at, :type, :forward_mailbox,
|
49
51
|
{user_id: :id,
|
50
52
|
renamed_fields: {sign_in_count: "sign in count",
|
51
53
|
current_sign_in_at: "time of current sign in",
|
@@ -54,10 +56,11 @@ User.gdpr_collect :email, :last_sign_in_at, :stripe_customer_id,
|
|
54
56
|
last_sign_in_ip: "previously used IP address"}}
|
55
57
|
```
|
56
58
|
|
57
|
-
|
59
|
+
From your `User` model, you want to retrieve the values of the fields `email, last_sign_in_at,
|
60
|
+
type, forward_mailbox`, in addition to the fields `sign_in_count, current_sign_in_at, chosen_program_id, current_sign_in_ip, last_sign_in_ip`. However for the latter you want their csv header to be renamed. And the field representing the user in the `User` model is `id`.
|
58
61
|
|
59
62
|
### Data export
|
60
|
-
|
63
|
+
Finally, call `GdprExporter.export(<user_id>)` to return a csv formatted output of all the fields you specified previously.
|
61
64
|
|
62
65
|
|
63
66
|
## Contributing
|
data/lib/gdpr_exporter.rb
CHANGED
@@ -76,9 +76,12 @@ module GdprExporter
|
|
76
76
|
self.class.send :attr_reader, :gdpr_hash_params
|
77
77
|
|
78
78
|
# Build the csv header and prepare the fields used for querying
|
79
|
+
#
|
79
80
|
user_id_field = hash_params[:user_id]
|
80
|
-
csv_headers = [:user_id].concat @gdpr_simple_fields
|
81
|
-
query_fields = [user_id_field].concat @gdpr_simple_fields
|
81
|
+
# csv_headers = [:user_id].concat @gdpr_simple_fields # Uncomment if user_id needed
|
82
|
+
# query_fields = [user_id_field].concat @gdpr_simple_fields # Uncomment if user_id needed
|
83
|
+
csv_headers = [].concat @gdpr_simple_fields
|
84
|
+
query_fields = [].concat @gdpr_simple_fields
|
82
85
|
|
83
86
|
if hash_params[:renamed_fields]
|
84
87
|
csv_headers.concat hash_params[:renamed_fields].values
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-gdpr-export
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chrislain Razafimahefa
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|