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 +4 -4
- data/CHANGELOG.md +8 -1
- data/Gemfile.lock +1 -1
- data/README.md +33 -12
- data/lib/type_fusion/minitest.rb +2 -0
- data/lib/type_fusion/processor.rb +15 -8
- data/lib/type_fusion/rack/middleware.rb +2 -1
- data/lib/type_fusion/rspec.rb +12 -0
- data/lib/type_fusion/sampler.rb +5 -3
- data/lib/type_fusion/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9c5749c381eccd5f84c5d824fce4d634cde7bda503638dfef9c9737b61c7cb0
|
4
|
+
data.tar.gz: 6fc4cb00bf6ddb01f0832962df93add41020668d2de5ca3933c3619039bbda96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b1c116b16c6f56234a1718af703c0c8e64527230e9cb74f4efae26727a467e30ac63b233f0f075f8494b1fc40096d3bf113b03bd0ab409f3088e7332c09a04f
|
7
|
+
data.tar.gz: a687bce21925739f806d3cb458a08e301723db19d755dcc04f3de47098fbe4236ccb30a84fa6e2845be6553cad92f1a1145464fe16483a0416ed0650cf8a969a
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,11 @@
|
|
1
|
-
## [
|
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
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
|
-
|
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
|
-
|
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
|
data/lib/type_fusion/minitest.rb
CHANGED
@@ -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
|
-
|
12
|
+
enqueued_jobs.positive?
|
12
13
|
end
|
13
14
|
|
14
|
-
def
|
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 #{
|
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
|
data/lib/type_fusion/sampler.rb
CHANGED
@@ -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
|
-
|
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
|
|
data/lib/type_fusion/version.rb
CHANGED
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.
|
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.
|
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
|