paper_trail-rails 0.6.0 → 0.6.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6aa5868c6142fc4fe53860a3d2419e4f8f564ecc6f885b35a2c2378b414c39ca
4
- data.tar.gz: b6ea9745e16cbb603de44aaae7a8f25fd75c3953d7c8a5bb55467dd6d3434008
3
+ metadata.gz: 9cbd2f0eda94258a20e3a294ed155191773c27af3d91bcbd66c63971084e37e8
4
+ data.tar.gz: d59ed0df5959182a653556c3583e963ef9df5d2669821f15b4ae06c2deade834
5
5
  SHA512:
6
- metadata.gz: 6eb0038d9fb7de316971d81955f430fc24c43146f176dc491d6641b5346b4102e2d2ed5150cf85cdcea7a9239485052129f519ffefc5df92e5609a3e779ec5e4
7
- data.tar.gz: 9202e8d1e38fe06436a59f0ce2051867517297ed9b91f71aba5b640b74e8214ca18e068e1345e070bffeb908bc5f8e94747981f7aacf80e40408efa47c49382e
6
+ metadata.gz: fd93b66499033e9b62bb521bd0870f81fa4a4c4fbe3f4916a5359dbd5fa04279ce5a2ec8396e474062588f70db1170f0e8810293145914dd2f25539451ef298a
7
+ data.tar.gz: 2b5bd83ee674694032247fec1212dd4ce2a3f49cddaa1ce1380235e4ed3300d3eb0af7ce126942d7beee48c1213e7faf411aff4017565afce8b039206ec1af1d
data/Changelog.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.6.1 (2023-06-15)
2
+ - Add `PaperTrail.metadata`, `PaperTrail.reverse_update_metadata`
3
+ - Change `set_default_metadata` to only set `command` to `default_command` if it hasn't been set yet. This
4
+ fixes bug where the command set by `RunnerCommandExtensions` got overwritten when the `whodunnit`
5
+ callback called `set_default_metadata` again.
6
+
1
7
  ## 0.6.0 (2023-06-14)
2
8
  - Include the rails subcommand (`'rails console'`, etc.) in the `command` metadata, not just `'rails'`
3
9
  - When using `rails runner`, include the full Ruby code/file that was run in the `command` metadata.
@@ -1,5 +1,11 @@
1
1
  PaperTrail.class_eval do
2
2
 
3
+ unless methods.include?(:metadata)
4
+ def self.metadata
5
+ PaperTrail.request.controller_info
6
+ end
7
+ end
8
+
3
9
  unless methods.include?(:with_metadata)
4
10
  # Adds additional metadata to versions created within the given block. This will be merged with
5
11
  # (and may override) any metadata already set by your controller's info_for_paper_trail.
@@ -27,4 +33,11 @@ PaperTrail.class_eval do
27
33
  PaperTrail.request.controller_info = merged_metadata
28
34
  end
29
35
  end
36
+
37
+ unless methods.include?(:reverse_update_metadata)
38
+ def self.reverse_update_metadata(metadata)
39
+ merged_metadata = (::PaperTrail.request.controller_info || {}).reverse_merge(metadata)
40
+ PaperTrail.request.controller_info = merged_metadata
41
+ end
42
+ end
30
43
  end
@@ -1,7 +1,7 @@
1
1
  module PaperTrail
2
2
  module Rails
3
3
  def self.version
4
- "0.6.0"
4
+ "0.6.1"
5
5
  end
6
6
  end
7
7
  end
@@ -30,8 +30,10 @@ module PaperTrail
30
30
 
31
31
  # Store some metadata about where the change came from
32
32
  def set_default_metadata
33
- PaperTrail.update_metadata(
33
+ PaperTrail.reverse_update_metadata(
34
34
  command: default_command,
35
+ )
36
+ PaperTrail.update_metadata(
35
37
  source_location: caller.find { |line|
36
38
  line.starts_with? ::Rails.root.to_s and
37
39
  config.source_location_filter.(line)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paper_trail-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Rick