trackstamps-reborn 0.0.5 → 0.1.0

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: 47b8037687df6e16b2ca5d66a07c2d3da27c7146c36718356c62ad428458de8e
4
- data.tar.gz: 7261748050c07bc01c95cdc57811781b4e6a05292c14145771a5b1052258e37d
3
+ metadata.gz: e2913a46aba0967d1226ed02f93e86d219c93b97ae295e1754c208dbefb90b1d
4
+ data.tar.gz: 2af412096b4d54fa9ea08557c0d560d508763b11a468216bd5beb25b65c53ef8
5
5
  SHA512:
6
- metadata.gz: edc4eb2e953309e523126fbeae51c27034e1910ce9c0e328e5d6ab79cd42b326e2744ba263e49fb0281de5d13eb23231a04504b5f264e43b12861b354c90def4
7
- data.tar.gz: 91c1210eebecb2174ebdf864a914217b845675f2702242be116d58306c5d14709d6110281c96eb1fa1ebe4198a81944e14bcdefa812f1c2f02c7565e2e92f830
6
+ metadata.gz: 7fbbe08e654b28afcc671f76ed61f4d52f16fc0a757770027e7e9939d489f73a5fb4810baf38b74f10f4033ff6ea0c008ac594f1ba0980b5f849966389882413
7
+ data.tar.gz: 2f029a844e3ad1a92efd6c97e4c49dd6d2c94d9e990fffe7638c7a07ed239c2aaec32311e6840e387184fcdd27c6225c489bea3ea00527640d7ebab20abb5179
data/README.md CHANGED
@@ -1,8 +1,7 @@
1
1
  # trackstamps-reborn
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/trackstamps-reborn.svg)](https://rubygems.org/gems/trackstamps-reborn)
4
- [![Circle](https://circleci.com/gh/uvera/trackstamps-reborn/tree/main.svg?style=shield)](https://app.circleci.com/pipelines/github/uvera/trackstamps-reborn?branch=main)
5
- [![Code Climate](https://codeclimate.com/github/uvera/trackstamps-reborn/badges/gpa.svg)](https://codeclimate.com/github/uvera/trackstamps-reborn)
4
+ [![Test](https://github.com/uvera/trackstamps-reborn/actions/workflows/test.yml/badge.svg)](https://github.com/uvera/trackstamps-reborn/actions/workflows/test.yml)
6
5
 
7
6
  Track which user created or updated record in Rails.
8
7
 
@@ -1,6 +1,6 @@
1
1
  module Trackstamps
2
2
  module Reborn
3
- class Current < ActiveSupport::CurrentAttributes
3
+ class Current < ::ActiveSupport::CurrentAttributes
4
4
  attribute :user
5
5
  end
6
6
  end
@@ -1,5 +1,5 @@
1
1
  module Trackstamps
2
2
  module Reborn
3
- VERSION = "0.0.5".freeze
3
+ VERSION = "0.1.0".freeze
4
4
  end
5
5
  end
@@ -1,7 +1,6 @@
1
- require 'trackstamps/reborn/current'
2
- require 'active_support/current_attributes'
3
- require 'active_support/concern'
4
- require 'dry-configurable'
1
+ require "active_support"
2
+ require "trackstamps/reborn/current"
3
+ require "dry-configurable"
5
4
 
6
5
  module Trackstamps
7
6
  module Reborn
@@ -11,9 +10,9 @@ module Trackstamps
11
10
 
12
11
  setting :get_current_user, default: -> { Trackstamps::Reborn::Current.user }
13
12
 
14
- setting :user_class_name, default: 'User'.freeze
15
- setting :updater_foreign_key, default: 'updated_by_id'.freeze
16
- setting :creator_foreign_key, default: 'created_by_id'.freeze
13
+ setting :user_class_name, default: "User".freeze
14
+ setting :updater_foreign_key, default: "updated_by_id".freeze
15
+ setting :creator_foreign_key, default: "created_by_id".freeze
17
16
 
18
17
  def trackstamps_current_user
19
18
  Trackstamps::Reborn.config.get_current_user.call
@@ -23,25 +22,39 @@ module Trackstamps
23
22
  before_save :trackstamps_set_updater
24
23
  before_create :trackstamps_set_creator
25
24
 
25
+ const_set(:UPDATER_FOREIGN_KEY, Trackstamps::Reborn.config.updater_foreign_key.dup.freeze)
26
+
27
+ private_constant :UPDATER_FOREIGN_KEY
28
+
26
29
  belongs_to :updater,
27
30
  class_name: Trackstamps::Reborn.config.user_class_name,
28
- foreign_key: Trackstamps::Reborn.config.updater_foreign_key,
31
+ foreign_key: const_get(:UPDATER_FOREIGN_KEY),
29
32
  optional: true
33
+
34
+ const_set(:CREATOR_FOREIGN_KEY, Trackstamps::Reborn.config.creator_foreign_key.dup.freeze)
35
+ private_constant :CREATOR_FOREIGN_KEY
36
+
30
37
  belongs_to :creator,
31
38
  class_name: Trackstamps::Reborn.config.user_class_name,
32
- foreign_key: Trackstamps::Reborn.config.creator_foreign_key,
39
+ foreign_key: const_get(:CREATOR_FOREIGN_KEY),
33
40
  optional: true
34
41
 
35
42
  def trackstamps_set_updater
36
43
  return unless trackstamps_current_user
37
44
 
38
- send("#{Trackstamps::Reborn.config.updater_foreign_key}=", trackstamps_current_user.id)
45
+ send("#{self.class.const_get(:UPDATER_FOREIGN_KEY)}=", trackstamps_current_user.id)
39
46
  end
40
47
 
41
48
  def trackstamps_set_creator
42
49
  return unless trackstamps_current_user
43
50
 
44
- send("#{Trackstamps::Reborn.config.creator_foreign_key}=", trackstamps_current_user.id)
51
+ send("#{self.class.const_get(:CREATOR_FOREIGN_KEY)}=", trackstamps_current_user.id)
52
+ end
53
+ end
54
+
55
+ class_methods do
56
+ def with_trackstamps
57
+ includes(:creator, :updater)
45
58
  end
46
59
  end
47
60
  end
metadata CHANGED
@@ -1,49 +1,49 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trackstamps-reborn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dušan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-20 00:00:00.000000000 Z
11
+ date: 2023-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rails
14
+ name: dry-configurable
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '5.2'
20
- - - "<"
17
+ - - "~>"
21
18
  - !ruby/object:Gem::Version
22
- version: '8'
19
+ version: '1.0'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: '5.2'
30
- - - "<"
24
+ - - "~>"
31
25
  - !ruby/object:Gem::Version
32
- version: '8'
26
+ version: '1.0'
33
27
  - !ruby/object:Gem::Dependency
34
- name: dry-configurable
28
+ name: rails
35
29
  requirement: !ruby/object:Gem::Requirement
36
30
  requirements:
37
31
  - - ">="
38
32
  - !ruby/object:Gem::Version
39
- version: '0'
33
+ version: '5.2'
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '8'
40
37
  type: :runtime
41
38
  prerelease: false
42
39
  version_requirements: !ruby/object:Gem::Requirement
43
40
  requirements:
44
41
  - - ">="
45
42
  - !ruby/object:Gem::Version
46
- version: '0'
43
+ version: '5.2'
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '8'
47
47
  description:
48
48
  email:
49
49
  - dusan.uveric@mitigate.dev
@@ -82,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
84
  requirements: []
85
- rubygems_version: 3.3.23
85
+ rubygems_version: 3.3.25
86
86
  signing_key:
87
87
  specification_version: 4
88
88
  summary: ''