prosopite 1.0.9 → 1.1.1

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: dc0695c895e2f636c3c2a2caa2c4b211cad0f7d57f8bd4842fbc534ba9e55190
4
- data.tar.gz: 2dcd4426e5b792a58cee89ec601e3388bacc97cb0de57aa3b87dd7600dd6b020
3
+ metadata.gz: 5e7209ed5070fd604f22b0e2a6c0256cf3e30bdc9492403f9c427edef00e5a3c
4
+ data.tar.gz: 75bd921fee0f39354db2fd7a4136f4c32387bd7b2373b5fc34028340105de9e8
5
5
  SHA512:
6
- metadata.gz: b2c1c6a4723c44c24ab800fede6c14d49f74ba1c97c4aa60c59a231725e001ca45416abb878331157402582114e144931e39774a9af51fb422d12ba4f668403b
7
- data.tar.gz: 2175b7c1bd661c5bca41c1263e9a750d63b205e548ef1d2f13ca2aac43c6306eaad3e3bb8420e627ab2576821565311c525e6b51576b4e30431c41420b3b7f0b
6
+ metadata.gz: 2c393693a5477df4f7e1615c7d67c71cf77b060deb62a8b47e771604b5af5f2a52bcea1639c345173f50d1d11decc263522565cab89a64bea4974a08c6770d8e
7
+ data.tar.gz: 7eaece0588d418afb0fecc543b697ca3261567d1bed34e549b826800c2861f7be854999accac0b46e96a7bf7a24b00ea5e6485218b566456bfe76bfb7b3b20c6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- prosopite (1.0.9)
4
+ prosopite (1.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -225,11 +225,19 @@ Prosopite.scan
225
225
  Prosopite.finish
226
226
  ```
227
227
 
228
- or
228
+ In block form the `Prosopite.finish` is called automatically for you at the end of the block:
229
229
 
230
230
  ```ruby
231
231
  Prosopite.scan do
232
- <code to scan>
232
+ <code to scan>
233
+ end
234
+ ```
235
+
236
+ The result of the code block is also returned by `Prosopite.scan`, so you can wrap calls as follows:
237
+
238
+ ```ruby
239
+ my_object = Prosopite.scan do
240
+ MyObjectFactory.create(params)
233
241
  end
234
242
  ```
235
243
 
@@ -247,6 +255,20 @@ Prosopite.resume
247
255
  Prosopite.finish
248
256
  ```
249
257
 
258
+ You can also pause items in a block, and the `Prosopite.resume` will be done
259
+ for you automatically:
260
+
261
+ ```ruby
262
+ Prosopite.scan
263
+ # <code to scan>
264
+
265
+ result = Prosopite.pause do
266
+ # <code that has n+1s>
267
+ end
268
+
269
+ Prosopite.finish
270
+ ```
271
+
250
272
  An example of when you might use this is if you are [testing Active Jobs inline](https://guides.rubyonrails.org/testing.html#testing-jobs),
251
273
  and don't want to run Prosopite on background job code, just foreground app code. In that case you could write an [Active Job callback](https://edgeguides.rubyonrails.org/active_job_basics.html#callbacks) that pauses the scan while the job is running.
252
274
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Prosopite
4
- VERSION = "1.0.9"
4
+ VERSION = "1.1.1"
5
5
  end
data/lib/prosopite.rb CHANGED
@@ -34,8 +34,9 @@ module Prosopite
34
34
 
35
35
  if block_given?
36
36
  begin
37
- yield
37
+ block_result = yield
38
38
  finish
39
+ block_result
39
40
  ensure
40
41
  tc[:prosopite_scan] = false
41
42
  end
@@ -48,6 +49,14 @@ module Prosopite
48
49
 
49
50
  def pause
50
51
  tc[:prosopite_scan] = false
52
+
53
+ if block_given?
54
+ begin
55
+ yield
56
+ ensure
57
+ tc[:prosopite_scan] = true
58
+ end
59
+ end
51
60
  end
52
61
 
53
62
  def resume
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prosopite
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.9
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mpampis Kostas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-16 00:00:00.000000000 Z
11
+ date: 2022-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry