fiber-annotation 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c9ffc1572c38b76c7fbbf7d8c96cc03f199c17c273e970df287d08b99db0d425
4
+ data.tar.gz: 270ff0cf268ff8d8b27c7488b8961edffe5abb5e78646f9b7f7404699162e41e
5
+ SHA512:
6
+ metadata.gz: 5c0f23f106b9e8751ed8c3802d6ca5cd630cabf6da3fd07af7ba28f63b44e174bbca80347f36423472f626657036e761f56ce33107a59b71892180a748f15394
7
+ data.tar.gz: 12a105d49ee347cac3ceff44d39861faea5bc0d9a42b6ac12cbefa19978732ac22290d28d5601386c32ea45df66788403eaa6cd1721aff4307670586b6d33283
checksums.yaml.gz.sig ADDED
Binary file
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2023, by Samuel Williams.
5
+
6
+ class Fiber
7
+ module Annotation
8
+ VERSION = "0.2.0"
9
+ end
10
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2023, by Samuel Williams.
5
+
6
+ require 'fiber'
7
+
8
+ class Fiber
9
+ # A mechanism for annotating fibers.
10
+ module Annotation
11
+ # Annotate the current fiber with the given annotation.
12
+ # @parameter annotation [Object] The annotation to set.
13
+ def initialize(annotation: nil, **options, &block)
14
+ @annotation = annotation
15
+ super(**options, &block)
16
+ end
17
+
18
+ # Get the current annotation.
19
+ # @returns [Object] The current annotation.
20
+ attr_accessor :annotation
21
+
22
+ # Annotate the current fiber with the given annotation.
23
+ #
24
+ # If a block is given, the annotation is set for the duration of the block and then restored to the previous value.
25
+ #
26
+ # The block form of this method should only be invoked on the current fiber.
27
+ #
28
+ # @parameter annotation [Object] The annotation to set.
29
+ # @yields {} The block to execute with the given annotation.
30
+ # @returns [Object] The return value of the block.
31
+ def annotate(annotation)
32
+ if block_given?
33
+ raise "Cannot annotation a different fiber!" unless Fiber.current == self
34
+
35
+ begin
36
+ current_annotation = @annotation
37
+ @annotation = annotation
38
+ return yield
39
+ ensure
40
+ @annotation = current_annotation
41
+ end
42
+ else
43
+ @annotation = annotation
44
+ end
45
+ end
46
+ end
47
+ end
48
+
49
+ unless Fiber.method_defined?(:annotation)
50
+ Fiber.prepend(Fiber::Annotation)
51
+
52
+ # @scope Fiber
53
+ # @name self.annotate
54
+ # Annotate the current fiber with the given annotation.
55
+ def Fiber.annotate(...)
56
+ Fiber.current.annotate(...)
57
+ end
58
+ end
data/license.md ADDED
@@ -0,0 +1,21 @@
1
+ # MIT License
2
+
3
+ Copyright, 2023, by Samuel Williams.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/readme.md ADDED
@@ -0,0 +1,19 @@
1
+ # Fiber::Annotation
2
+
3
+ A simple way to annotate what a fiber is currently doing, useful for debugging, logging and tracing.
4
+
5
+ [![Development Status](https://github.com/ioquatix/fiber-annotation/workflows/Test/badge.svg)](https://github.com/ioquatix/fiber-annotation/actions?workflow=Test)
6
+
7
+ ## Usage
8
+
9
+ Please see the [project documentation](https://ioquatix.github.io/fiber-annotation).
10
+
11
+ ## Contributing
12
+
13
+ We welcome contributions to this project.
14
+
15
+ 1. Fork it.
16
+ 2. Create your feature branch (`git checkout -b my-new-feature`).
17
+ 3. Commit your changes (`git commit -am 'Add some feature'`).
18
+ 4. Push to the branch (`git push origin my-new-feature`).
19
+ 5. Create new Pull Request.
data.tar.gz.sig ADDED
Binary file
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fiber-annotation
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Samuel Williams
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIE2DCCA0CgAwIBAgIBATANBgkqhkiG9w0BAQsFADBhMRgwFgYDVQQDDA9zYW11
14
+ ZWwud2lsbGlhbXMxHTAbBgoJkiaJk/IsZAEZFg1vcmlvbnRyYW5zZmVyMRIwEAYK
15
+ CZImiZPyLGQBGRYCY28xEjAQBgoJkiaJk/IsZAEZFgJuejAeFw0yMjA4MDYwNDUz
16
+ MjRaFw0zMjA4MDMwNDUzMjRaMGExGDAWBgNVBAMMD3NhbXVlbC53aWxsaWFtczEd
17
+ MBsGCgmSJomT8ixkARkWDW9yaW9udHJhbnNmZXIxEjAQBgoJkiaJk/IsZAEZFgJj
18
+ bzESMBAGCgmSJomT8ixkARkWAm56MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIB
19
+ igKCAYEAomvSopQXQ24+9DBB6I6jxRI2auu3VVb4nOjmmHq7XWM4u3HL+pni63X2
20
+ 9qZdoq9xt7H+RPbwL28LDpDNflYQXoOhoVhQ37Pjn9YDjl8/4/9xa9+NUpl9XDIW
21
+ sGkaOY0eqsQm1pEWkHJr3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61JR6lvkGYQ2MYskBveyaxt
37
+ Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
38
+ voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
39
+ -----END CERTIFICATE-----
40
+ date: 2023-06-05 00:00:00.000000000 Z
41
+ dependencies: []
42
+ description:
43
+ email:
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - lib/fiber/annotation.rb
49
+ - lib/fiber/annotation/version.rb
50
+ - license.md
51
+ - readme.md
52
+ homepage: https://github.com/ioquatix/fiber-annotation
53
+ licenses:
54
+ - MIT
55
+ metadata:
56
+ funding_uri: https://github.com/sponsors/ioquatix/
57
+ post_install_message:
58
+ rdoc_options: []
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: '2.7'
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ requirements: []
72
+ rubygems_version: 3.4.7
73
+ signing_key:
74
+ specification_version: 4
75
+ summary: A mechanism for annotating fibers.
76
+ test_files: []
metadata.gz.sig ADDED
Binary file