Skip to content

Commit

Permalink
Rename gem from fiber-annotate to fiber-annotation to better refl…
Browse files Browse the repository at this point in the history
…ect it's main feature.
  • Loading branch information
ioquatix committed Jun 5, 2023
1 parent 9d63318 commit 54b4eff
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 25 deletions.
8 changes: 4 additions & 4 deletions fiber-annotate.gemspec → fiber-annotation.gemspec
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# frozen_string_literal: true

require_relative "lib/fiber/annotate/version"
require_relative "lib/fiber/annotation/version"

Gem::Specification.new do |spec|
spec.name = "fiber-annotate"
spec.version = Fiber::Annotate::VERSION
spec.name = "fiber-annotation"
spec.version = Fiber::Annotation::VERSION

spec.summary = "A mechanism for annotating fibers."
spec.authors = ["Samuel Williams"]
Expand All @@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
spec.cert_chain = ['release.cert']
spec.signing_key = File.expand_path('~/.gem/release.pem')

spec.homepage = "https://github.com/ioquatix/fiber-annotate"
spec.homepage = "https://github.com/ioquatix/fiber-annotation"

spec.metadata = {
"funding_uri" => "https://github.com/sponsors/ioquatix/",
Expand Down
4 changes: 2 additions & 2 deletions guides/getting-started/readme.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Getting Started

This guide gives shows how to add fiber-annotate to your project and annotate your fibers.
This guide shows how to add `fiber-annotation` to your project and annotate your fibers.

## Installation

Add the gem to your project:

~~~ bash
$ bundle add fiber-annotate
$ bundle add fiber-annotation
~~~

## Annotating a Fiber
Expand Down
18 changes: 8 additions & 10 deletions lib/fiber/annotate.rb → lib/fiber/annotation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class Fiber
# A mechanism for annotating fibers.
module Annotate
module Annotation
# Annotate the current fiber with the given annotation.
# @parameter annotation [Object] The annotation to set.
def initialize(annotation: nil, **options, &block)
Expand All @@ -17,23 +17,21 @@ def initialize(annotation: nil, **options, &block)

# Get the current annotation.
# @returns [Object] The current annotation.
def annotation
@annotation
end
attr_accessor :annotation

# Annotate the current fiber with the given annotation.
#
# If a block is given, the annotation is set for the duration of the block and then restored.
# If a block is given, the annotation is set for the duration of the block and then restored to the previous value.
#
# This method should only be invoked on the current fiber.
# The block form of this method should only be invoked on the current fiber.
#
# @parameter annotation [Object] The annotation to set.
# @yields {} The block to execute with the given annotation.
# @returns [Object] The return value of the block.
def annotate(annotation)
raise "Cannot annotate a different fiber!" unless Fiber.current == self

if block_given?
raise "Cannot annotation a different fiber!" unless Fiber.current == self

begin
current_annotation = @annotation
@annotation = annotation
Expand All @@ -49,11 +47,11 @@ def annotate(annotation)
end

unless Fiber.method_defined?(:annotation)
Fiber.prepend(Fiber::Annotate)
Fiber.prepend(Fiber::Annotation)

# @scope Fiber
# @name self.annotate
# Annotate the current fiber with the given annotation.
# Annotation the current fiber with the given annotation.
def Fiber.annotate(...)
Fiber.current.annotate(...)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Copyright, 2023, by Samuel Williams.

class Fiber
module Annotate
module Annotation
VERSION = "0.1.0"
end
end
8 changes: 4 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Fiber::Annotate
# Fiber::Annotation

A simple way to annotate what a fiber is currently doing, useful for debugging.
A simple way to annotate what a fiber is currently doing, useful for debugging, logging and tracing.

[![Development Status](https://github.com/ioquatix/fiber-annotate/workflows/Test/badge.svg)](https://github.com/ioquatix/fiber-annotate/actions?workflow=Test)
[![Development Status](https://github.com/ioquatix/fiber-annotation/workflows/Test/badge.svg)](https://github.com/ioquatix/fiber-annotation/actions?workflow=Test)

## Usage

Please see the [project documentation](https://ioquatix.github.io/fiber-annotate).
Please see the [project documentation](https://ioquatix.github.io/fiber-annotation).

## Contributing

Expand Down
8 changes: 4 additions & 4 deletions test/fiber/annotate.rb → test/fiber/annotation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
# Released under the MIT License.
# Copyright, 2023, by Samuel Williams.

require 'fiber/annotate'
require 'fiber/annotation'

describe Fiber do
it "should be able to annotate a fiber" do
it "should be able to annotation a fiber" do
fiber = Fiber.new(annotation: "foo") do
expect(Fiber.current.annotation).to be == "foo"
end

expect(fiber.annotation).to be == "foo"
expect(Fiber.current.annotation).to be == nil
end

with '.annotate' do
with '.annotation' do
it "should annotate the current fiber" do
Fiber.annotate("foo")
expect(Fiber.current.annotation).to be == "foo"
Expand Down

0 comments on commit 54b4eff

Please sign in to comment.