loggable_activity 0.1.59 → 0.2.1c

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: db2b65fd9476234eb90900437f005f9a84b9e29c1acb514236a8b24346278b17
4
- data.tar.gz: ef3113633c4c9b101e119d829213ee00c345af95700d112d800a06232fa442d6
3
+ metadata.gz: aedc39df0c92354d989c8991ca33392b22b17712b09d029b47e4c3f416a9fea6
4
+ data.tar.gz: 608619353a94d6488bcc5ab6b1b5e8355598051a8aace932ca7336ef41b04c0e
5
5
  SHA512:
6
- metadata.gz: ea6c0068987ae337395230e9147b7be7bbbedb10fc488dfad2c901bf5b590a51024333141fa350e7007e8c50ce8a453962770ee4e9cce8b5fb8f9ccc03d8b63a
7
- data.tar.gz: 73f5b8a7bca8f87907be31b4e4bc378a0a0caa34fa774c1ba21f2aa39da5733b56827e780be3460ed4415d5f2cb92e03a5a8c47919ac5df6f439cf1ed4331e19
6
+ metadata.gz: 15de688e047ce77333ce9b0b6cdbbad648c69dc2022f0d42913c0058c9ad0ddcd9397f8b6e143a1201cde0f0f6905e2a729f26d802233009bf6fb21814b78740
7
+ data.tar.gz: 6d8cb25b837e1fdfaa3ac4cf9e27ab875c681595f0c1e8f3131e8f69d8e35849f06a050ca62235d7214f2a67f139642ba5143e4d4f40d037c5dfee959b5289eb
@@ -0,0 +1,26 @@
1
+ {
2
+ "commands": [
3
+ {
4
+ "command": "terminals.runTerminalByName",
5
+ "arguments": [
6
+ "Test"
7
+ ],
8
+ "text": "$(run)",
9
+ "alignment": "right",
10
+ "priority": 300,
11
+ "tooltip": "Run test for current line",
12
+ "filterFileRegex": ".*_spec\\.rb"
13
+ },
14
+ {
15
+ "command": "terminals.runTerminalByName",
16
+ "arguments": [
17
+ "Test file"
18
+ ],
19
+ "text": "$(run-all)",
20
+ "alignment": "right",
21
+ "priority": 290,
22
+ "tooltip": "Run test for current file",
23
+ "filterFileRegex": ".*_spec\\.rb"
24
+ }
25
+ ]
26
+ }
@@ -0,0 +1,31 @@
1
+ {
2
+ "autorun": false,
3
+ "terminals": [
4
+ {
5
+ "name": "Test",
6
+ "focus": true,
7
+ "execute": true,
8
+ "onlySingle": true,
9
+ "icon": "run",
10
+ "commands": [
11
+ "dir=[file] && test_path=${${(s:/spec/:)dir}[1]} && file=\"spec/\"${${(s:/spec/:)dir}[2]}",
12
+ "echo \"$dir\\n$test_path\\n$file:[lineNumber]\"",
13
+ "cd $test_path",
14
+ "rspec $file:[lineNumber]"
15
+ ]
16
+ },
17
+ {
18
+ "name": "Test file",
19
+ "focus": true,
20
+ "execute": true,
21
+ "onlySingle": true,
22
+ "icon": "run-all",
23
+ "commands": [
24
+ "dir=[file] && test_path=${${(s:/spec/:)dir}[1]} && file=\"spec/\"${${(s:/spec/:)dir}[2]}",
25
+ "echo \"$dir\\n$test_path\\n$file\"",
26
+ "cd $test_path",
27
+ "rspec $file"
28
+ ]
29
+ }
30
+ ]
31
+ }
data/CHANGELOG.md CHANGED
@@ -1,4 +1,10 @@
1
1
 
2
+ ## [0.2.1b] - 2024-07-03
3
+ - Repo has moved to organization on github
4
+
5
+ ## [0.2.0] - 2024-07-03
6
+ - Keys kan be kept until LoggableActivity::Sanitizer.run is called
7
+
2
8
  ## [0.1.58] - 2024-03-21
3
9
  ### Breaking change
4
10
  - All presentations generators are removed
data/GETTING-STARTED.md CHANGED
@@ -7,7 +7,7 @@ This document should you getting started with `LoggableActivity`
7
7
 
