loggable_activity 0.1.49 → 0.1.51

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: e3a71b62ddccb997e31e0592a4069f3c1684043fe5dee77691801930ebd86a43
4
- data.tar.gz: 7b8cf906c1357bbc2e90172020de8ab712132ba43de3a53fc0d4058cfa391bd8
3
+ metadata.gz: 562b5492910176c8bc5816b7f5691ae386c015d1a969b71a33c45f708383c185
4
+ data.tar.gz: 577534f63904b76ac414d1dba76aac35725892b127a3f268de650eeb4ed4629e
5
5
  SHA512:
6
- metadata.gz: a951d551a83e4cab2c58ec1b6a3b00c1814ecd099bdf38682d024a99298417912f6efcaf1c1d625f8ee4f877ac60f7ab851cc9a00b2c7201fb9fba2cf1e093b1
7
- data.tar.gz: 4821fd58720ad28bd77d7f958f0c1ce39de246503b93a4027097fa61c3b5f4b4e3ca3f673f37271205a121717905f3dbb12337ad3193e40fe12f6098f69667ec
6
+ metadata.gz: 631979df293ae2f1e03125b0a900c7eb432a59f163b0ab1c3a2c7e559d5e9e75f33e7fb0f686fece6f80888264f5b703719bfe7c2d6069a2a49512424414d913
7
+ data.tar.gz: 749dd6e36b9017f5c6b92572b1a9bf47e4c0e8fbe418d0d38e6ab0cd51553ccd64fa92f286ed45bc9e39d7a4dab2e5d74517093da6772578b82044379f53048d
data/.rubocop.yml CHANGED
@@ -1,13 +1,16 @@
1
1
  AllCops:
2
- # TargetRubyVersion: '3.0.1'
2
+ TargetRubyVersion: '3.2.0'
3
3
  NewCops: enable
4
4
  Exclude:
5
5
  - 'db/schema.rb'
6
- - 'vendor/**/*'
6
+ # - 'vendor/**/*'
7
7
 
8
8
  Style/Documentation:
9
9
  Enabled: false
10
10
 
11
+ Gemspec/DevelopmentDependencies:
12
+ Enabled: false
13
+
11
14
  Layout/LineLength:
12
15
  Enabled: false
13
16
 
data/CHANGELOG.md CHANGED
@@ -1,7 +1,9 @@
1
- ## [Unreleased]
2
- - nothing so far
1
+ ## [0.1.51] - 2024-02-18
2
+ - Added RSpec test
3
+ - Added rubocop
4
+
3
5
  ## [0.1.49] - 2024-02-18
4
- - Metadata, pointing to hompage
6
+ - Metadata, pointing to homepage
5
7
 
6
8
  ## [0.1.48] - 2024-02-16
7
9
  ### Breaking change
data/GETTING-STARTED.md CHANGED
@@ -65,7 +65,7 @@ class ApplicationController < ActionController::Base
65
65
  ```
66
66
  This will give us access to the current_user.
67
67
 
68
- And then we have to add this to 'config/application.rb'
68
+ And then we have to add this to `config/application.rb`
69
69
  ```
70
70
  config.loggable_activity = ActiveSupport::OrderedOptions.new
71
71
  config.loggable_activity.actor_display_name = :full_name
@@ -77,59 +77,26 @@ current_user_model: This is the name of the model we use for current_user
77
77
  load_config_file: this is the configuration file from above.
78
78
 
79
79
 
80
- ## Configuration
81
-
82
- ```
83
- User:
84
- record_display_name: full_name
85
- loggable_attrs:
86
- - first_name
87
- - last_name
88
- auto_log:
89
- - create
90
- - update
91
- - destroy
92
- relations:
93
- - belongs_to: :demo_address
94
- model: Demo::Address
95
- loggable_attrs:
96
- - street
97
- - city
98
- Demo::Address:
99
- record_display_name: full_address
100
- actor_display_name: email
101
- loggable_attrs:
102
- - street
103
- - city
104
- - country
105
- - postal_code
106
- ```
107
80
  Then you HAVE TO to add `LogggableActivity::Hooks` to the `User Model` like this
108
81
 
109
82
  ```
110
83
  class User < ApplicationRecord
111
84
  include LoggableActivity::Hooks
112
85
  ...
113
- ```
86
+ resto of your code here.
114
87
 
115
- And finally you have to add this to the `ApplicationController`
116
- ```
117
- class ApplicationController < ActionController::Base
118
- include LoggableActivity::CurrentUser
119
88
  ```
120
89
 
121
- Now if you create a model like this:
122
- ```
123
- $ rails c
124
- $ User.create(first_name: 'John', last_name: 'Doe')
125
- ```
126
90
 
127
- Then an `LoggableActivity::Activity` is created. You can inspect it from the terminal like this.
91
+ ### Log the show action
92
+ If you want to log the show action you can add this to your controllers show method
128
93
  ```
129
- puts activity = Loggable::Activity.last
130
- puts activity.attrs
94
+ def show
95
+ @user.log(:show)
131
96
  ```
132
97
 
98
+
99
+
133
100
  ## For developers
134
101
  If you want to contribute to the development and try it out in the process
