loggable_activity 0.1.55 → 0.1.58
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +10 -1
- data/CHANGELOG.md +14 -0
- data/GETTING-STARTED.md +8 -47
- data/PAYLOAD_EXAMPLE.md +63 -0
- data/docs/LoggableActivity/Activity.html +92 -241
- data/docs/LoggableActivity/Configuration.html +162 -15
- data/docs/LoggableActivity/ConfigurationError.html +148 -0
- data/docs/LoggableActivity/DataOwner.html +138 -0
- data/docs/LoggableActivity/Encryption.html +18 -14
- data/docs/LoggableActivity/EncryptionError.html +47 -1
- data/docs/LoggableActivity/EncryptionKey.html +54 -35
- data/docs/LoggableActivity/Error.html +48 -0
- data/docs/LoggableActivity/Hooks.html +221 -89
- data/docs/LoggableActivity/Payload.html +103 -27
- data/docs/LoggableActivity/Services/BasePayloadsBuilder.html +442 -0
- data/docs/LoggableActivity/Services/DestroyPayloadsBuilder.html +395 -0
- data/docs/LoggableActivity/Services/PayloadsBuilder.html +342 -0
- data/docs/LoggableActivity/Services/UpdatePayloadsBuilder.html +490 -0
- data/docs/LoggableActivity/Services.html +93 -0
- data/docs/created.rid +14 -10
- data/docs/index.html +10 -2
- data/docs/js/navigation.js.gz +0 -0
- data/docs/js/search_index.js +1 -1
- data/docs/js/search_index.js.gz +0 -0
- data/docs/js/searcher.js.gz +0 -0
- data/docs/table_of_contents.html +253 -85
- data/lib/generators/loggable_activity/install_generator.rb +2 -18
- data/lib/generators/loggable_activity/templates/binary_ids/create_loggable_activities.rb +9 -10
- data/lib/generators/loggable_activity/templates/create_loggable_activities.rb +16 -13
- data/lib/loggable_activity/activity.rb +58 -101
- data/lib/loggable_activity/configuration.rb +60 -3
- data/lib/loggable_activity/data_owner.rb +18 -0
- data/lib/loggable_activity/encryption.rb +14 -14
- data/lib/loggable_activity/encryption_key.rb +26 -25
- data/lib/loggable_activity/error.rb +34 -0
- data/lib/loggable_activity/hooks.rb +78 -43
- data/lib/loggable_activity/payload.rb +70 -20
- data/lib/loggable_activity/services/base_payloads_builder.rb +127 -0
- data/lib/loggable_activity/services/destroy_payloads_builder.rb +127 -0
- data/lib/loggable_activity/services/payloads_builder.rb +98 -0
- data/lib/loggable_activity/services/update_payloads_builder.rb +168 -0
- data/lib/loggable_activity/version.rb +1 -1
- data/lib/loggable_activity.rb +6 -6
- data/lib/schemas/config_schema.json +90 -0
- metadata +37 -26
- data/docs/LoggableActivity/PayloadsBuilder.html +0 -441
- data/docs/LoggableActivity/UpdatePayloadsBuilder.html +0 -424
- data/lib/.DS_Store +0 -0
- data/lib/generators/loggable_activity/install_templates_generator.rb +0 -103
- data/lib/generators/loggable_activity/templates/helpers/loggable_activity_helper.rb +0 -49
- data/lib/generators/loggable_activity/templates/loggable_activity_helper.rb +0 -58
- data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/default/_create.html.erb +0 -23
- data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/default/_create.html.slim +0 -18
- data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/default/_destroy.html.erb +0 -18
- data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/default/_destroy.html.slim +0 -17
- data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/default/_show.html.erb +0 -18
- data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/default/_show.html.slim +0 -17
- data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/default/_update.html.erb +0 -18
- data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/default/_update.html.slim +0 -12
- data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/shared/_activity_info.html.erb +0 -12
- data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/shared/_activity_info.html.slim +0 -11
- data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/shared/_list_attrs.html.erb +0 -8
- data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/shared/_list_attrs.html.slim +0 -6
- data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/shared/_update_attrs.html.erb +0 -17
- data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/shared/_update_attrs.html.slim +0 -14
- data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/shared/_updated_relations.html.erb +0 -23
- data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/shared/_updated_relations.html.slim +0 -21
- data/lib/loggable_activity/payloads_builder.rb +0 -153
- data/lib/loggable_activity/update_payloads_builder.rb +0 -127
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3443b88743e80e04335aeb6b192af90e69d6e79c22906784d8fde0efc303371e
|
4
|
+
data.tar.gz: 010db4535422917b8c7595e60d61e15a309c70456a95dfc4809bc6bcd382119e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 503bc1adc73fb22312c8ae21b2a68dfd12e4f452687bd0b3be947a73a2a5aa06e4c643461b5c6f768915cd09c00117ec5020028bb91c30bcc9e618226d8efeda
|
7
|
+
data.tar.gz: b6f50f7877b2164f8b58267c87a1a2b0ede19f85d9c05a9cd32cb7b1188405f738704fd0e17907ed521f51db0893a40a4102e48e6b8b998ecd422143cf1f546c
|
data/.rubocop.yml
CHANGED
@@ -31,12 +31,21 @@ Style/IfUnlessModifier:
|
|
31
31
|
Metrics/PerceivedComplexity:
|
32
32
|
Enabled: false
|
33
33
|
|
34
|
+
Metrics/ClassLength:
|
35
|
+
Exclude:
|
36
|
+
- lib/loggable_activity/services/update_payloads_builder.rb
|
37
|
+
|
38
|
+
Metrics/ParameterLists:
|
39
|
+
Exclude:
|
40
|
+
- lib/loggable_activity/services/base_payloads_builder.rb
|
41
|
+
|
34
42
|
Metrics/ModuleLength:
|
35
43
|
Exclude:
|
36
44
|
- lib/loggable_activity/hooks.rb
|
45
|
+
|
37
46
|
Metrics/AbcSize:
|
38
47
|
Exclude:
|
39
48
|
- lib/loggable_activity/encryption.rb
|
40
|
-
- lib/loggable_activity/
|
49
|
+
# - lib/loggable_activity/update_payloads_builderx.rb
|
41
50
|
- lib/generators/loggable_activity/templates/binary_ids/create_loggable_activities.rb
|
42
51
|
- lib/generators/loggable_activity/templates/create_loggable_activities.rb
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
|
2
|
+
## [0.1.58] - 2024-03-21
|
3
|
+
### Breaking change
|
4
|
+
- All presentations generators are removed
|
5
|
+
- Service modules for building of payloads
|
6
|
+
- Schema validation of configuration file
|
7
|
+
- Schema validation in tests of generated attrs
|
8
|
+
- Support for UUID's hanging, tbd
|
9
|
+
- 100 pct test coverage
|
10
|
+
|
11
|
+
## [0.1.56] - 2024-03-04
|
12
|
+
### Breaking change
|
13
|
+
- Generate links in helpers
|
14
|
+
|
1
15
|
## [0.1.54] - 2024-02-24
|
2
16
|
- Support for BinaryID's
|
3
17
|
- Updated README.md
|
data/GETTING-STARTED.md
CHANGED
@@ -40,7 +40,7 @@ Update `config/application.rb`, you might do it differently in production
|
|
40
40
|
config.loggable_activity = ActiveSupport::OrderedOptions.new
|
41
41
|
config.loggable_activity.actor_display_name = :full_name
|
42
42
|
config.loggable_activity.current_user_model_name = 'User'
|
43
|
-
LoggableActivity::Configuration.load_config_file('config/loggable_activity.yaml')
|
43
|
+
::LoggableActivity::Configuration.load_config_file('config/loggable_activity.yaml')
|
44
44
|
```
|
45
45
|
- actor_display_name: this is a method on the User model we want to use when presenting the actor.
|
46
46
|
- current_user_model: This is the name of the model we use for current_user
|
@@ -60,6 +60,7 @@ This file defines:
|
|
60
60
|
```
|
61
61
|
Demo::Club:
|
62
62
|
record_display_name: email
|
63
|
+
route: show_demo_club
|
63
64
|
loggable_attrs:
|
64
65
|
- email
|
65
66
|
- name
|
@@ -70,6 +71,7 @@ Demo::Club:
|
|
70
71
|
relations:
|
71
72
|
- belongs_to: :address
|
72
73
|
model: Demo::Address
|
74
|
+
route: show_address
|
73
75
|
loggable_attrs:
|
74
76
|
- street
|
75
77
|
- city
|
@@ -78,10 +80,11 @@ Demo::Club:
|
|
78
80
|
Lets break this down.
|
79
81
|
- First we can se that we are logging a model named Demo::Club.
|
80
82
|
- `record_display_name:` is the field/method on the on the model we want to display as a headline in the log
|
81
|
-
-
|
82
|
-
- Then we can se that we are
|
83
|
+
- `route` is a flag used to generate a link to the model logged, more on that later.
|
84
|
+
- Then we can se that we are logging the `email` and `name`.
|
85
|
+
- Then we can se that we are logging `create`, `update`, and `destroy` automatically.
|
83
86
|
- Then there are some relations: that we want to collect and add to the log.<br/>
|
84
|
-
In this example the club belongs to an
|
87
|
+
In this example the club belongs to an address so we add the street and city from the address to the log.
|
85
88
|
|
86
89
|
|
87
90
|
## Set current user
|
@@ -107,49 +110,7 @@ Supported relations at the moment is
|
|
107
110
|
- has_one
|
108
111
|
- has_many
|
109
112
|
|
110
|
-
|
111
|
-
*Optional*
|
112
|
-
<br/>You can install all the files needed to render a list of activities<br/>
|
113
|
-
The following command will generate all the files need for showing the activity log
|
114
|
-
```
|
115
|
-
$ rails g loggable_activity:install_templates
|
116
|
-
```
|
117
|
-
or for the slim template language. (don't run both)
|
118
|
-
```
|
119
|
-
$ rails g loggable_activity:install_templates --template=slim
|
120
|
-
```
|
121
|
-
Now you got the `loggable_activity_helper.rb' installed.<br/>
|
122
|
-
You can use the `render_activity` method from your view like this.
|
123
|
-
```
|
124
|
-
<table>
|
125
|
-
<thead>
|
126
|
-
<tr>
|
127
|
-
<th>Info</th>
|
128
|
-
<th>Attributes</th>
|
129
|
-
<th>Actions</th>
|
130
|
-
</tr>
|
131
|
-
</thead>
|
132
|
-
<tbody>
|
133
|
-
<% @loggable_activities.each do |activity| %>
|
134
|
-
<%= render_activity(activity) %>
|
135
|
-
<% end %>
|
136
|
-
</tbody>
|
137
|
-
</table>
|
138
|
-
```
|
139
|
-
Create a route and a controller and fetch the `@loggable_activities` like this
|
140
|
-
```
|
141
|
-
class ActivityLogsController < ApplicationController
|
142
|
-
def index
|
143
|
-
@loggable_activities = LoggableActivity::Activity.latest(50)
|
144
|
-
end
|
145
|
-
end
|
146
|
-
```
|
147
|
-
Or you can fetch all activities for a given actor like this
|
148
|
-
```
|
149
|
-
def show
|
150
|
-
@loggable_activities = LoggableActivity::Activity.where(actor: @user)
|
151
|
-
end
|
152
|
-
```
|
113
|
+
|
153
114
|
|
154
115
|
## For developers and contributors
|
155
116
|
If you can download and play around with a demo app
|
data/PAYLOAD_EXAMPLE.md
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# Example of a payload attributes
|
2
|
+
```
|
3
|
+
{
|
4
|
+
'actor_type' => 'User'
|
5
|
+
'actor_id' => "12"
|
6
|
+
'action' => 'user.update'
|
7
|
+
'payloads' =>
|
8
|
+
[
|
9
|
+
{
|
10
|
+
:related_to_activity_as => 'primary',
|
11
|
+
:record_type => 'User',
|
12
|
+
:record_id => 7,
|
13
|
+
:route => 'show_user',
|
14
|
+
'attrs' => {
|
15
|
+
:first_name =>
|
16
|
+
'changed' =>
|
17
|
+
{
|
18
|
+
'from' => 'Vo5qr2ZXdnUNvZlFPzPivVnZ4JJMHvftPKR9F5ZidDQ=\n',
|
19
|
+
'to' => 'c4849GlicNeNw/7arZBRu6BCAYNlc7bjfHfpPv4Ra1I=\n'
|
20
|
+
}
|
21
|
+
last_name => 'Vo9apehbkapd=\n',
|
22
|
+
'age' => {
|
23
|
+
'from' => 'Whybq9OToAIYjYlP2gbXaieKDXH5Ut/uXc+M9R1OAk8=\n',
|
24
|
+
'to' => 'SUvxCLFBl3HUxqYihoj7VU3Ai/GK/ji5APJZNwbERqQ=\n'
|
25
|
+
}
|
26
|
+
}
|
27
|
+
},
|
28
|
+
{
|
29
|
+
:related_to_activity_as => 'has_one'
|
30
|
+
:record_type => 'Demo::UserProfile',
|
31
|
+
:record_id => 7,
|
32
|
+
:route => 'show_user'
|
33
|
+
:attrs => {,
|
34
|
+
:sex =>
|
35
|
+
'changed' =>
|
36
|
+
{
|
37
|
+
'from' => 'aNY4G6dyaYyg7xiPwGMnGORsMvt8rzOKl7S+sEq1jYY=\n',
|
38
|
+
'to' => 'Pqo5vaojL1SV0DMLL5WQsuNjxcZY+Av/ckCbT00ZKUk=\n'
|
39
|
+
},
|
40
|
+
religion => 'christianity'
|
41
|
+
}
|
42
|
+
},
|
43
|
+
{
|
44
|
+
:related_to_activity_as => 'belongs_to,
|
45
|
+
:changed =>
|
46
|
+
:payload_attrs => {
|
47
|
+
:from => {
|
48
|
+
:state => 'current_association'
|
49
|
+
:record_type => 'Demo::Address',
|
50
|
+
:record_id => 7,
|
51
|
+
:route => 'show_address'
|
52
|
+
|
53
|
+
|
54
|
+
}
|
55
|
+
:to => {
|
56
|
+
|
57
|
+
}
|
58
|
+
|
59
|
+
}
|
60
|
+
}
|
61
|
+
]
|
62
|
+
}
|
63
|
+
```
|