8
8
  ## Demo Application
9
9
  You can download a demo application from<br/>
10
- [https://github.com/maxgronlund/LoggableActivityDemoApp](https://github.com/maxgronlund/LoggableActivityDemoApp)
10
+ [https://github.com/LoggableActivity/LoggableActivityDemoApp](https://github.com/LoggableActivity/LoggableActivityDemoApp)
11
11
  <br/>
12
12
  You can try a demo here<br/>
13
13
  [https://loggableactivity-efe7b931c886.herokuapp.com/](https://loggableactivity-efe7b931c886.herokuapp.com/)
@@ -114,6 +114,6 @@ Supported relations at the moment is
114
114
 
115
115
  ## For developers and contributors
116
116
  If you can download and play around with a demo app
117
- - 1 Down the demo project from [demo project on github](https://github.com/maxgronlund/LoggableActivityDemoApp)
117
+ - 1 Down the demo project from [demo project on github](https://github.com/LoggableActivity/LoggableActivityDemoApp)
118
118
  - 2 Update the Gemfile in the demo project so it points to your localhost.
119
119
  - 3 you can now build and test you version of the gem `$ gem build loggable_activity.gemspec`
data/README.md CHANGED
@@ -30,7 +30,7 @@ Beside the journal in the db, an activity log is kept so it is possible to track
30
30
  At some point in time the patients data from the DB and the activity log has to be removed according to GDPR.<br/>
31
31
 
32
32
  ### Getting started
33
- please read the [GETTING-STARTED.md](https://github.com/maxgronlund/LoggableActivity/blob/main/GETTING-STARTED.md) guide
33
+ please read the [GETTING-STARTED.md](https://github.com/LoggableActivity/LoggableActivity/blob/main/GETTING-STARTED.md) guide
34
34
 
35
35
  ### Contribute
36
36
  👉 Join the Slack channel here: [LoggableActivity Slack Workspace](https://join.slack.com/t/loggableactivity/shared_invite/zt-2a3tvgv37-mGwjHJTrBXBH2srXFRRSXQ)
data/ROADMAP.md CHANGED
@@ -4,7 +4,7 @@ Outline of steps to get the LoggableActivity adapted.
4
4
  ### Demo project
5
5
  Nothing is better than gain som experience by getting som real world tests and experiences.
6
6
  <br/>
7
- Try the [Live Demo]("https://loggableactivity-efe7b931c886.herokuapp.com/") here or download it from [Github]("https://github.com/maxgronlund/LoggableActivityDemoApp") here
7
+ Try the [Live Demo]("https://loggableactivity-efe7b931c886.herokuapp.com/") here or download it from [Github]("https://github.com/LoggableActivity/LoggableActivityDemoApp") here
8
8
 
9
9
 
10
10
  ### Open Source
@@ -80,7 +80,7 @@ module LoggableActivity
80
80
 
81
81
 
82
82
  For more information, please visit:
83
- https://github.com/maxgronlund/LoggableActivity/blob/main/GETTING-STARTED.md
83
+ https://github.com/LoggableActivity/LoggableActivity/blob/main/GETTING-STARTED.md
84
84
 
85
85
  ------------------------------------------------
86
86
  MESSAGE
@@ -30,6 +30,7 @@ class CreateLoggableActivities < ActiveRecord::Migration[7.1]
30
30
  create_table :loggable_encryption_keys do |t|
31
31
  t.references :record, polymorphic: true, null: true, index: true
32
32
  t.string :secret_key
33
+ t.datetime :delete_at
33
34
  end
34
35
  end
35
36
  end
@@ -18,6 +18,23 @@ module LoggableActivity
18
18
  validates :action, presence: true
19
19
  validate :must_have_at_least_one_payload
20
20
 
21
+ RELATION_TYPES = {
22
+ 'primary_payload' => 'self',
23
+ 'primary_update_payload' => 'self',
24
+ 'primary_destroy_payload' => 'self',
25
+ 'has_one_payload' => 'has_one',
26
+ 'has_one_create_payload' => 'has_one',
27
+ 'has_one_update_payload' => 'has_one',
28
+ 'has_one_destroy_payload' => 'has_one',
29
+ 'has_many_payload' => 'has_many',
30
+ 'has_many_create_payload' => 'has_many',
31
+ 'has_many_destroy_payload' => 'has_many',
32
+ 'has_many_update_payload' => 'has_many',
33
+ 'belongs_to_payload' => 'belongs_to',
34
+ 'belongs_to_destroy_payload' => 'belongs_to',
35
+ 'belongs_to_update_payload' => 'belongs_to'
36
+ }
37
+
21
38
  # Returns an array of hashes, each representing an activity's attributes and its associated relations. The structure and relations to include are specified in 'config/loggable_activity.yaml'. This format is designed for UI display purposes.
22
39
  #
23
40
  # Each hash in the array contains:
@@ -48,7 +65,7 @@ module LoggableActivity
48
65
  def payloads_attrs
49
66
  ordered_payloads.map do |payload|
50
67
  {
51
- related_to_activity_as: payload.related_to_activity_as,
68
+ relation: RELATION_TYPES[payload.related_to_activity_as],
52
69
  record_type: payload.record_type,
53
70
  record_id: payload.deleted? ? nil : payload.record_id,
54
71
  attrs: payload.attrs,
@@ -85,5 +85,10 @@ module LoggableActivity
85
85
  def self.current_user_model_name
86
86
  @config_data['current_user_model_name']
87
87
  end
88
+
89
+ # Returns whatever models should be sanitized on delete.
90
+ def self.task_for_sanitization
91
+ @config_data['task_for_sanitization']
92
+ end
88
93
  end
89
94
  end
@@ -14,16 +14,28 @@ module LoggableActivity
14
14
  # belongs_to :parent_key, class_name: '::LoggableActivity::EncryptionKey', optional: true,
15
15
  # foreign_key: 'parent_key_id'
16
16
 
17
- # Marks the encryption key as deleted by updating the key to nil.
17
+ # Prepare the record for deletion
18
18
  def mark_as_deleted!
19
- update(secret_key: nil)
19
+ LoggableActivity::Configuration.task_for_sanitization ? update(delete_at: DateTime.now + 1.month) : delete
20
20
  end
21
21
 
22
- # check if the encryption key is deleted
22
+ # check if the encryption key is deleted or it is about to be deleted
23
23
  def deleted?
24
- secret_key.nil?
24
+ secret_key.nil? || delete_at.present?
25
25
  end
26
26
 
27
+ # Delete the encryption key by updating the key to nil.
28
+ def delete
29
+ update(secret_key: nil, delete_at: nil)
30
+ end
31
+
32
+ # Restores the encryption key by updating the delete_at field to nil.
33
+ def restore!
34
+ update(delete_at: nil) if delete_at && DateTime.now < delete_at
35
+ end
36
+
37
+
38
+
27
39
  # Returns an encryption key for a record by its type and ID, optionally using a parent key.
28
40
  #
29
41
  # @param record_type [String] The type of the record.
@@ -206,6 +206,7 @@ module LoggableActivity
206
206
  def base_action
207
207
  name.downcase.gsub('::', '/')
208
208
  end
209
+
209
210
  end
210
211
  end
211
212
  end
@@ -0,0 +1,9 @@
1
+ module LoggableActivity
2
+ module Sanitizer
3
+ def self.run
4
+ ::LoggableActivity::EncryptionKey.where('delete_at < ?', DateTime.now).find_in_batches do |batch|
5
+ batch.each(&:delete)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -3,5 +3,5 @@
3
3
  # Version of the gem
4
4
  module LoggableActivity
5
5
  # Version
6
- VERSION = '0.1.59'
6
+ VERSION = '0.2.1c'
7
7
  end
@@ -9,6 +9,7 @@ require_relative 'loggable_activity/data_owner'
9
9
  require_relative 'loggable_activity/hooks'
10
10
  require_relative 'loggable_activity/payload'
11
11
  require_relative 'loggable_activity/error'
12
+ require_relative 'loggable_activity/sanitizer'
12
13
  require_relative 'loggable_activity/services/base_payloads_builder'
13
14
  require_relative 'loggable_activity/services/payloads_builder'
14
15
  require_relative 'loggable_activity/services/update_payloads_builder'
@@ -7,10 +7,13 @@
7
7
  },
8
8
  "fetch_current_user_name_from": {
9
9
  "type": "string"
10
+ },
11
+ "task_for_sanitization": {
12
+ "type": "boolean"
10
13
  }
11
14
  },
12
15
  "patternProperties": {
13
- "^(?!current_user_model_name$|fetch_current_user_name_from$)[A-Za-z0-9_:]+$": {
16
+ "^(?!current_user_model_name$|fetch_current_user_name_from$|task_for_sanitization)[A-Za-z0-9_:]+$": {
14
17
  "type": "object",
15
18
  "properties": {
16
19
  "data_owner": {
@@ -19,6 +22,9 @@
19
22
  "fetch_record_name_from": {
20
23
  "type": "string"
21
24
  },
25
+ "task_for_sanitization": {
26
+ "type": "boolean"
27
+ },
22
28
  "loggable_attrs": {
23
29
  "type": "array",
24
30
  "items": {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loggable_activity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.59
4
+ version: 0.2.1c
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Max \nGroenlund"
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-03-21 00:00:00.000000000 Z
11
+ date: 2024-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -92,6 +92,20 @@ dependencies:
92
92
  - - ">="
93
93
  - !ruby/object:Gem::Version
94
94
  version: 6.1.1
95
+ - !ruby/object:Gem::Dependency
96
+ name: rspec-mocks
97
+ requirement: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - "~>"
100
+ - !ruby/object:Gem::Version
101
+ version: '3.13'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - "~>"
107
+ - !ruby/object:Gem::Version
108
+ version: '3.13'
95
109
  - !ruby/object:Gem::Dependency
96
110
  name: sqlite3
97
111
  requirement: !ruby/object:Gem::Requirement
@@ -106,6 +120,26 @@ dependencies:
106
120
  - - "~>"
107
121
  - !ruby/object:Gem::Version
108
122
  version: 1.4.2
123
+ - !ruby/object:Gem::Dependency
124
+ name: awesome_print
125
+ requirement: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - "~>"
128
+ - !ruby/object:Gem::Version
129
+ version: '1.9'
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: 1.9.2
133
+ type: :development
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - "~>"
138
+ - !ruby/object:Gem::Version
139
+ version: '1.9'
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: 1.9.2
109
143
  - !ruby/object:Gem::Dependency
110
144
  name: factory_bot
111
145
  requirement: !ruby/object:Gem::Requirement
@@ -164,6 +198,8 @@ files:
164
198
  - ".rspec"
165
199
  - ".rspec_status"
166
200
  - ".rubocop.yml"
201
+ - ".vscode/commands.json"
202
+ - ".vscode/terminals.json"
167
203
  - CHANGELOG.md
168
204
  - CODE_OF_CONDUCT.md
169
205
  - CONSIDERTIONS.md
@@ -254,6 +290,7 @@ files:
254
290
  - lib/loggable_activity/error.rb
255
291
  - lib/loggable_activity/hooks.rb
256
292
  - lib/loggable_activity/payload.rb
293
+ - lib/loggable_activity/sanitizer.rb
257
294
  - lib/loggable_activity/services/base_payloads_builder.rb
258
295
  - lib/loggable_activity/services/destroy_payloads_builder.rb
259
296
  - lib/loggable_activity/services/payloads_builder.rb
@@ -267,9 +304,9 @@ licenses:
267
304
  - MIT
268
305
  metadata:
269
306
  homepage_uri: https://loggableactivity-efe7b931c886.herokuapp.com/
270
- source_code_uri: https://github.com/maxgronlund/LoggableActivity
271
- changelog_uri: https://github.com/maxgronlund/LoggableActivity/CHANGELOG.md
272
- documentation_uri: https://maxgronlund.github.io/LoggableActivity/
307
+ source_code_uri: https://github.com/LoggableActivity/LoggableActivity
308
+ changelog_uri: https://github.com/LoggableActivity/LoggableActivity/CHANGELOG.md
309
+ documentation_uri: https://LoggableActivity.github.io/LoggableActivity/
273
310
  rubygems_mfa_required: 'true'
274
311
  post_install_message:
275
312
  rdoc_options: []
@@ -286,7 +323,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
286
323
  - !ruby/object:Gem::Version
287
324
  version: '0'
288
325
  requirements: []
289
- rubygems_version: 3.5.6
326
+ rubygems_version: 3.5.7
290
327
  signing_key:
291
328
  specification_version: 4
292
329
  summary: Activity Logger with relations, prepared for GDPR Compliance and .