135
102
  - 1 Down the demo project from [demo project on github](https://github.com/maxgronlund/LoggableActivityDemoApp)
data/README.md CHANGED
@@ -20,14 +20,14 @@ Most organizations needs to keep a log of how users interact with data stored in
20
20
 
21
21
  *Super simplified example from the healthcare.*
22
22
  - Each patient has a journal, that is updated on a regular basis.
23
- - Supervisor needs to follow the journal, how was it updated, who read it.
23
+ - Supervisor needs to follow the journal, how was it updated, who read it, did it get deleted.
24
24
  - Security personnel needs to know how the journal is handled, who did what when.
25
- - Patients has the right to know how their journal is handled and that the log is deleted.
25
+ - Patients has the right to know how their journal is handled and that their data will be removed when required.
26
26
 
27
27
  Beside the journal in the db, an activity log is kept so it is possible to track how the journal is used.<br/>
28
28
  At some point in time the patients data from the DB and the activity log has to be removed according to GDPR.<br/>
29
29
 
30
-
30
+ ### Contribute
31
31
  👉 Join the Slack channel here: [LoggableActivity Slack Workspace](https://join.slack.com/t/loggableactivity/shared_invite/zt-2a3tvgv37-mGwjHJTrBXBH2srXFRRSXQ)
32
32
  <br/>
33
33
  👉 Want to play around with an online version: [Show Demo](https://loggableactivity-efe7b931c886.herokuapp.com/)
@@ -35,3 +35,6 @@ At some point in time the patients data from the DB and the activity log has to
35
35
  We value each contribution and believe in the power of community. Looking forward to seeing you there!
36
36
 
37
37
 
38
+ ### Test
39
+ We embrace the philosophy of black-box testing, where we focus on the input and output of the public interface without worrying about internal implementation details.<br/>
40
+ This approach aligns with the principle of testing behavior rather than implementation.
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'active_record'
4
+
3
5
  module LoggableActivity
4
6
  # Represents one action in the activity log.
5
7
  class Activity < ActiveRecord::Base
@@ -224,6 +226,13 @@ module LoggableActivity
224
226
  .limit(limit)
225
227
  end
226
228
 
229
+ # Returns the last activity.
230
+ def self.last(limit = 1)
231
+ return latest(1).first if limit == 1
232
+
233
+ latest(limit)
234
+ end
235
+
227
236
  private
228
237
 
229
238
  def update_attrs
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'active_record'
4
+
3
5
  module LoggableActivity
4
6
  # This class represents the encryption key used to unlock the data for one payload.
5
7
  # When deleted, only the encryption_key field is deleted.
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'active_support/concern'
4
+
3
5
  # This is the main module for loggable.
4
6
  # When included to a model, it provides the features for creating the activities.
5
7
  require 'loggable_activity/payloads_builder'
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'active_record'
4
+
3
5
  module LoggableActivity
4
6
  # This class represents a payload in the log, containing encrypted data of one record in the database.
5
7
  # When the record is deleted, the encryption key for the payload is also deleted.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LoggableActivity
4
- VERSION = '0.1.49'
4
+ VERSION = '0.1.51'
5
5
  end
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # require 'rails'
4
-
3
+ require_relative 'loggable_activity/version'
5
4
  require_relative 'loggable_activity/activity'
6
5
  require_relative 'loggable_activity/configuration'
7
6
  require_relative 'loggable_activity/encryption'
@@ -10,7 +9,6 @@ require_relative 'loggable_activity/hooks'
10
9
  require_relative 'loggable_activity/payload'
11
10
  require_relative 'loggable_activity/payloads_builder'
12
11
  require_relative 'loggable_activity/update_payloads_builder'
13
- require_relative 'loggable_activity/version'
14
12
 
15
13
  module LoggableActivity
16
14
  class Error < StandardError; end
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.49
4
+ version: 0.1.51
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-02-18 00:00:00.000000000 Z
11
+ date: 2024-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -24,6 +24,102 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 7.1.3
27
+ - !ruby/object:Gem::Dependency
28
+ name: rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: generator_spec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.10.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.10.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: sqlite3
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 1.4.2
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 1.4.2
83
+ - !ruby/object:Gem::Dependency
84
+ name: factory_bot
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '6.4'
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: 6.4.6
93
+ type: :development
94
+ prerelease: false
95
+ version_requirements: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - "~>"
98
+ - !ruby/object:Gem::Version
99
+ version: '6.4'
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: 6.4.6
103
+ - !ruby/object:Gem::Dependency
104
+ name: rubocop
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '1.60'
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: 1.60.2
113
+ type: :development
114
+ prerelease: false
115
+ version_requirements: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - "~>"
118
+ - !ruby/object:Gem::Version
119
+ version: '1.60'
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: 1.60.2
27
123
  description: |2
28
124
  LoggableActivity is a powerful gem for Ruby on Rails that provides seamless user activity logging
29
125
  prepared for GDPR compliance and supporting record relations. It allows you to effortlessly
@@ -147,7 +243,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
147
243
  requirements:
148
244
  - - ">="
149
245
  - !ruby/object:Gem::Version
150
- version: '3.2'
246
+ version: 3.2.0
151
247
  required_rubygems_version: !ruby/object:Gem::Requirement
152
248
  requirements:
153
249
  - - ">="