monotime 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +16 -0
- data/.rubocop.yml +17 -1
- data/CHANGELOG.md +10 -0
- data/README.md +26 -22
- data/lib/monotime/duration.rb +1 -0
- data/lib/monotime/include.rb +5 -0
- data/lib/monotime/instant.rb +1 -0
- data/lib/monotime/version.rb +1 -1
- data/monotime.gemspec +2 -1
- metadata +25 -11
- data/.travis.yml +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a9395967e506d690912041251bc7b6afd1a373aa49d0b4425ec08ca611e5238
|
4
|
+
data.tar.gz: '09ec6a1e96c9ce434d4847d275d85f7514c4a9bb3d9c71d205b04ab0f06e6d5b'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a68a338484a8534a8953abf5bec0a98a6b7a2dc6a506cd1f5fb1e3b29e1b534fa0d41e4175aa81598273ee5d706d16caeb60ce1b89a92b5e8192f87a960265f3
|
7
|
+
data.tar.gz: f9f329d74339eccc1b4c50007d2cb93cc87132ce6a5841faa327d4db48dfb347df8faee3f9777551cb686e90001def65d72c8a77c6b6df4dfed1d847598ac685
|
@@ -0,0 +1,16 @@
|
|
1
|
+
name: CI
|
2
|
+
on: [push, pull_request]
|
3
|
+
jobs:
|
4
|
+
test:
|
5
|
+
runs-on: ubuntu-latest
|
6
|
+
strategy:
|
7
|
+
fail-fast: false
|
8
|
+
matrix:
|
9
|
+
ruby: ['2.5', '2.6', '2.7', '3.0', jruby, truffleruby]
|
10
|
+
steps:
|
11
|
+
- uses: actions/checkout@v2
|
12
|
+
- uses: ruby/setup-ruby@v1
|
13
|
+
with:
|
14
|
+
ruby-version: ${{ matrix.ruby }}
|
15
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
16
|
+
- run: bundle exec rake
|
data/.rubocop.yml
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
AllCops:
|
2
|
+
NewCops: enable
|
2
3
|
Exclude:
|
3
4
|
- "bin/*"
|
4
5
|
- "test/*"
|
@@ -6,7 +7,7 @@ AllCops:
|
|
6
7
|
- "Rakefile"
|
7
8
|
- "Gemfile"
|
8
9
|
|
9
|
-
|
10
|
+
Layout/LineLength:
|
10
11
|
Max: 96
|
11
12
|
|
12
13
|
Metrics/ClassLength:
|
@@ -20,3 +21,18 @@ Style/AccessModifierDeclarations:
|
|
20
21
|
|
21
22
|
Style/FormatStringToken:
|
22
23
|
Enabled: false
|
24
|
+
|
25
|
+
Style/HashEachMethods:
|
26
|
+
Enabled: true
|
27
|
+
|
28
|
+
Style/HashTransformKeys:
|
29
|
+
Enabled: true
|
30
|
+
|
31
|
+
Style/HashTransformValues:
|
32
|
+
Enabled: true
|
33
|
+
|
34
|
+
Style/ExplicitBlockArgument:
|
35
|
+
Enabled: false
|
36
|
+
|
37
|
+
Style/MixinUsage:
|
38
|
+
Enabled: false
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.7.1 - 2021-10-22
|
4
|
+
### Added
|
5
|
+
- `simplecov` introduced to test suite.
|
6
|
+
- `monotime/include.rb` to auto-include types globally.
|
7
|
+
|
8
|
+
### Changed
|
9
|
+
- All `Instant` and `Duration` instances are now frozen.
|
10
|
+
- Migrate from Travis CI to Github Actions
|
11
|
+
- Update development dependency on `rake`.
|
12
|
+
|
3
13
|
## [0.7.0] - 2019-04-24
|
4
14
|
### Added
|
5
15
|
- `Duration.with_measure`, which yields and returns an array containing its
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
[![Gem Version](https://badge.fury.io/rb/monotime.svg)](https://badge.fury.io/rb/monotime)
|
2
|
-
|
2
|
+
![Build Status](https://github.com/Freaky/monotime/actions/workflows/ci.yml/badge.svg)
|
3
3
|
[![Inline docs](http://inch-ci.org/github/Freaky/monotime.svg?branch=master)](http://inch-ci.org/github/Freaky/monotime)
|
4
4
|
[![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](https://www.rubydoc.info/gems/monotime)
|
5
5
|
|
@@ -23,10 +23,17 @@ Or install it yourself as:
|
|
23
23
|
|
24
24
|
$ gem install monotime
|
25
25
|
|
26
|
-
`Monotime` is tested on Ruby 2.
|
26
|
+
`Monotime` is tested on Ruby 2.5—3.0 and recent JRuby 9.x releases.
|
27
27
|
|
28
28
|
## Usage
|
29
29
|
|
30
|
+
```ruby
|
31
|
+
require 'monotime'
|
32
|
+
# or, to automatically include Monotime::* in the global scope,
|
33
|
+
# as used by these examples:
|
34
|
+
require 'monotime/include'
|
35
|
+
```
|
36
|
+
|
30
37
|
`Monotime` offers a `Duration` type for describing spans of time, and an
|
31
38
|
`Instant` type for describing points in time. Both operate at nanosecond
|
32
39
|
resolution to the limits of whatever your Ruby implementation supports.
|
@@ -36,8 +43,6 @@ start point, perform the action and then ask for the `Duration` that has elapsed
|
|
36
43
|
since:
|
37
44
|
|
38
45
|
```ruby
|
39
|
-
include Monotime
|
40
|
-
|
41
46
|
start = Instant.now
|
42
47
|
do_something
|
43
48
|
elapsed = start.elapsed
|
@@ -47,9 +52,7 @@ Or use a convenience method:
|
|
47
52
|
|
48
53
|
```ruby
|
49
54
|
elapsed = Duration.measure { do_something }
|
50
|
-
|
51
55
|
# or
|
52
|
-
|
53
56
|
return_value, elapsed = Duration.with_measure { compute_something }
|
54
57
|
```
|
55
58
|
|
@@ -98,34 +101,37 @@ is not yet implemented):
|
|
98
101
|
```ruby
|
99
102
|
# Equivalent
|
100
103
|
sleep(Duration.secs(1).secs) # => 1
|
101
|
-
|
102
|
-
Duration.secs(1).sleep # => 1
|
104
|
+
Duration.secs(1).sleep # => 1
|
103
105
|
```
|
104
106
|
|
105
107
|
So can `Instant`, taking a `Duration` and sleeping until the given `Duration`
|
106
|
-
past the time the `Instant` was created, if any.
|
107
|
-
|
108
|
+
past the time the `Instant` was created, if any. This can be useful for
|
109
|
+
maintaining a precise candence between tasks:
|
108
110
|
|
109
111
|
```ruby
|
110
|
-
|
112
|
+
interval = Duration.secs(60)
|
113
|
+
start = Instant.now
|
111
114
|
loop do
|
112
|
-
|
113
|
-
|
114
|
-
start
|
115
|
-
# alternative: start.sleep_secs(60)
|
115
|
+
do_stuff
|
116
|
+
start.sleep(interval)
|
117
|
+
start += interval
|
116
118
|
end
|
117
119
|
```
|
118
120
|
|
119
|
-
Or you can declare
|
121
|
+
Or you can declare an `Instant` in the future and sleep to that point:
|
120
122
|
|
121
123
|
```ruby
|
122
|
-
|
123
|
-
|
124
|
-
|
124
|
+
interval = Duration.secs(60)
|
125
|
+
deadline = Instant.now + interval
|
126
|
+
loop do
|
127
|
+
do_stuff
|
128
|
+
deadline.sleep
|
129
|
+
deadline += interval
|
130
|
+
end
|
125
131
|
```
|
126
132
|
|
127
133
|
`Instant#sleep` returns a `Duration` which was slept, or a negative `Duration`
|
128
|
-
|
134
|
+
indicating that the desired sleep point was in the past.
|
129
135
|
|
130
136
|
## Duration duck typing
|
131
137
|
|
@@ -174,5 +180,3 @@ depending on platform.
|
|
174
180
|
which also includes a variety of features for gathering statistics about
|
175
181
|
measurements, and may offer higher precision on some platforms.
|
176
182
|
|
177
|
-
Note until [#73](https://github.com/copiousfreetime/hitimes/pull/73) is closed it
|
178
|
-
depends on compiled C/Java extensions.
|
data/lib/monotime/duration.rb
CHANGED
data/lib/monotime/instant.rb
CHANGED
data/lib/monotime/version.rb
CHANGED
data/monotime.gemspec
CHANGED
@@ -32,6 +32,7 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.require_paths = ["lib"]
|
33
33
|
|
34
34
|
spec.add_development_dependency "bundler", "~> 2"
|
35
|
-
spec.add_development_dependency "rake", "~>
|
35
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
36
36
|
spec.add_development_dependency "minitest", "~> 5.0"
|
37
|
+
spec.add_development_dependency "simplecov", "~> 0.21"
|
37
38
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: monotime
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Hurst
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '13.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '13.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,16 +52,30 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '5.0'
|
55
|
-
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: simplecov
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.21'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.21'
|
69
|
+
description:
|
56
70
|
email:
|
57
71
|
- tom@hur.st
|
58
72
|
executables: []
|
59
73
|
extensions: []
|
60
74
|
extra_rdoc_files: []
|
61
75
|
files:
|
76
|
+
- ".github/workflows/ci.yml"
|
62
77
|
- ".gitignore"
|
63
78
|
- ".rubocop.yml"
|
64
|
-
- ".travis.yml"
|
65
79
|
- CHANGELOG.md
|
66
80
|
- Gemfile
|
67
81
|
- LICENSE.txt
|
@@ -71,6 +85,7 @@ files:
|
|
71
85
|
- bin/setup
|
72
86
|
- lib/monotime.rb
|
73
87
|
- lib/monotime/duration.rb
|
88
|
+
- lib/monotime/include.rb
|
74
89
|
- lib/monotime/instant.rb
|
75
90
|
- lib/monotime/version.rb
|
76
91
|
- monotime.gemspec
|
@@ -79,7 +94,7 @@ licenses:
|
|
79
94
|
- MIT
|
80
95
|
metadata:
|
81
96
|
allowed_push_host: https://rubygems.org
|
82
|
-
post_install_message:
|
97
|
+
post_install_message:
|
83
98
|
rdoc_options: []
|
84
99
|
require_paths:
|
85
100
|
- lib
|
@@ -94,9 +109,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
109
|
- !ruby/object:Gem::Version
|
95
110
|
version: '0'
|
96
111
|
requirements: []
|
97
|
-
|
98
|
-
|
99
|
-
signing_key:
|
112
|
+
rubygems_version: 3.2.22
|
113
|
+
signing_key:
|
100
114
|
specification_version: 4
|
101
115
|
summary: A sensible interface to the monotonic clock
|
102
116
|
test_files: []
|