logisticed 0.1.0 → 1.0.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/Gemfile.lock +2 -2
- data/README.md +22 -22
- data/lib/logisticed/logistic.rb +6 -1
- data/lib/logisticed/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 169a9a12d30c45dbe38f4afa074a1a7d62cfd5f3c3116b7826fb83e83b5c1c5c
|
4
|
+
data.tar.gz: 5e16c9708ba8580c4b6864051b598d61dfb42eccd46c5b23f047b5fdc8ace0ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fcfdde7d954008ea410ccc98040c9fa83ab58f1cdd4ead30a4e727c48896788727bf47d30bcf2d87c80150a187f656dd85f8d1684d345f0c90d2b58064377f19
|
7
|
+
data.tar.gz: 1bf730d7ccd5c58e753096717cd69b54f449b2975c0014a5d37c9b5776188929eff9bd5a4a86a5cbfcbdc8087fca35674d07c70835317136da483994676b7673
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -30,20 +30,20 @@ end
|
|
30
30
|
```ruby
|
31
31
|
class Page < ActiveRecord::Base
|
32
32
|
enum status: [:draft, :active, :archived]
|
33
|
-
|
33
|
+
logisticed :status, only: [:active, :archived]
|
34
34
|
end
|
35
35
|
```
|
36
36
|
|
37
37
|
现在就已经可以监听所有的操作人和操作时间等信息了
|
38
38
|
```ruby
|
39
39
|
class PagesController < ApplicationController
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
40
|
+
def create
|
41
|
+
current_user # => #<User name: 'sss'>
|
42
|
+
@page = Page.first # => #<Page status: 'draft'>
|
43
|
+
@page.active!
|
44
|
+
@page.active_at # => 2021-01-22 17:15:13 +0800
|
45
|
+
@page.active_by # => #<User name: 'sss'>
|
46
|
+
end
|
47
47
|
end
|
48
48
|
```
|
49
49
|
|
@@ -53,16 +53,16 @@ end
|
|
53
53
|
|
54
54
|
```ruby
|
55
55
|
class PagesController < ApplicationController
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
56
|
+
def create
|
57
|
+
current_user # => #<User name: 'sss'>
|
58
|
+
user = User.last # => #<User name: 'smx'>
|
59
|
+
Logisticed::Logistic.as_user(user) do
|
60
|
+
@page = Page.first # => #<Page status: 'draft'>
|
61
|
+
@page.active!
|
62
|
+
@page.active_at # => 2021-01-22 17:15:13 +0800
|
63
|
+
@page.active_by # => #<User name: 'smx'>
|
64
|
+
end
|
65
|
+
end
|
66
66
|
end
|
67
67
|
```
|
68
68
|
# setting
|
@@ -71,9 +71,9 @@ end
|
|
71
71
|
# config/initializers/logisticed.rb
|
72
72
|
|
73
73
|
Logisticed.config do |config|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
74
|
+
config.current_user_method = :authenticated_user
|
75
|
+
# if your table primary_key type is uuid
|
76
|
+
config.logisticed_source_id_column_type = :uuid
|
77
|
+
config.logisticed_operator_id_column_type = :uuid
|
78
78
|
end
|
79
79
|
```
|
data/lib/logisticed/logistic.rb
CHANGED
@@ -2,7 +2,7 @@ module Logisticed
|
|
2
2
|
class Logistic < ::ActiveRecord::Base
|
3
3
|
belongs_to :source, polymorphic: true
|
4
4
|
belongs_to :operator, polymorphic: true
|
5
|
-
before_create :set_logistic_user
|
5
|
+
before_create :set_logistic_user, :set_request_info
|
6
6
|
|
7
7
|
def self.as_user(user)
|
8
8
|
last_logisticed_user = ::Logisticed.store[:logisticed_user]
|
@@ -19,5 +19,10 @@ module Logisticed
|
|
19
19
|
self.operator ||= ::Logisticed.store[:current_user].try!(:call) # from Sweeper
|
20
20
|
nil # prevent stopping callback chains
|
21
21
|
end
|
22
|
+
|
23
|
+
def set_request_info
|
24
|
+
self.remote_ip = ::Logisticed.store[:current_remote_address]
|
25
|
+
self.request_uuid = ::Logisticed.store[:current_request_uuid]
|
26
|
+
end
|
22
27
|
end
|
23
28
|
end
|
data/lib/logisticed/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logisticed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sumingxuan
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: 轻松的管理你的业务变更的操作人和操作时间
|
14
14
|
email:
|
@@ -36,7 +36,7 @@ homepage: https://github.com/SuMingXuan/logisticed
|
|
36
36
|
licenses: []
|
37
37
|
metadata:
|
38
38
|
homepage_uri: https://github.com/SuMingXuan/logisticed
|
39
|
-
post_install_message:
|
39
|
+
post_install_message:
|
40
40
|
rdoc_options: []
|
41
41
|
require_paths:
|
42
42
|
- lib
|
@@ -51,8 +51,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: '0'
|
53
53
|
requirements: []
|
54
|
-
rubygems_version: 3.
|
55
|
-
signing_key:
|
54
|
+
rubygems_version: 3.2.22
|
55
|
+
signing_key:
|
56
56
|
specification_version: 4
|
57
57
|
summary: simple manage business change datas
|
58
58
|
test_files: []
|