loggable_activity 0.1.56 → 0.1.59

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +10 -1
  3. data/CHANGELOG.md +9 -0
  4. data/GETTING-STARTED.md +8 -47
  5. data/PAYLOAD_EXAMPLE.md +63 -0
  6. data/docs/LoggableActivity/Activity.html +92 -241
  7. data/docs/LoggableActivity/Configuration.html +162 -15
  8. data/docs/LoggableActivity/ConfigurationError.html +148 -0
  9. data/docs/LoggableActivity/DataOwner.html +138 -0
  10. data/docs/LoggableActivity/Encryption.html +18 -14
  11. data/docs/LoggableActivity/EncryptionError.html +47 -1
  12. data/docs/LoggableActivity/EncryptionKey.html +54 -35
  13. data/docs/LoggableActivity/Error.html +48 -0
  14. data/docs/LoggableActivity/Hooks.html +221 -89
  15. data/docs/LoggableActivity/Payload.html +103 -27
  16. data/docs/LoggableActivity/Services/BasePayloadsBuilder.html +442 -0
  17. data/docs/LoggableActivity/Services/DestroyPayloadsBuilder.html +395 -0
  18. data/docs/LoggableActivity/Services/PayloadsBuilder.html +342 -0
  19. data/docs/LoggableActivity/Services/UpdatePayloadsBuilder.html +490 -0
  20. data/docs/LoggableActivity/Services.html +93 -0
  21. data/docs/created.rid +14 -10
  22. data/docs/index.html +10 -2
  23. data/docs/js/navigation.js.gz +0 -0
  24. data/docs/js/search_index.js +1 -1
  25. data/docs/js/search_index.js.gz +0 -0
  26. data/docs/js/searcher.js.gz +0 -0
  27. data/docs/table_of_contents.html +253 -85
  28. data/lib/generators/loggable_activity/install_generator.rb +2 -18
  29. data/lib/generators/loggable_activity/templates/.DS_Store +0 -0
  30. data/lib/generators/loggable_activity/templates/binary_ids/create_loggable_activities.rb +9 -10
  31. data/lib/generators/loggable_activity/templates/create_loggable_activities.rb +16 -13
  32. data/lib/loggable_activity/activity.rb +53 -102
  33. data/lib/loggable_activity/configuration.rb +60 -3
  34. data/lib/loggable_activity/data_owner.rb +18 -0
  35. data/lib/loggable_activity/encryption.rb +14 -14
  36. data/lib/loggable_activity/encryption_key.rb +26 -25
  37. data/lib/loggable_activity/error.rb +34 -0
  38. data/lib/loggable_activity/hooks.rb +78 -43
  39. data/lib/loggable_activity/payload.rb +70 -20
  40. data/lib/loggable_activity/services/base_payloads_builder.rb +127 -0
  41. data/lib/loggable_activity/services/destroy_payloads_builder.rb +127 -0
  42. data/lib/loggable_activity/services/payloads_builder.rb +98 -0
  43. data/lib/loggable_activity/services/update_payloads_builder.rb +170 -0
  44. data/lib/loggable_activity/version.rb +1 -1
  45. data/lib/loggable_activity.rb +6 -6
  46. data/lib/schemas/config_schema.json +90 -0
  47. metadata +37 -26
  48. data/docs/LoggableActivity/PayloadsBuilder.html +0 -441
  49. data/docs/LoggableActivity/UpdatePayloadsBuilder.html +0 -424
  50. data/lib/generators/loggable_activity/install_templates_generator.rb +0 -105
  51. data/lib/generators/loggable_activity/templates/helpers/activity_helper.rb +0 -37
  52. data/lib/generators/loggable_activity/templates/helpers/router.rb +0 -52
  53. data/lib/generators/loggable_activity/templates/helpers/routes_helper.rb +0 -20
  54. data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/default/_create.html.erb +0 -23
  55. data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/default/_create.html.slim +0 -18
  56. data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/default/_destroy.html.erb +0 -18
  57. data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/default/_destroy.html.slim +0 -17
  58. data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/default/_show.html.erb +0 -18
  59. data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/default/_show.html.slim +0 -17
  60. data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/default/_update.html.erb +0 -18
  61. data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/default/_update.html.slim +0 -12
  62. data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/shared/_activity_info.html.erb +0 -12
  63. data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/shared/_activity_info.html.slim +0 -11
  64. data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/shared/_list_attrs.html.erb +0 -8
  65. data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/shared/_list_attrs.html.slim +0 -6
  66. data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/shared/_update_attrs.html.erb +0 -17
  67. data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/shared/_update_attrs.html.slim +0 -14
  68. data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/shared/_updated_relations.html.erb +0 -23
  69. data/lib/generators/loggable_activity/templates/views/loggable_activity/templates/shared/_updated_relations.html.slim +0 -21
  70. data/lib/loggable_activity/payloads_builder.rb +0 -153
  71. 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: 0026d9021dbb8d457f89aae37cefeab76c25307392f7df9bf33576ced785ab2a
4
- data.tar.gz: 1a7e30aee22dad70a1d5b6cfdbc8fbc5647ed9a84acb8e1793a12342dbd2845f
3
+ metadata.gz: db2b65fd9476234eb90900437f005f9a84b9e29c1acb514236a8b24346278b17
4
+ data.tar.gz: ef3113633c4c9b101e119d829213ee00c345af95700d112d800a06232fa442d6
5
5
  SHA512:
6
- metadata.gz: 4207be61cc5c3fc3c9f6f8a37a6d589b92c0c5067cfc76dc8187ff94a4c8fcf4f8438c0682830bd609ff78883c3ee863985642926ddbece92a2a230c6b96e7a9
7
- data.tar.gz: c770403638780d4708ef561eea6e3522dc1d16de6ac916d656db608e52ec24d88ba24a8314410f542d31a56d1f192a6869a67a0a486721dffc7d2b01dea8d7a8
6
+ metadata.gz: ea6c0068987ae337395230e9147b7be7bbbedb10fc488dfad2c901bf5b590a51024333141fa350e7007e8c50ce8a453962770ee4e9cce8b5fb8f9ccc03d8b63a
7
+ data.tar.gz: 73f5b8a7bca8f87907be31b4e4bc378a0a0caa34fa774c1ba21f2aa39da5733b56827e780be3460ed4415d5f2cb92e03a5a8c47919ac5df6f439cf1ed4331e19
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/update_payloads_builder.rb
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,4 +1,13 @@
1
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
+
2
11
  ## [0.1.56] - 2024-03-04
3
12
  ### Breaking change
4
13
  - Generate links in helpers
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
- - Then we can se that we are logging the **name** of the club, in this example that's all there is to log.
82
- - Then we can se that we are **logging create, update, and destroy** automatically.
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 addres so we add the street and city from the address to the log.
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
- ## Render templates
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
@@ -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
+ ```