interactor-stopwatch 0.1.1
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 +7 -0
- data/.rspec +3 -0
- data/.standard.yml +3 -0
- data/CHANGELOG.md +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +47 -0
- data/Rakefile +10 -0
- data/lib/interactor/stopwatch/version.rb +7 -0
- data/lib/interactor/stopwatch.rb +26 -0
- data/sig/interactor/stopwatch.rbs +6 -0
- metadata +84 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0066ea7dfe76c12206c8cfb51984f1c9f549088dca5ea805df7eb38b1fdcb402
|
4
|
+
data.tar.gz: e602daea36cc17f228e66b8344fb380dbbd171e09c27b9245be30ff719739086
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ea8c351d71c8a86ea70f1bd483e4cc31776fa37894c8dfdacb5a9c1491e2dd87b2088ef6a7372c3dc3f0c03b8c9590392c55ef7bfde1aed580b7364bd49f63ab
|
7
|
+
data.tar.gz: eab38a763fe8e74bde6254e0cef6c82636226e884df61ddfbbd400b211ed4eb0672d4dce050d1c7cdb8d4b5c17e3840044ac227bac2b35d60669505e08e073e6
|
data/.rspec
ADDED
data/.standard.yml
ADDED
data/CHANGELOG.md
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2024 TODO: Write your name
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# Interactor::Stopwatch
|
2
|
+
|
3
|
+
Stopwatch is a miniature Interactor extension that is watching the clock.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Install the gem and add to the application's Gemfile by executing:
|
8
|
+
|
9
|
+
$ bundle add interactor-stopwatch
|
10
|
+
|
11
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
12
|
+
|
13
|
+
$ gem install interactor-stopwatch
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
A sample Interactor could look a little like this, the `stopwatch` block yields in the context of our interactor instance with a single block parameter (ActiveSupport::Duration) of the interactor's lifecycle.
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
class TakeTime
|
21
|
+
include Interactor
|
22
|
+
include Interactor::Stopwatch
|
23
|
+
|
24
|
+
stopwatch do |duration|
|
25
|
+
puts "TakeTime took #{duration}s"
|
26
|
+
end
|
27
|
+
|
28
|
+
def call
|
29
|
+
sleep 0.1
|
30
|
+
context.message = 'I measured how long this took'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
```
|
34
|
+
|
35
|
+
## Development
|
36
|
+
|
37
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
38
|
+
|
39
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
40
|
+
|
41
|
+
## Contributing
|
42
|
+
|
43
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/braindeaf/interactor-stopwatch.
|
44
|
+
|
45
|
+
## License
|
46
|
+
|
47
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "interactor"
|
4
|
+
require "active_support/deprecator"
|
5
|
+
require "active_support/deprecation"
|
6
|
+
require "active_support/core_ext/numeric/time"
|
7
|
+
|
8
|
+
require_relative "stopwatch/version"
|
9
|
+
|
10
|
+
module Interactor
|
11
|
+
module Stopwatch
|
12
|
+
def self.included(base)
|
13
|
+
base.extend(ClassMethods)
|
14
|
+
end
|
15
|
+
|
16
|
+
module ClassMethods
|
17
|
+
def stopwatch(&block)
|
18
|
+
around do |interactor|
|
19
|
+
starts_at = Time.now
|
20
|
+
interactor.call
|
21
|
+
instance_exec((Time.now - starts_at).seconds, &block)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: interactor-stopwatch
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- RobL
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-07-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: interactor
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.0'
|
41
|
+
description: Stopwatch is a miniature Interactor extension that is watching the clock.
|
42
|
+
It is a simple way to measure how long an interactor takes to run.
|
43
|
+
email:
|
44
|
+
- contact@robl.me
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".rspec"
|
50
|
+
- ".standard.yml"
|
51
|
+
- CHANGELOG.md
|
52
|
+
- LICENSE.txt
|
53
|
+
- README.md
|
54
|
+
- Rakefile
|
55
|
+
- lib/interactor/stopwatch.rb
|
56
|
+
- lib/interactor/stopwatch/version.rb
|
57
|
+
- sig/interactor/stopwatch.rbs
|
58
|
+
homepage: https://github.com/braindeaf/interactor-stopwatch
|
59
|
+
licenses:
|
60
|
+
- MIT
|
61
|
+
metadata:
|
62
|
+
homepage_uri: https://github.com/braindeaf/interactor-stopwatch
|
63
|
+
source_code_uri: https://github.com/braindeaf/interactor-stopwatch
|
64
|
+
changelog_uri: https://github.com/braindeaf/interactor-stopwatch/CHANGELOG.md
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options: []
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: 3.0.0
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
requirements: []
|
80
|
+
rubygems_version: 3.5.3
|
81
|
+
signing_key:
|
82
|
+
specification_version: 4
|
83
|
+
summary: Stopwatch is a miniature Interactor extension that is watching the clock.
|
84
|
+
test_files: []
|