type_fusion 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/Gemfile.lock +3 -3
- data/README.md +25 -6
- data/lib/tasks/type_fusion.rake +8 -0
- data/lib/type_fusion/config.rb +1 -1
- data/lib/type_fusion/litejob.rb +7 -0
- data/lib/type_fusion/minitest.rb +8 -0
- data/lib/type_fusion/processor.rb +60 -0
- data/lib/type_fusion/rack/middleware.rb +1 -0
- data/lib/type_fusion/sampler.rb +6 -2
- data/lib/type_fusion/version.rb +1 -1
- data/lib/type_fusion.rb +15 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba90818fd8e50f24a1b0049c0a8076a22b2e168a0fcafff53fb425b858b6323a
|
4
|
+
data.tar.gz: '011790f72f4d7e17fe12a8a1443f71e4bbdc42d4308f02c8110d5b07a3e91825'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23e4e3de6448d1f0f1a982ed90d73fec09b74d10b89e037bb6c477c24c8576bb42087a3dc112b612e41f81029e364472ebe498fd83258dc7da4f368c44866a26
|
7
|
+
data.tar.gz: 933b4a204122078dcc8a939daa35aae1648cb73ca06ec08231aa982be790adabc8075725ac715782873c84e8c657a3b6f12db9759b1fe32008dbde3557f70148
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.0.5] - 2023-08-25
|
4
|
+
|
5
|
+
- Introduce `TypeFusion::Processor` for processing samples
|
6
|
+
- Add support for running TypeFusion in the test environment with Minitest
|
7
|
+
- Rescue and log when job failed to enqueue
|
8
|
+
- Add Rake task for manually processing enqueued jobs
|
9
|
+
|
3
10
|
## [0.0.4] - 2023-08-16
|
4
11
|
|
5
12
|
- Implement sample collection by sending samples to gem.sh endpoint
|
data/Gemfile.lock
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
type_fusion (0.0.
|
4
|
+
type_fusion (0.0.5)
|
5
5
|
lhc (~> 15.2)
|
6
6
|
litejob (~> 0.2.3)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activesupport (7.0.7)
|
11
|
+
activesupport (7.0.7.2)
|
12
12
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
13
|
i18n (>= 1.6, < 2)
|
14
14
|
minitest (>= 5.1)
|
@@ -54,7 +54,7 @@ GEM
|
|
54
54
|
rake (13.0.6)
|
55
55
|
regexp_parser (2.8.1)
|
56
56
|
rexml (3.2.6)
|
57
|
-
rubocop (1.56.
|
57
|
+
rubocop (1.56.1)
|
58
58
|
base64 (~> 0.1.1)
|
59
59
|
json (~> 2.3)
|
60
60
|
language_server-protocol (>= 3.17.0)
|
data/README.md
CHANGED
@@ -27,6 +27,24 @@ use TypeFusion::Middleware
|
|
27
27
|
Adding the gem to your applications Gemfile will automatically setup `type_fusion`.
|
28
28
|
|
29
29
|
|
30
|
+
#### Minitest
|
31
|
+
|
32
|
+
If you only want to run TypeFusion in your test environment you can require `type_fusion/minitest` in your `test_helper.rb`:
|
33
|
+
|
34
|
+
```diff
|
35
|
+
# test/test_helper.rb
|
36
|
+
|
37
|
+
ENV["RAILS_ENV"] ||= "test"
|
38
|
+
require_relative "../config/environment"
|
39
|
+
require "rails/test_help"
|
40
|
+
|
41
|
+
+require "type_fusion/minitest"
|
42
|
+
|
43
|
+
class ActiveSupport::TestCase
|
44
|
+
# ...
|
45
|
+
end
|
46
|
+
```
|
47
|
+
|
30
48
|
## Configuration
|
31
49
|
|
32
50
|
Setup `TypeFusion` in an initializer
|
@@ -134,19 +152,20 @@ TypeFusion::Sampler.instance.samples
|
|
134
152
|
TypeFusion::Sampler.instance.samples.first
|
135
153
|
|
136
154
|
# => #<struct TypeFusion::SampleCall
|
137
|
-
#
|
155
|
+
# gem_name="nokogiri"
|
156
|
+
# gem_version="1.15.4-x86_64-darwin",
|
138
157
|
# receiver="Nokogiri",
|
139
158
|
# method_name=:parse,
|
140
|
-
#
|
141
|
-
#
|
142
|
-
#
|
143
|
-
# ],
|
159
|
+
# application_name="TypeFusion",
|
160
|
+
# location="/Users/marcoroth/.anyenv/envs/rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/nokogiri-1.15.4-x86_64-darwin/lib/nokogiri.rb:43",
|
161
|
+
# type_fusion_version="0.0.4",
|
144
162
|
# parameters=[
|
145
163
|
# [:string, :req, String],
|
146
164
|
# [:url, :opt, NilClass],
|
147
165
|
# [:encoding, :opt, NilClass],
|
148
166
|
# [:options, :opt, NilClass]
|
149
|
-
# ]
|
167
|
+
# ],
|
168
|
+
# return_value="Nokogiri::XML::Document"
|
150
169
|
# >
|
151
170
|
```
|
152
171
|
|
data/lib/type_fusion/config.rb
CHANGED
@@ -23,7 +23,7 @@ module TypeFusion
|
|
23
23
|
@type_sample_call_rate = 0.001
|
24
24
|
@type_sample_request = ->(_env) { [true, false, false, false].sample }
|
25
25
|
@type_sample_tracepoint_path = ->(_tracepoint_path) { true }
|
26
|
-
@endpoint = "
|
26
|
+
@endpoint = "https://gem.sh/api/v1/types/samples"
|
27
27
|
@application_name = "TypeFusion"
|
28
28
|
end
|
29
29
|
|
data/lib/type_fusion/litejob.rb
CHANGED
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TypeFusion
|
4
|
+
class Processor
|
5
|
+
def initialize(amount = 4)
|
6
|
+
@amount = amount
|
7
|
+
@servers = []
|
8
|
+
end
|
9
|
+
|
10
|
+
def should_run?
|
11
|
+
enqueued_samples.positive?
|
12
|
+
end
|
13
|
+
|
14
|
+
def enqueued_samples
|
15
|
+
Litequeue.instance.count
|
16
|
+
end
|
17
|
+
|
18
|
+
def stop!
|
19
|
+
@servers.each do |server|
|
20
|
+
server.instance_variable_get(:@scheduler).context.kill
|
21
|
+
end
|
22
|
+
@servers = []
|
23
|
+
end
|
24
|
+
|
25
|
+
def start!
|
26
|
+
Signal.trap("INT") do
|
27
|
+
puts "\n[TypeFusion] Stop processing of TypeFusion samples..."
|
28
|
+
stop!
|
29
|
+
end
|
30
|
+
|
31
|
+
@amount.times do
|
32
|
+
@servers << Litejob::Server.new
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def process!
|
37
|
+
puts "[TypeFusion] Start processing of #{enqueued_samples} samples..."
|
38
|
+
|
39
|
+
start!
|
40
|
+
|
41
|
+
while should_run?
|
42
|
+
puts "[TypeFusion] Remaining samples: #{Litequeue.instance.count}"
|
43
|
+
sleep 1
|
44
|
+
end
|
45
|
+
|
46
|
+
puts "[TypeFusion] Finished!"
|
47
|
+
|
48
|
+
puts "[TypeFusion] Congratulations! You just contributed samples to the following gems and helped making the Ruby ecosystem better for the whole community! Thank you!\n"
|
49
|
+
puts "- #{gems.join("\n- ")}"
|
50
|
+
|
51
|
+
stop!
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def gems
|
57
|
+
TypeFusion::Sampler.instance.samples.map(&:gem_name).uniq.sort
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/lib/type_fusion/sampler.rb
CHANGED
@@ -10,7 +10,6 @@ module TypeFusion
|
|
10
10
|
|
11
11
|
def initialize
|
12
12
|
@samples = []
|
13
|
-
@litejob_server ||= Litejob::Server.new([["default", 1]])
|
14
13
|
end
|
15
14
|
|
16
15
|
def with_sampling
|
@@ -51,7 +50,12 @@ module TypeFusion
|
|
51
50
|
)
|
52
51
|
|
53
52
|
samples << sample
|
54
|
-
|
53
|
+
|
54
|
+
begin
|
55
|
+
SampleJob.perform_async(sample)
|
56
|
+
rescue StandardError => e
|
57
|
+
puts "[TypeFusion] Couldn't enqueue sample: #{e.inspect}"
|
58
|
+
end
|
55
59
|
end
|
56
60
|
end.tap(&:disable)
|
57
61
|
end
|
data/lib/type_fusion/version.rb
CHANGED
data/lib/type_fusion.rb
CHANGED
@@ -6,6 +6,7 @@ require_relative "type_fusion/litejob"
|
|
6
6
|
require_relative "type_fusion/sample_call"
|
7
7
|
require_relative "type_fusion/sample_job"
|
8
8
|
require_relative "type_fusion/sampler"
|
9
|
+
require_relative "type_fusion/processor"
|
9
10
|
|
10
11
|
module TypeFusion
|
11
12
|
class << self
|
@@ -23,6 +24,16 @@ module TypeFusion
|
|
23
24
|
Sampler.instance.trace.disable
|
24
25
|
end
|
25
26
|
|
27
|
+
def start_processing
|
28
|
+
puts "[TypeFusion] Start processing..."
|
29
|
+
processor.start!
|
30
|
+
end
|
31
|
+
|
32
|
+
def stop_processing
|
33
|
+
puts "[TypeFusion] Stop processing..."
|
34
|
+
processor.stop!
|
35
|
+
end
|
36
|
+
|
26
37
|
def with_sampling
|
27
38
|
start
|
28
39
|
|
@@ -30,6 +41,10 @@ module TypeFusion
|
|
30
41
|
|
31
42
|
stop
|
32
43
|
end
|
44
|
+
|
45
|
+
def processor
|
46
|
+
@processor ||= TypeFusion::Processor.new(4)
|
47
|
+
end
|
33
48
|
end
|
34
49
|
end
|
35
50
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marco Roth
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-08-
|
11
|
+
date: 2023-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lhc
|
@@ -53,9 +53,12 @@ files:
|
|
53
53
|
- Gemfile.lock
|
54
54
|
- README.md
|
55
55
|
- Rakefile
|
56
|
+
- lib/tasks/type_fusion.rake
|
56
57
|
- lib/type_fusion.rb
|
57
58
|
- lib/type_fusion/config.rb
|
58
59
|
- lib/type_fusion/litejob.rb
|
60
|
+
- lib/type_fusion/minitest.rb
|
61
|
+
- lib/type_fusion/processor.rb
|
59
62
|
- lib/type_fusion/rack/middleware.rb
|
60
63
|
- lib/type_fusion/rails/railtie.rb
|
61
64
|
- lib/type_fusion/sample_call.rb
|