rails_log_book 2.2.0 → 2.3.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: 6dd4aeafea7a8338a28acc53502390c4e754b1ee89f9de73dcedfd7819e63225
4
- data.tar.gz: 661135f7039e5d6da50b4a92f8d3362e505ba94a2cffac7599ed759b6cdcb884
3
+ metadata.gz: 40ac50af4671708098c57282c0a2bfd6af146bc41a2511fdb712669b30642e8d
4
+ data.tar.gz: 8fa4ae7b220b1c52146e011f999e95e5b8a781dbf45e6db6aaa785503a8eadda
5
5
  SHA512:
6
- metadata.gz: 5839ee045701d910400217703c2a826ce37248eda39b3056ffa765e824fbba9db9307dc1e17417a116e7243ac1ea032b30116601d131cc82814bf36f067e539e
7
- data.tar.gz: a50ff77ca42c86c0e5359c63b4f376e0c59ecdae872ebb789034613a2aa8348a9a4e362a36ed38e82a2d10f0d6767b0cae781f1a19f1aa20ad7d617c4dbbcd47
6
+ metadata.gz: '09543149f1dc7cf81a78e1450f0840bdfce3e796c0c68f467d66e9e845251d97ad43c58766ff900717da6329e37a3faff8c50322e05b0be73d68e0c8353bd3f6'
7
+ data.tar.gz: 8f2620cd3a9ed80bac438d85d000201fd9aa911f36e0fc0a0bb182f4380e408865ea22f4c7f2f55c8d601868b00ea097317beb0424a7957e8975da64f6f019dc
data/README.md CHANGED
@@ -235,11 +235,10 @@ Defines what method is run when looking for the author for recording
235
235
  ``` ruby
236
236
  # config/initializers/log_book.rb
237
237
  LogBook.configure do |config|
238
- config.records_table_name = 'records'
239
238
  config.ignored_attributes = [:updated_at, :created_at]
240
239
  config.author_method = :current_user
241
240
  config.record_squashing = false
242
- config.recording_enabled = false
241
+ config.always_record = false
243
242
  config.skip_if_empty_actions = [:update]
244
243
  end
245
244
  ```
@@ -248,7 +247,7 @@ end
248
247
 
249
248
  ``` ruby
250
249
  LogBook.with_recording {} #=> Enables recording within block
251
- LogBook.author=(author ) #=> Records as a different author within block
250
+ LogBook.author=(author) #=> Records as a different author within block
252
251
  LogBook.action=(value) #=> Change default action for this request
253
252
  LogBook.with_record_squashing {} #=> Squashes records within block
254
253
  LogBook.enable_recording #=> Enables recording from this point
@@ -2,7 +2,7 @@ LogBook.configure do |config|
2
2
  # config.records_table_name = 'records'
3
3
  # config.ignored_attributes = [:updated_at, :created_at]
4
4
  # config.author_method = :current_user
5
- # config.recording_enabled = false
5
+ # config.always_record = false
6
6
  # config.record_squashing = true
7
7
  # config.skip_if_empty_actions = [:update]
8
8
  end
@@ -3,7 +3,7 @@ module LogBook
3
3
 
4
4
  setting :records_table_name, 'records'
5
5
  setting :ignored_attributes, [:updated_at, :created_at]
6
- setting :recording_enabled, false
6
+ setting :always_record, false
7
7
  setting :author_method, :current_user
8
8
  setting :record_squashing, false
9
9
  setting :skip_if_empty_actions, [:update]
@@ -4,5 +4,13 @@ module LogBook
4
4
  spec = Gem::Specification.find_by_name 'rails_log_book'
5
5
  load "#{spec.gem_dir}/lib/tasks/log_book.rake"
6
6
  end
7
+
8
+ config.after_initialize do
9
+ next unless LogBook.config.always_record
10
+
11
+ at_exit do
12
+ LogBook::SaveRecords.call
13
+ end
14
+ end
7
15
  end
8
16
  end
@@ -11,7 +11,8 @@ module LogBook
11
11
  end
12
12
 
13
13
  def add(record)
14
- node = nodes[record.recording_key] ||= Node.new(record)
14
+ node = nodes[record.recording_key]
15
+ node = node ? node.merge(record) : nodes[record.recording_key] = Node.new(record)
15
16
  add_parent(node, record.parent)
16
17
  add_children(node, record.children)
17
18
  end
@@ -69,6 +70,11 @@ module LogBook
69
70
  @depth = 0
70
71
  @children = []
71
72
  end
73
+
74
+ def merge(new_value)
75
+ value.record_changes = new_value.record_changes
76
+ self
77
+ end
72
78
  end
73
79
  end
74
80
  end
@@ -1,3 +1,3 @@
1
1
  module LogBook
2
- VERSION = '2.2.0'
2
+ VERSION = '2.3.0'
3
3
  end
@@ -27,7 +27,7 @@ module LogBook
27
27
  end
28
28
 
29
29
  def recording_enabled
30
- LogBook::Store.recording_enabled || LogBook.config.recording_enabled
30
+ LogBook::Store.recording_enabled || LogBook.config.always_record
31
31
  end
32
32
 
33
33
  def record_squashing_enabled
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_log_book
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stjepan Hadjic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-29 00:00:00.000000000 Z
11
+ date: 2019-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler