type_fusion 0.0.5 → 0.0.6

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: ba90818fd8e50f24a1b0049c0a8076a22b2e168a0fcafff53fb425b858b6323a
4
- data.tar.gz: '011790f72f4d7e17fe12a8a1443f71e4bbdc42d4308f02c8110d5b07a3e91825'
3
+ metadata.gz: b9c5749c381eccd5f84c5d824fce4d634cde7bda503638dfef9c9737b61c7cb0
4
+ data.tar.gz: 6fc4cb00bf6ddb01f0832962df93add41020668d2de5ca3933c3619039bbda96
5
5
  SHA512:
6
- metadata.gz: 23e4e3de6448d1f0f1a982ed90d73fec09b74d10b89e037bb6c477c24c8576bb42087a3dc112b612e41f81029e364472ebe498fd83258dc7da4f368c44866a26
7
- data.tar.gz: 933b4a204122078dcc8a939daa35aae1648cb73ca06ec08231aa982be790adabc8075725ac715782873c84e8c657a3b6f12db9759b1fe32008dbde3557f70148
6
+ metadata.gz: 1b1c116b16c6f56234a1718af703c0c8e64527230e9cb74f4efae26727a467e30ac63b233f0f075f8494b1fc40096d3bf113b03bd0ab409f3088e7332c09a04f
7
+ data.tar.gz: a687bce21925739f806d3cb458a08e301723db19d755dcc04f3de47098fbe4236ccb30a84fa6e2845be6553cad92f1a1145464fe16483a0416ed0650cf8a969a
data/CHANGELOG.md CHANGED
@@ -1,4 +1,11 @@
1
- ## [Unreleased]
1
+ ## [0.0.6] - 2023-08-25
2
+
3
+ - Add support for running TypeFusion in the test environment with RSpec
4
+ - Update Struct syntax for Ruby 3.2/3.1 compatibility
5
+ - Show how many threads are processing samples
6
+ - Rename `TypeFusion::Processor#enqueued_samples` to `#enqueued_jobs`
7
+ - Move `TypeFusion::Processor` signal trap to `#process!` so it doesn't interfere with the Rails server
8
+ - Keep track of started state of `TypeFusion::Processor` so we only need to start the processing once
2
9
 
3
10
  ## [0.0.5] - 2023-08-25
4
11
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- type_fusion (0.0.5)
4
+ type_fusion (0.0.6)
5
5
  lhc (~> 15.2)
6
6
  litejob (~> 0.2.3)
7
7
 
data/README.md CHANGED
@@ -14,22 +14,13 @@ If bundler is not being used to manage dependencies, install the gem by executin
14
14
  gem install type_fusion
15
15
  ```
16
16
 
17
- #### Rack
18
-
19
- ```ruby
20
- require "type_fusion/rack/middleware"
21
-
22
- use TypeFusion::Middleware
23
- ```
24
-
25
- #### Rails
26
-
27
- Adding the gem to your applications Gemfile will automatically setup `type_fusion`.
17
+ ### Running TypeFusion in the `test` environment
28
18
 
19
+ Setup TypeFusion if you only want to run TypeFusion as part of your test suite.
29
20
 
30
21
  #### Minitest
31
22
 
32
- If you only want to run TypeFusion in your test environment you can require `type_fusion/minitest` in your `test_helper.rb`:
23
+ You can require `type_fusion/minitest` in your `test_helper.rb`:
33
24
 
34
25
  ```diff
35
26
  # test/test_helper.rb
@@ -45,6 +36,36 @@ class ActiveSupport::TestCase
45
36
  end
46
37
  ```
47
38
 
39
+ #### RSpec
40
+
41
+ You can require `type_fusion/rspec` in your `spec_helper.rb`:
42
+
43
+ ```diff
44
+ # spec/spec_helper.rb
45
+
46
+ +require "type_fusion/rspec"
47
+
48
+ RSpec.configure do |config|
49
+ # ...
50
+ end
51
+ ```
52
+
53
+ ### Running TypeFusion in `development` or `production`
54
+
55
+ #### Rack
56
+
57
+ ```ruby
58
+ require "type_fusion/rack/middleware"
59
+
60
+ use TypeFusion::Middleware
61
+ ```
62
+
63
+ #### Rails
64
+
65
+ Adding the gem to your applications Gemfile will automatically setup `type_fusion`.
66
+
67
+
68
+
48
69
  ## Configuration
49
70
 
50
71
  Setup `TypeFusion` in an initializer
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "../type_fusion"
4
+
3
5
  TypeFusion.start
4
6
 
5
7
  Minitest.after_run do
@@ -5,13 +5,18 @@ module TypeFusion
5
5
  def initialize(amount = 4)
6
6
  @amount = amount
7
7
  @servers = []
8
+ @started = false
8
9
  end
9
10
 
10
11
  def should_run?
11
- enqueued_samples.positive?
12
+ enqueued_jobs.positive?
12
13
  end
13
14
 
14
- def enqueued_samples
15
+ def started?
16
+ @started
17
+ end
18
+
19
+ def enqueued_jobs
15
20
  Litequeue.instance.count
16
21
  end
17
22
 
@@ -20,21 +25,23 @@ module TypeFusion
20
25
  server.instance_variable_get(:@scheduler).context.kill
21
26
  end
22
27
  @servers = []
28
+ @started = false
23
29
  end
24
30
 
25
31
  def start!
26
- Signal.trap("INT") do
27
- puts "\n[TypeFusion] Stop processing of TypeFusion samples..."
28
- stop!
29
- end
30
-
31
32
  @amount.times do
32
33
  @servers << Litejob::Server.new
33
34
  end
35
+ @started = true
34
36
  end
35
37
 
36
38
  def process!
37
- puts "[TypeFusion] Start processing of #{enqueued_samples} samples..."
39
+ puts "[TypeFusion] Start processing of #{enqueued_jobs} samples using #{@amount} threads..."
40
+
41
+ Signal.trap("INT") do
42
+ puts "\n[TypeFusion] Stop processing of TypeFusion samples..."
43
+ stop!
44
+ end
38
45
 
39
46
  start!
40
47
 
@@ -6,7 +6,6 @@ module TypeFusion
6
6
  class Middleware
7
7
  def initialize(app)
8
8
  @app = app
9
- TypeFusion.start_processing
10
9
  end
11
10
 
12
11
  def call(env)
@@ -17,6 +16,8 @@ module TypeFusion
17
16
 
18
17
  @app.call(env)
19
18
  ensure
19
+ TypeFusion.start_processing unless TypeFusion.processor.started?
20
+
20
21
  TypeFusion.stop
21
22
  end
22
23
  end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../type_fusion"
4
+
5
+ TypeFusion.start
6
+
7
+ RSpec.configure do |config|
8
+ config.after(:suite) do
9
+ TypeFusion.stop
10
+ TypeFusion.processor.process!
11
+ end
12
+ end
@@ -37,17 +37,19 @@ module TypeFusion
37
37
  parameters = extract_parameters(args, tracepoint.binding)
38
38
  return_value = type_for_object(tracepoint.return_value)
39
39
 
40
- sample = SampleCall.new(
40
+ sample_values = {
41
41
  gem_name: gem,
42
42
  gem_version: version,
43
43
  receiver: receiver,
44
44
  method_name: method_name,
45
+ application_name: TypeFusion.config.application_name,
45
46
  location: location,
46
47
  type_fusion_version: VERSION,
47
48
  parameters: parameters,
48
- application_name: TypeFusion.config.application_name,
49
49
  return_value: return_value,
50
- )
50
+ }
51
+
52
+ sample = SampleCall.new(*sample_values.values)
51
53
 
52
54
  samples << sample
53
55
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TypeFusion
4
- VERSION = "0.0.5"
4
+ VERSION = "0.0.6"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: type_fusion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marco Roth
@@ -61,6 +61,7 @@ files:
61
61
  - lib/type_fusion/processor.rb
62
62
  - lib/type_fusion/rack/middleware.rb
63
63
  - lib/type_fusion/rails/railtie.rb
64
+ - lib/type_fusion/rspec.rb
64
65
  - lib/type_fusion/sample_call.rb
65
66
  - lib/type_fusion/sample_job.rb
66
67
  - lib/type_fusion/sampler.rb
@@ -89,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
90
  - !ruby/object:Gem::Version
90
91
  version: '0'
91
92
  requirements: []
92
- rubygems_version: 3.4.17
93
+ rubygems_version: 3.3.26
93
94
  signing_key:
94
95
  specification_version: 4
95
96
  summary: Community-contributed sample data for Ruby types