loggable_activity 0.2.1 → 0.5.0
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/.rubocop.yml +29 -42
- data/.vscode/commands.json +2 -2
- data/.vscode/terminals.json +8 -8
- data/CHEAT_SHEET.md +31 -0
- data/MIT-LICENSE +21 -0
- data/README.md +31 -45
- data/Rakefile +6 -4
- data/app/assets/config/loggable_activity_manifest.js +4 -0
- data/app/assets/javascripts/loggable_activity/application.js +2 -0
- data/app/assets/stylesheets/loggable_activity/application.scss +20 -0
- data/app/controllers/concerns/.keep +0 -0
- data/app/controllers/loggable_activity/activities_controller.rb +12 -0
- data/app/controllers/loggable_activity/application_controller.rb +6 -0
- data/app/helpers/loggable_activity/activities_helper.rb +17 -0
- data/app/helpers/loggable_activity/application_helper.rb +6 -0
- data/app/jobs/loggable_activity/application_job.rb +6 -0
- data/app/mailers/loggable_activity/application_mailer.rb +8 -0
- data/app/models/loggable_activity/application_record.rb +7 -0
- data/app/views/kaminari/kaminari-turbo-bootstrap/_first_page.html.erb +14 -0
- data/app/views/kaminari/kaminari-turbo-bootstrap/_gap.html.erb +8 -0
- data/app/views/kaminari/kaminari-turbo-bootstrap/_last_page.html.erb +13 -0
- data/app/views/kaminari/kaminari-turbo-bootstrap/_next_page.html.erb +13 -0
- data/app/views/kaminari/kaminari-turbo-bootstrap/_page.html.erb +14 -0
- data/app/views/kaminari/kaminari-turbo-bootstrap/_paginator.html.erb +27 -0
- data/app/views/kaminari/kaminari-turbo-bootstrap/_prev_page.html.erb +14 -0
- data/app/views/layouts/loggable_activity/application.html.erb +19 -0
- data/app/views/loggable_activity/activities/_activities.html.erb +56 -0
- data/app/views/loggable_activity/activities/index.html.erb +7 -0
- data/app/views/loggable_activity/activities/show.html.erb +2 -0
- data/config/initializers/kaminari_config.rb +14 -0
- data/config/routes.rb +7 -0
- data/{lib/generators/loggable_activity/templates/create_loggable_activities.rb → db/migrate/20240702092648_create_loggable_activity_tables.rb} +18 -10
- data/git-org/HEAD +1 -0
- data/git-org/config +7 -0
- data/git-org/description +1 -0
- data/git-org/hooks/applypatch-msg.sample +15 -0
- data/git-org/hooks/commit-msg.sample +24 -0
- data/git-org/hooks/fsmonitor-watchman.sample +174 -0
- data/git-org/hooks/post-update.sample +8 -0
- data/git-org/hooks/pre-applypatch.sample +14 -0
- data/git-org/hooks/pre-commit.sample +49 -0
- data/git-org/hooks/pre-merge-commit.sample +13 -0
- data/git-org/hooks/pre-push.sample +53 -0
- data/git-org/hooks/pre-rebase.sample +169 -0
- data/git-org/hooks/pre-receive.sample +24 -0
- data/git-org/hooks/prepare-commit-msg.sample +42 -0
- data/git-org/hooks/push-to-checkout.sample +78 -0
- data/git-org/hooks/update.sample +128 -0
- data/git-org/info/exclude +6 -0
- data/lib/loggable_activity/activity.rb +3 -3
- data/lib/{schemas → loggable_activity}/config_schema.json +3 -3
- data/lib/loggable_activity/configuration.rb +51 -75
- data/lib/loggable_activity/data_owner.rb +0 -1
- data/lib/loggable_activity/encryption.rb +16 -7
- data/lib/loggable_activity/encryption_key.rb +4 -7
- data/lib/loggable_activity/engine.rb +27 -0
- data/lib/loggable_activity/error.rb +0 -10
- data/lib/loggable_activity/hooks.rb +10 -5
- data/lib/loggable_activity/payload.rb +8 -11
- data/lib/loggable_activity/sanitizer.rb +6 -2
- data/lib/loggable_activity/services/base_payloads_builder.rb +14 -5
- data/lib/loggable_activity/services/destroy_payloads_builder.rb +2 -1
- data/lib/loggable_activity/services/payloads_builder.rb +9 -2
- data/lib/loggable_activity/services/update_payloads_builder.rb +30 -2
- data/lib/loggable_activity/version.rb +1 -1
- data/lib/loggable_activity.rb +51 -14
- data/lib/tasks/loggable_activity_tasks.rake +6 -0
- metadata +129 -117
- data/.document +0 -1
- data/.nojekyll +0 -1
- data/.rspec +0 -3
- data/CONSIDERTIONS.md +0 -129
- data/GETTING-STARTED.md +0 -119
- data/LICENSE.txt +0 -21
- data/PAYLOAD_EXAMPLE.md +0 -63
- data/ROADMAP.md +0 -23
- data/docs/LoggableActivity/Activity.html +0 -555
- data/docs/LoggableActivity/Configuration.html +0 -330
- data/docs/LoggableActivity/ConfigurationError.html +0 -148
- data/docs/LoggableActivity/DataOwner.html +0 -138
- data/docs/LoggableActivity/Encryption.html +0 -234
- data/docs/LoggableActivity/EncryptionError.html +0 -145
- data/docs/LoggableActivity/EncryptionKey.html +0 -351
- data/docs/LoggableActivity/Error.html +0 -145
- data/docs/LoggableActivity/Hooks.html +0 -759
- data/docs/LoggableActivity/Payload.html +0 -432
- data/docs/LoggableActivity/Services/BasePayloadsBuilder.html +0 -442
- data/docs/LoggableActivity/Services/DestroyPayloadsBuilder.html +0 -395
- data/docs/LoggableActivity/Services/PayloadsBuilder.html +0 -342
- data/docs/LoggableActivity/Services/UpdatePayloadsBuilder.html +0 -490
- data/docs/LoggableActivity/Services.html +0 -93
- data/docs/LoggableActivity.html +0 -102
- data/docs/created.rid +0 -14
- data/docs/css/fonts.css +0 -167
- data/docs/css/rdoc.css +0 -687
- data/docs/fonts/Lato-Light.ttf +0 -0
- data/docs/fonts/Lato-LightItalic.ttf +0 -0
- data/docs/fonts/Lato-Regular.ttf +0 -0
- data/docs/fonts/Lato-RegularItalic.ttf +0 -0
- data/docs/fonts/SourceCodePro-Bold.ttf +0 -0
- data/docs/fonts/SourceCodePro-Regular.ttf +0 -0
- data/docs/images/add.png +0 -0
- data/docs/images/arrow_up.png +0 -0
- data/docs/images/brick.png +0 -0
- data/docs/images/brick_link.png +0 -0
- data/docs/images/bug.png +0 -0
- data/docs/images/bullet_black.png +0 -0
- data/docs/images/bullet_toggle_minus.png +0 -0
- data/docs/images/bullet_toggle_plus.png +0 -0
- data/docs/images/date.png +0 -0
- data/docs/images/delete.png +0 -0
- data/docs/images/find.png +0 -0
- data/docs/images/loadingAnimation.gif +0 -0
- data/docs/images/macFFBgHack.png +0 -0
- data/docs/images/package.png +0 -0
- data/docs/images/page_green.png +0 -0
- data/docs/images/page_white_text.png +0 -0
- data/docs/images/page_white_width.png +0 -0
- data/docs/images/plugin.png +0 -0
- data/docs/images/ruby.png +0 -0
- data/docs/images/tag_blue.png +0 -0
- data/docs/images/tag_green.png +0 -0
- data/docs/images/transparent.png +0 -0
- data/docs/images/wrench.png +0 -0
- data/docs/images/wrench_orange.png +0 -0
- data/docs/images/zoom.png +0 -0
- data/docs/index.html +0 -99
- data/docs/js/darkfish.js +0 -97
- data/docs/js/navigation.js +0 -105
- data/docs/js/navigation.js.gz +0 -0
- data/docs/js/search.js +0 -110
- data/docs/js/search_index.js +0 -1
- data/docs/js/search_index.js.gz +0 -0
- data/docs/js/searcher.js +0 -229
- data/docs/js/searcher.js.gz +0 -0
- data/docs/table_of_contents.html +0 -617
- data/help/loggable_activity_help.txt +0 -19
- data/lib/generators/.DS_Store +0 -0
- data/lib/generators/loggable_activity/.DS_Store +0 -0
- data/lib/generators/loggable_activity/install_generator.rb +0 -109
- data/lib/generators/loggable_activity/templates/.DS_Store +0 -0
- data/lib/generators/loggable_activity/templates/binary_ids/create_loggable_activities.rb +0 -30
- data/lib/generators/loggable_activity/templates/config/locales/loggable_activity.en.yml +0 -36
- data/lib/generators/loggable_activity/templates/config/loggable_activity.yaml +0 -29
- data/lib/generators/loggable_activity/templates/loggable_activity.en.yaml +0 -36
- data/pkg/loggable_activity-0.1.35.gem +0 -0
- data/sig/loggable_activity.rbs +0 -4
- /data/{.rspec_status → app/assets/images/loggable_activity/.keep} +0 -0
- /data/lib/{generators/loggable_activity/templates → loggable_activity/concerns}/current_user.rb +0 -0
@@ -1,109 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'rails/generators/active_record'
|
4
|
-
require 'rails/generators/named_base'
|
5
|
-
|
6
|
-
module LoggableActivity
|
7
|
-
module Generators
|
8
|
-
class InstallGenerator < Rails::Generators::Base
|
9
|
-
def self.banner
|
10
|
-
'rails generate loggable_activity:install [options]'
|
11
|
-
end
|
12
|
-
|
13
|
-
desc 'This generator configures LoggableActivity by creating migration files and initializing necessary configuration files.'
|
14
|
-
|
15
|
-
source_root File.expand_path('templates', __dir__)
|
16
|
-
class_option :uuid, type: :boolean, desc: 'use UUID for primary keys'
|
17
|
-
|
18
|
-
FILE_NAMES = %w[activity payload encryption_key data_owner].freeze
|
19
|
-
TIME = Time.now
|
20
|
-
|
21
|
-
def install
|
22
|
-
binary_ids = options['uuid'] ? true : false
|
23
|
-
time = Time.now.utc
|
24
|
-
timestamp = time.strftime('%Y%m%d%H%M%S')
|
25
|
-
migration_file_name = 'create_loggable_activities.rb'
|
26
|
-
destination = File.join('db', 'migrate', "#{timestamp}_#{migration_file_name}")
|
27
|
-
if binary_ids
|
28
|
-
template "binary_ids/#{migration_file_name}", destination
|
29
|
-
else
|
30
|
-
template migration_file_name, destination
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def create_translation_file
|
35
|
-
copy_file 'config/locales/loggable_activity.en.yml', 'config/locales/loggable_activity.en.yml'
|
36
|
-
end
|
37
|
-
|
38
|
-
def create_config_file
|
39
|
-
copy_file 'config/loggable_activity.yaml', 'config/loggable_activity.yaml'
|
40
|
-
end
|
41
|
-
|
42
|
-
def create_current_user_concern
|
43
|
-
copy_file 'current_user.rb', 'app/controllers/concerns/loggable_activity/current_user.rb'
|
44
|
-
end
|
45
|
-
|
46
|
-
def completion_message
|
47
|
-
message = <<~MESSAGE
|
48
|
-
------------------------------------------------
|
49
|
-
___ _ _ _ _#{' '}
|
50
|
-
|_ _| _ __ ___| |_ __ _| | __ _| |_(_) ___ _ __#{' '}
|
51
|
-
| | | '_ \\/ __| __/ _` | |/ _` | __| |/ _ \\| '_ \\#{' '}
|
52
|
-
| | | | | \\__ \\ || (_| | | (_| | |_| | (_) | | | |
|
53
|
-
|___| |_| |_|___/\\__\\__,_|_|\\__,_|\\__|_|\\___/|_| |_|
|
54
|
-
____ _ _ _#{' '}
|
55
|
-
/ ___| ___ _ __ ___ _ __ | | ___| |_ ___ __| |
|
56
|
-
| | / _ \\| '_ ` _ \\| '_ \\| |/ _ \\ __/ _ \\/ _` |
|
57
|
-
| |___ | (_) | | | | | | |_) | | __/ || __/ (_| |
|
58
|
-
\\____| \\___/|_| |_| |_| .__/|_|\\___|\\__\\___|\\__,_|
|
59
|
-
|_|#{' '}
|
60
|
-
|
61
|
-
LoggableActivity installation completed successfully!
|
62
|
-
|
63
|
-
Quick Start:
|
64
|
-
|
65
|
-
1. include hooks to the model we want to log.
|
66
|
-
class MY_MODEL < ApplicationRecord
|
67
|
-
include LoggableActivity::Hooks
|
68
|
-
|
69
|
-
2. Update `config/application.rb
|
70
|
-
config.loggable_activity = ActiveSupport::OrderedOptions.new
|
71
|
-
::LoggableActivity::Configuration.load_config_file('config/loggable_activity.yaml')
|
72
|
-
|
73
|
-
3. Include current_user ApplicationController
|
74
|
-
class ApplicationController < ActionController::Base
|
75
|
-
include LoggableActivity::CurrentUser
|
76
|
-
|
77
|
-
4. Update the 'config/loggable_activity.yaml' file with the necessary configuration.
|
78
|
-
|
79
|
-
5. Run the migration to create the necessary tables.
|
80
|
-
|
81
|
-
|
82
|
-
For more information, please visit:
|
83
|
-
https://github.com/maxgronlund/LoggableActivity/blob/main/GETTING-STARTED.md
|
84
|
-
|
85
|
-
------------------------------------------------
|
86
|
-
MESSAGE
|
87
|
-
|
88
|
-
puts message
|
89
|
-
end
|
90
|
-
|
91
|
-
private
|
92
|
-
|
93
|
-
def create_migration_files
|
94
|
-
binary_ids = options['uuid'] ? true : false
|
95
|
-
time = Time.now.utc
|
96
|
-
timestamp = time.strftime('%Y%m%d%H%M%S')
|
97
|
-
migration_file_name = 'create_loggable_activities.rb'
|
98
|
-
destination = File.join('db', 'migrate', "#{timestamp}_#{migration_file_name}")
|
99
|
-
if binary_ids
|
100
|
-
# Copy binary_id migration file
|
101
|
-
template "binary_ids/#{migration_file_name}", destination
|
102
|
-
else
|
103
|
-
# Copy integer migration file
|
104
|
-
template migration_file_name, destination
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
Binary file
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class CreateLoggableActivities < ActiveRecord::Migration[7.1]
|
4
|
-
def change
|
5
|
-
create_table :loggable_activities, id: :uuid, default: 'gen_random_uuid()' do |t|
|
6
|
-
t.string :action
|
7
|
-
t.references :actor, polymorphic: true, null: true, type: :uuid
|
8
|
-
t.string :actor_display_name
|
9
|
-
t.string :record_display_name
|
10
|
-
t.references :record, polymorphic: true, null: true, type: :uuid
|
11
|
-
|
12
|
-
t.timestamps
|
13
|
-
end
|
14
|
-
|
15
|
-
create_table :loggable_payloads, id: :uuid, default: 'gen_random_uuid()' do |t|
|
16
|
-
t.references :activity, foreign_key: { to_table: 'loggable_activities', class_name: '::LoggableActivity::Activity' }, type: :uuid
|
17
|
-
t.references :encryption_key, null: false, foreign_key: { to_table: 'loggable_encryption_keys', class_name: '::LoggableActivity::EncryptionKey' }, type: :uuid
|
18
|
-
t.references :record, polymorphic: true, null: true, type: :uuid
|
19
|
-
t.json :encrypted_attrs
|
20
|
-
t.integer :related_to_activity_as, default: 0
|
21
|
-
t.string :route
|
22
|
-
end
|
23
|
-
|
24
|
-
create_table :loggable_encryption_keys, id: :uuid, default: 'gen_random_uuid()' do |t|
|
25
|
-
t.string :secret_key
|
26
|
-
# t.references :parent_key, foreign_key: { to_table: 'loggable_encryption_keys', type: :uuid }
|
27
|
-
# t.references :record, polymorphic: true, type: :uuid
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
en:
|
2
|
-
loggable:
|
3
|
-
activity:
|
4
|
-
deleted: "***** DELETED *****"
|
5
|
-
demo/address:
|
6
|
-
update: An address was updated
|
7
|
-
create: An address was created
|
8
|
-
show: An address was shown
|
9
|
-
destroy: An address was deleted
|
10
|
-
demo/club:
|
11
|
-
update: A club was updated
|
12
|
-
create: A club was created
|
13
|
-
show: A club was shown
|
14
|
-
destroy: A club was deleted
|
15
|
-
demo/journal:
|
16
|
-
update: A journal was updated
|
17
|
-
create: A journal was created
|
18
|
-
show: A journal was shown
|
19
|
-
destroy: A journal was deleted
|
20
|
-
demo/product:
|
21
|
-
update: A product was updated
|
22
|
-
create: A product was created
|
23
|
-
show: A product was shown
|
24
|
-
destroy: A product was deleted
|
25
|
-
user:
|
26
|
-
update: A user was updated
|
27
|
-
create: A user was created
|
28
|
-
show: "A user was shown"
|
29
|
-
destroy: A user was deleted
|
30
|
-
models:
|
31
|
-
Demo::Address: Address
|
32
|
-
Demo::UserProfile: Profile
|
33
|
-
Demo::Club: Club
|
34
|
-
Demo::Journal: Journal
|
35
|
-
Demo/Product: Product
|
36
|
-
User: User
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# User:
|
2
|
-
# record_display_name: full_name
|
3
|
-
# loggable_attrs:
|
4
|
-
# - first_name
|
5
|
-
# - last_name
|
6
|
-
# - age
|
7
|
-
# - email
|
8
|
-
# - user_type
|
9
|
-
# auto_log:
|
10
|
-
# - create
|
11
|
-
# - update
|
12
|
-
# - destroy
|
13
|
-
# relations:
|
14
|
-
# - has_one: :demo_user_profile
|
15
|
-
# model: Demo::UserProfile
|
16
|
-
# loggable_attrs:
|
17
|
-
# - sex
|
18
|
-
# - religion
|
19
|
-
# - belongs_to: :demo_address
|
20
|
-
# model: Demo::Address
|
21
|
-
# loggable_attrs:
|
22
|
-
# - street
|
23
|
-
# - city
|
24
|
-
# - country
|
25
|
-
# - postal_code
|
26
|
-
# - belongs_to: :demo_club
|
27
|
-
# model: Demo::Club
|
28
|
-
# loggable_attrs:
|
29
|
-
# - name
|
@@ -1,36 +0,0 @@
|
|
1
|
-
en:
|
2
|
-
loggable:
|
3
|
-
activity:
|
4
|
-
deleted: "***** DELETED *****"
|
5
|
-
demo/address:
|
6
|
-
update: An address was updated
|
7
|
-
create: An address was created
|
8
|
-
show: An address was shown
|
9
|
-
destroy: An address was deleted
|
10
|
-
demo/club:
|
11
|
-
update: A club was updated
|
12
|
-
create: A club was created
|
13
|
-
show: A club was shown
|
14
|
-
destroy: A club was deleted
|
15
|
-
demo/journal:
|
16
|
-
update: A journal was updated
|
17
|
-
create: A journal was created
|
18
|
-
show: A journal was shown
|
19
|
-
destroy: A journal was deleted
|
20
|
-
demo/product:
|
21
|
-
update: A product was updated
|
22
|
-
create: A product was created
|
23
|
-
show: A product was shown
|
24
|
-
destroy: A product was deleted
|
25
|
-
user:
|
26
|
-
update: A user was updated
|
27
|
-
create: A user was created
|
28
|
-
show: "A user was shown"
|
29
|
-
destroy: A user was deleted
|
30
|
-
models:
|
31
|
-
Demo::Address: Address
|
32
|
-
Demo::UserProfile: Profile
|
33
|
-
Demo::Club: Club
|
34
|
-
Demo::Journal: Journal
|
35
|
-
Demo/Product: Product
|
36
|
-
User: User
|
Binary file
|
data/sig/loggable_activity.rbs
DELETED
File without changes
|
/data/lib/{generators/loggable_activity/templates → loggable_activity/concerns}/current_user.rb
RENAMED
File without changes
|