elapsed 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.0pdd.yml +22 -0
- data/.gitattributes +7 -0
- data/.github/workflows/actionlint.yml +41 -0
- data/.github/workflows/codecov.yml +39 -0
- data/.github/workflows/license.yml +57 -0
- data/.github/workflows/markdown-lint.yml +38 -0
- data/.github/workflows/pdd.yml +34 -0
- data/.github/workflows/rake.yml +44 -0
- data/.github/workflows/xcop.yml +30 -0
- data/.github/workflows/yamllint.yml +34 -0
- data/.gitignore +9 -0
- data/.pdd +7 -0
- data/.rubocop.yml +42 -0
- data/.rultor.yml +44 -0
- data/.simplecov +41 -0
- data/Gemfile +33 -0
- data/Gemfile.lock +193 -0
- data/LICENSE.txt +21 -0
- data/README.md +67 -0
- data/Rakefile +68 -0
- data/elapsed.gemspec +45 -0
- data/lib/elapsed.rb +72 -0
- data/renovate.json +6 -0
- data/test/test__helper.rb +31 -0
- data/test/test_elapsed.rb +55 -0
- metadata +101 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9562903568a73870f07e2efcc82ea987817b1ec0fc861b9dbacf4da687121467
|
4
|
+
data.tar.gz: 9d8d43539df6d1ddd70debbde0e58a05887603de7dbff9cdd8c112edaf1869d5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1e286aae793f8e854892ad20ae76fc2258d3afad1e0f18eac116932f8476792e8d9aff7ae74d55806183462f837857f081a2a774719c018a0034936d69453f80
|
7
|
+
data.tar.gz: 820e25a81c030d7d775d13b8c289c384e7e1e05544b41af50ab4f181d177571ac9ce187a9f79c637972d824bc6f1f1e1a751d838c6422dadc831fc4aee9702fa
|
data/.0pdd.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# Copyright (c) 2024 Yegor Bugayenko
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in all
|
11
|
+
# copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
# SOFTWARE.
|
20
|
+
---
|
21
|
+
errors:
|
22
|
+
- yegor256@gmail.com
|
data/.gitattributes
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# Copyright (c) 2024 Yegor Bugayenko
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in all
|
11
|
+
# copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
# SOFTWARE.
|
20
|
+
---
|
21
|
+
name: actionlint
|
22
|
+
'on':
|
23
|
+
push:
|
24
|
+
branches:
|
25
|
+
- master
|
26
|
+
pull_request:
|
27
|
+
branches:
|
28
|
+
- master
|
29
|
+
jobs:
|
30
|
+
actionlint:
|
31
|
+
runs-on: ubuntu-22.04
|
32
|
+
steps:
|
33
|
+
- uses: actions/checkout@v4
|
34
|
+
- name: Download actionlint
|
35
|
+
id: get_actionlint
|
36
|
+
# yamllint disable-line rule:line-length
|
37
|
+
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
|
38
|
+
shell: bash
|
39
|
+
- name: Check workflow files
|
40
|
+
run: ${{ steps.get_actionlint.outputs.executable }} -color
|
41
|
+
shell: bash
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# Copyright (c) 2024 Yegor Bugayenko
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in all
|
11
|
+
# copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
# SOFTWARE.
|
20
|
+
---
|
21
|
+
name: codecov
|
22
|
+
'on':
|
23
|
+
push:
|
24
|
+
branches:
|
25
|
+
- master
|
26
|
+
jobs:
|
27
|
+
codecov:
|
28
|
+
runs-on: ubuntu-22.04
|
29
|
+
steps:
|
30
|
+
- uses: actions/checkout@v4
|
31
|
+
- uses: ruby/setup-ruby@v1
|
32
|
+
with:
|
33
|
+
ruby-version: 3.2
|
34
|
+
bundler-cache: true
|
35
|
+
- run: bundle install
|
36
|
+
- run: bundle exec rake
|
37
|
+
- uses: codecov/codecov-action@v4.0.0-beta.3
|
38
|
+
with:
|
39
|
+
token: ${{ secrets.CODECOV_TOKEN }}
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# Copyright (c) 2024 Yegor Bugayenko
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in all
|
11
|
+
# copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
# SOFTWARE.
|
20
|
+
---
|
21
|
+
name: license
|
22
|
+
'on':
|
23
|
+
push:
|
24
|
+
branches:
|
25
|
+
- master
|
26
|
+
pull_request:
|
27
|
+
branches:
|
28
|
+
- master
|
29
|
+
jobs:
|
30
|
+
license:
|
31
|
+
runs-on: ubuntu-22.04
|
32
|
+
steps:
|
33
|
+
- uses: actions/checkout@v4
|
34
|
+
- shell: bash
|
35
|
+
run: |
|
36
|
+
header="Copyright (c) $(date +%Y) Yegor Bugayenko"
|
37
|
+
failed="false"
|
38
|
+
while IFS= read -r file; do
|
39
|
+
if ! grep -q "${header}" "${file}"; then
|
40
|
+
failed="true"
|
41
|
+
echo "⚠️ Copyright header is not found in: ${file}"
|
42
|
+
else
|
43
|
+
echo "File looks good: ${file}"
|
44
|
+
fi
|
45
|
+
done < <(find . -type f \( \
|
46
|
+
-name "Dockerfile" -o \
|
47
|
+
-name "LICENSE.txt" -o \
|
48
|
+
-name "Makefile" -o \
|
49
|
+
-name "Rakefile" -o \
|
50
|
+
-name "*.sh" -o \
|
51
|
+
-name "*.rb" -o \
|
52
|
+
-name "*.fe" -o \
|
53
|
+
-name "*.yml" \
|
54
|
+
\) -print)
|
55
|
+
if [ "${failed}" = "true" ]; then
|
56
|
+
exit 1
|
57
|
+
fi
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# Copyright (c) 2024 Yegor Bugayenko
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in all
|
11
|
+
# copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
# SOFTWARE.
|
20
|
+
---
|
21
|
+
name: markdown-lint
|
22
|
+
'on':
|
23
|
+
push:
|
24
|
+
branches:
|
25
|
+
- master
|
26
|
+
pull_request:
|
27
|
+
branches:
|
28
|
+
- master
|
29
|
+
paths-ignore: ['paper/**', 'sandbox/**']
|
30
|
+
concurrency:
|
31
|
+
group: markdown-lint-${{ github.ref }}
|
32
|
+
cancel-in-progress: true
|
33
|
+
jobs:
|
34
|
+
markdown-lint:
|
35
|
+
runs-on: ubuntu-22.04
|
36
|
+
steps:
|
37
|
+
- uses: actions/checkout@v4
|
38
|
+
- uses: articulate/actions-markdownlint@v1
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# Copyright (c) 2024 Yegor Bugayenko
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in all
|
11
|
+
# copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
# SOFTWARE.
|
20
|
+
---
|
21
|
+
name: pdd
|
22
|
+
on:
|
23
|
+
push:
|
24
|
+
branches:
|
25
|
+
- master
|
26
|
+
pull_request:
|
27
|
+
branches:
|
28
|
+
- master
|
29
|
+
jobs:
|
30
|
+
pdd:
|
31
|
+
runs-on: ubuntu-22.04
|
32
|
+
steps:
|
33
|
+
- uses: actions/checkout@v4
|
34
|
+
- uses: volodya-lombrozo/pdd-action@master
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# Copyright (c) 2024 Yegor Bugayenko
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in all
|
11
|
+
# copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
# SOFTWARE.
|
20
|
+
---
|
21
|
+
name: rake
|
22
|
+
on:
|
23
|
+
push:
|
24
|
+
branches:
|
25
|
+
- master
|
26
|
+
pull_request:
|
27
|
+
branches:
|
28
|
+
- master
|
29
|
+
jobs:
|
30
|
+
rake:
|
31
|
+
name: test
|
32
|
+
strategy:
|
33
|
+
matrix:
|
34
|
+
os: [ubuntu-20.04, macos-12, windows-2022]
|
35
|
+
ruby: [3.2]
|
36
|
+
runs-on: ${{ matrix.os }}
|
37
|
+
steps:
|
38
|
+
- uses: actions/checkout@v4
|
39
|
+
- uses: ruby/setup-ruby@v1
|
40
|
+
with:
|
41
|
+
ruby-version: ${{ matrix.ruby }}
|
42
|
+
bundler-cache: true
|
43
|
+
- run: bundle install
|
44
|
+
- run: bundle exec rake
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# Copyright (c) 2024 Yegor Bugayenko
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in all
|
11
|
+
# copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
# SOFTWARE.
|
20
|
+
---
|
21
|
+
name: xcop
|
22
|
+
on:
|
23
|
+
push:
|
24
|
+
pull_request:
|
25
|
+
jobs:
|
26
|
+
xcop:
|
27
|
+
runs-on: ubuntu-22.04
|
28
|
+
steps:
|
29
|
+
- uses: actions/checkout@v4
|
30
|
+
- uses: g4s8/xcop-action@master
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# Copyright (c) 2024 Yegor Bugayenko
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in all
|
11
|
+
# copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
# SOFTWARE.
|
20
|
+
---
|
21
|
+
name: yamllint
|
22
|
+
'on':
|
23
|
+
push:
|
24
|
+
branches:
|
25
|
+
- master
|
26
|
+
pull_request:
|
27
|
+
branches:
|
28
|
+
- master
|
29
|
+
jobs:
|
30
|
+
yamllint:
|
31
|
+
runs-on: ubuntu-22.04
|
32
|
+
steps:
|
33
|
+
- uses: actions/checkout@v4
|
34
|
+
- uses: ibiqlik/action-yamllint@v3
|
data/.gitignore
ADDED
data/.pdd
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# Copyright (c) 2024 Yegor Bugayenko
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in all
|
11
|
+
# copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
# SOFTWARE.
|
20
|
+
---
|
21
|
+
AllCops:
|
22
|
+
Exclude:
|
23
|
+
- 'bin/**/*'
|
24
|
+
- 'assets/**/*'
|
25
|
+
- 'vendor/**/*'
|
26
|
+
DisplayCopNames: true
|
27
|
+
TargetRubyVersion: 3.2
|
28
|
+
SuggestExtensions: false
|
29
|
+
NewCops: enable
|
30
|
+
|
31
|
+
Layout/EndOfLine:
|
32
|
+
EnforcedStyle: lf
|
33
|
+
Style/EvalWithLocation:
|
34
|
+
Enabled: false
|
35
|
+
Metrics/MethodLength:
|
36
|
+
Enabled: false
|
37
|
+
Metrics/AbcSize:
|
38
|
+
Enabled: false
|
39
|
+
Metrics/CyclomaticComplexity:
|
40
|
+
Enabled: false
|
41
|
+
Metrics/PerceivedComplexity:
|
42
|
+
Enabled: false
|
data/.rultor.yml
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# Copyright (c) 2024 Yegor Bugayenko
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in all
|
11
|
+
# copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
# SOFTWARE.
|
20
|
+
---
|
21
|
+
docker:
|
22
|
+
image: yegor256/rultor-image:1.23.1
|
23
|
+
assets:
|
24
|
+
rubygems.yml: yegor256/home#assets/rubygems.yml
|
25
|
+
install: |
|
26
|
+
pdd -f /dev/null
|
27
|
+
bundle install --no-color
|
28
|
+
release:
|
29
|
+
pre: false
|
30
|
+
script: |-
|
31
|
+
[[ "${tag}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || exit -1
|
32
|
+
bundle exec rake
|
33
|
+
rm -rf *.gem
|
34
|
+
sed -i "s/0\.0\.0/${tag}/g" elapsed.gemspec
|
35
|
+
git add elapsed.gemspec
|
36
|
+
sed -i "s/0\.0\.0/${tag}/g" lib/elapsed.rb
|
37
|
+
git add lib/elapsed.rb
|
38
|
+
git commit -m "version set to ${tag}"
|
39
|
+
gem build elapsed.gemspec
|
40
|
+
chmod 0600 ../rubygems.yml
|
41
|
+
gem push *.gem --config-file ../rubygems.yml
|
42
|
+
merge:
|
43
|
+
script: |-
|
44
|
+
bundle exec rake
|
data/.simplecov
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Copyright (c) 2024 Yegor Bugayenko
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be included in all
|
14
|
+
# copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
# SOFTWARE.
|
23
|
+
|
24
|
+
if Gem.win_platform?
|
25
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
26
|
+
SimpleCov::Formatter::HTMLFormatter
|
27
|
+
]
|
28
|
+
SimpleCov.start do
|
29
|
+
add_filter '/test/'
|
30
|
+
add_filter '/features/'
|
31
|
+
end
|
32
|
+
else
|
33
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
|
34
|
+
[SimpleCov::Formatter::HTMLFormatter]
|
35
|
+
)
|
36
|
+
SimpleCov.start do
|
37
|
+
add_filter '/test/'
|
38
|
+
add_filter '/features/'
|
39
|
+
minimum_coverage 20
|
40
|
+
end
|
41
|
+
end
|
data/Gemfile
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (c) 2024 Yegor Bugayenko
|
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.
|
22
|
+
|
23
|
+
source 'https://rubygems.org'
|
24
|
+
gemspec
|
25
|
+
|
26
|
+
gem 'minitest', '5.25.0', require: false
|
27
|
+
gem 'rake', '13.2.1', require: false
|
28
|
+
gem 'rspec-rails', '6.1.3', require: false
|
29
|
+
gem 'rubocop', '1.65.1', require: false
|
30
|
+
gem 'rubocop-rspec', '3.0.4', require: false
|
31
|
+
gem 'simplecov', '0.22.0', require: false
|
32
|
+
gem 'simplecov-cobertura', '2.1.0', require: false
|
33
|
+
gem 'yard', '0.9.36', require: false
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,193 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
elapsed (0.0.0)
|
5
|
+
loog (> 0)
|
6
|
+
tago (> 0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actionpack (7.2.0)
|
12
|
+
actionview (= 7.2.0)
|
13
|
+
activesupport (= 7.2.0)
|
14
|
+
nokogiri (>= 1.8.5)
|
15
|
+
racc
|
16
|
+
rack (>= 2.2.4, < 3.2)
|
17
|
+
rack-session (>= 1.0.1)
|
18
|
+
rack-test (>= 0.6.3)
|
19
|
+
rails-dom-testing (~> 2.2)
|
20
|
+
rails-html-sanitizer (~> 1.6)
|
21
|
+
useragent (~> 0.16)
|
22
|
+
actionview (7.2.0)
|
23
|
+
activesupport (= 7.2.0)
|
24
|
+
builder (~> 3.1)
|
25
|
+
erubi (~> 1.11)
|
26
|
+
rails-dom-testing (~> 2.2)
|
27
|
+
rails-html-sanitizer (~> 1.6)
|
28
|
+
activesupport (7.2.0)
|
29
|
+
base64
|
30
|
+
bigdecimal
|
31
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
32
|
+
connection_pool (>= 2.2.5)
|
33
|
+
drb
|
34
|
+
i18n (>= 1.6, < 2)
|
35
|
+
logger (>= 1.4.2)
|
36
|
+
minitest (>= 5.1)
|
37
|
+
securerandom (>= 0.3)
|
38
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
39
|
+
ast (2.4.2)
|
40
|
+
base64 (0.2.0)
|
41
|
+
bigdecimal (3.1.8)
|
42
|
+
builder (3.3.0)
|
43
|
+
concurrent-ruby (1.3.4)
|
44
|
+
connection_pool (2.4.1)
|
45
|
+
crass (1.0.6)
|
46
|
+
diff-lcs (1.5.1)
|
47
|
+
docile (1.4.1)
|
48
|
+
drb (2.2.1)
|
49
|
+
erubi (1.13.0)
|
50
|
+
i18n (1.14.5)
|
51
|
+
concurrent-ruby (~> 1.0)
|
52
|
+
io-console (0.7.2)
|
53
|
+
irb (1.14.0)
|
54
|
+
rdoc (>= 4.0.0)
|
55
|
+
reline (>= 0.4.2)
|
56
|
+
json (2.7.2)
|
57
|
+
language_server-protocol (3.17.0.3)
|
58
|
+
logger (1.6.0)
|
59
|
+
loofah (2.22.0)
|
60
|
+
crass (~> 1.0.2)
|
61
|
+
nokogiri (>= 1.12.0)
|
62
|
+
loog (0.6.0)
|
63
|
+
minitest (5.25.0)
|
64
|
+
nokogiri (1.16.7-aarch64-linux)
|
65
|
+
racc (~> 1.4)
|
66
|
+
nokogiri (1.16.7-arm-linux)
|
67
|
+
racc (~> 1.4)
|
68
|
+
nokogiri (1.16.7-arm64-darwin)
|
69
|
+
racc (~> 1.4)
|
70
|
+
nokogiri (1.16.7-x64-mingw-ucrt)
|
71
|
+
racc (~> 1.4)
|
72
|
+
nokogiri (1.16.7-x86-linux)
|
73
|
+
racc (~> 1.4)
|
74
|
+
nokogiri (1.16.7-x86_64-darwin)
|
75
|
+
racc (~> 1.4)
|
76
|
+
nokogiri (1.16.7-x86_64-linux)
|
77
|
+
racc (~> 1.4)
|
78
|
+
parallel (1.26.2)
|
79
|
+
parser (3.3.4.2)
|
80
|
+
ast (~> 2.4.1)
|
81
|
+
racc
|
82
|
+
psych (5.1.2)
|
83
|
+
stringio
|
84
|
+
racc (1.8.1)
|
85
|
+
rack (3.1.7)
|
86
|
+
rack-session (2.0.0)
|
87
|
+
rack (>= 3.0.0)
|
88
|
+
rack-test (2.1.0)
|
89
|
+
rack (>= 1.3)
|
90
|
+
rackup (2.1.0)
|
91
|
+
rack (>= 3)
|
92
|
+
webrick (~> 1.8)
|
93
|
+
rails-dom-testing (2.2.0)
|
94
|
+
activesupport (>= 5.0.0)
|
95
|
+
minitest
|
96
|
+
nokogiri (>= 1.6)
|
97
|
+
rails-html-sanitizer (1.6.0)
|
98
|
+
loofah (~> 2.21)
|
99
|
+
nokogiri (~> 1.14)
|
100
|
+
railties (7.2.0)
|
101
|
+
actionpack (= 7.2.0)
|
102
|
+
activesupport (= 7.2.0)
|
103
|
+
irb (~> 1.13)
|
104
|
+
rackup (>= 1.0.0)
|
105
|
+
rake (>= 12.2)
|
106
|
+
thor (~> 1.0, >= 1.2.2)
|
107
|
+
zeitwerk (~> 2.6)
|
108
|
+
rainbow (3.1.1)
|
109
|
+
rake (13.2.1)
|
110
|
+
rdoc (6.7.0)
|
111
|
+
psych (>= 4.0.0)
|
112
|
+
regexp_parser (2.9.2)
|
113
|
+
reline (0.5.9)
|
114
|
+
io-console (~> 0.5)
|
115
|
+
rexml (3.3.5)
|
116
|
+
strscan
|
117
|
+
rspec-core (3.13.0)
|
118
|
+
rspec-support (~> 3.13.0)
|
119
|
+
rspec-expectations (3.13.1)
|
120
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
121
|
+
rspec-support (~> 3.13.0)
|
122
|
+
rspec-mocks (3.13.1)
|
123
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
124
|
+
rspec-support (~> 3.13.0)
|
125
|
+
rspec-rails (6.1.3)
|
126
|
+
actionpack (>= 6.1)
|
127
|
+
activesupport (>= 6.1)
|
128
|
+
railties (>= 6.1)
|
129
|
+
rspec-core (~> 3.13)
|
130
|
+
rspec-expectations (~> 3.13)
|
131
|
+
rspec-mocks (~> 3.13)
|
132
|
+
rspec-support (~> 3.13)
|
133
|
+
rspec-support (3.13.1)
|
134
|
+
rubocop (1.65.1)
|
135
|
+
json (~> 2.3)
|
136
|
+
language_server-protocol (>= 3.17.0)
|
137
|
+
parallel (~> 1.10)
|
138
|
+
parser (>= 3.3.0.2)
|
139
|
+
rainbow (>= 2.2.2, < 4.0)
|
140
|
+
regexp_parser (>= 2.4, < 3.0)
|
141
|
+
rexml (>= 3.2.5, < 4.0)
|
142
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
143
|
+
ruby-progressbar (~> 1.7)
|
144
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
145
|
+
rubocop-ast (1.32.0)
|
146
|
+
parser (>= 3.3.1.0)
|
147
|
+
rubocop-rspec (3.0.4)
|
148
|
+
rubocop (~> 1.61)
|
149
|
+
ruby-progressbar (1.13.0)
|
150
|
+
securerandom (0.3.1)
|
151
|
+
simplecov (0.22.0)
|
152
|
+
docile (~> 1.1)
|
153
|
+
simplecov-html (~> 0.11)
|
154
|
+
simplecov_json_formatter (~> 0.1)
|
155
|
+
simplecov-cobertura (2.1.0)
|
156
|
+
rexml
|
157
|
+
simplecov (~> 0.19)
|
158
|
+
simplecov-html (0.12.3)
|
159
|
+
simplecov_json_formatter (0.1.4)
|
160
|
+
stringio (3.1.1)
|
161
|
+
strscan (3.1.0)
|
162
|
+
tago (0.0.2)
|
163
|
+
thor (1.3.1)
|
164
|
+
tzinfo (2.0.6)
|
165
|
+
concurrent-ruby (~> 1.0)
|
166
|
+
unicode-display_width (2.5.0)
|
167
|
+
useragent (0.16.10)
|
168
|
+
webrick (1.8.1)
|
169
|
+
yard (0.9.36)
|
170
|
+
zeitwerk (2.6.17)
|
171
|
+
|
172
|
+
PLATFORMS
|
173
|
+
aarch64-linux
|
174
|
+
arm-linux
|
175
|
+
arm64-darwin
|
176
|
+
x64-mingw-ucrt
|
177
|
+
x86-linux
|
178
|
+
x86_64-darwin
|
179
|
+
x86_64-linux
|
180
|
+
|
181
|
+
DEPENDENCIES
|
182
|
+
elapsed!
|
183
|
+
minitest (= 5.25.0)
|
184
|
+
rake (= 13.2.1)
|
185
|
+
rspec-rails (= 6.1.3)
|
186
|
+
rubocop (= 1.65.1)
|
187
|
+
rubocop-rspec (= 3.0.4)
|
188
|
+
simplecov (= 0.22.0)
|
189
|
+
simplecov-cobertura (= 2.1.0)
|
190
|
+
yard (= 0.9.36)
|
191
|
+
|
192
|
+
BUNDLED WITH
|
193
|
+
2.5.16
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
(The MIT License)
|
2
|
+
|
3
|
+
Copyright (c) 2024 Yegor Bugayenko
|
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,67 @@
|
|
1
|
+
# Measures the Time Elapsed by a Block
|
2
|
+
|
3
|
+
[![DevOps By Rultor.com](http://www.rultor.com/b/yegor256/elapsed)](http://www.rultor.com/p/yegor256/elapsed)
|
4
|
+
[![We recommend RubyMine](https://www.elegantobjects.org/rubymine.svg)](https://www.jetbrains.com/ruby/)
|
5
|
+
|
6
|
+
[![rake](https://github.com/yegor256/elapsed/actions/workflows/rake.yml/badge.svg)](https://github.com/yegor256/elapsed/actions/workflows/rake.yml)
|
7
|
+
[![PDD status](http://www.0pdd.com/svg?name=yegor256/elapsed)](http://www.0pdd.com/p?name=yegor256/elapsed)
|
8
|
+
[![Gem Version](https://badge.fury.io/rb/elapsed.svg)](http://badge.fury.io/rb/elapsed)
|
9
|
+
[![Test Coverage](https://img.shields.io/codecov/c/github/yegor256/elapsed.svg)](https://codecov.io/github/yegor256/elapsed?branch=master)
|
10
|
+
[![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](http://rubydoc.info/github/yegor256/elapsed/master/frames)
|
11
|
+
[![Hits-of-Code](https://hitsofcode.com/github/yegor256/elapsed)](https://hitsofcode.com/view/github/yegor256/elapsed)
|
12
|
+
[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/yegor256/elapsed/blob/master/LICENSE.txt)
|
13
|
+
|
14
|
+
Here is how you can measure and log the time of a block:
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
require 'elapsed'
|
18
|
+
elapsed do
|
19
|
+
run_something_slow
|
20
|
+
end
|
21
|
+
```
|
22
|
+
|
23
|
+
You can also send the log message to a log, for example to the
|
24
|
+
[Loog](https://github.com/yegor256/loog):
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
require 'elapsed'
|
28
|
+
require 'loog'
|
29
|
+
elapsed(Loog::VERBOSE) do
|
30
|
+
# any code
|
31
|
+
end
|
32
|
+
```
|
33
|
+
|
34
|
+
You can also make the message custom:
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
elapsed(intro: 'File saved') do
|
38
|
+
File.save(f, 'Hello, world!')
|
39
|
+
end
|
40
|
+
```
|
41
|
+
|
42
|
+
Or, you can make the message even more custom:
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
elapsed do
|
46
|
+
File.save(f, 'Hello, world!')
|
47
|
+
throw :"Successfully saved #{File.size(f)} bytes"
|
48
|
+
end
|
49
|
+
```
|
50
|
+
|
51
|
+
That's it.
|
52
|
+
|
53
|
+
## How to contribute
|
54
|
+
|
55
|
+
Read
|
56
|
+
[these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).
|
57
|
+
Make sure you build is green before you contribute
|
58
|
+
your pull request. You will need to have
|
59
|
+
[Ruby](https://www.ruby-lang.org/en/) 3.0+ and
|
60
|
+
[Bundler](https://bundler.io/) installed. Then:
|
61
|
+
|
62
|
+
```bash
|
63
|
+
bundle update
|
64
|
+
bundle exec rake
|
65
|
+
```
|
66
|
+
|
67
|
+
If it's clean and you don't see any error messages, submit your pull request.
|
data/Rakefile
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (c) 2024 Yegor Bugayenko
|
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.
|
22
|
+
|
23
|
+
require 'rubygems'
|
24
|
+
require 'rake'
|
25
|
+
require 'rdoc'
|
26
|
+
require 'rake/clean'
|
27
|
+
|
28
|
+
def name
|
29
|
+
@name ||= File.basename(Dir['*.gemspec'].first, '.*')
|
30
|
+
end
|
31
|
+
|
32
|
+
def version
|
33
|
+
Gem::Specification.load(Dir['*.gemspec'].first).version
|
34
|
+
end
|
35
|
+
|
36
|
+
task default: %i[clean test rubocop yard copyright]
|
37
|
+
|
38
|
+
require 'rake/testtask'
|
39
|
+
desc 'Run all unit tests'
|
40
|
+
Rake::TestTask.new(:test) do |test|
|
41
|
+
Rake::Cleaner.cleanup_files(['coverage'])
|
42
|
+
test.libs << 'lib' << 'test'
|
43
|
+
test.pattern = 'test/**/test_*.rb'
|
44
|
+
test.warning = true
|
45
|
+
test.verbose = false
|
46
|
+
end
|
47
|
+
|
48
|
+
require 'yard'
|
49
|
+
desc 'Build Yard documentation'
|
50
|
+
YARD::Rake::YardocTask.new do |t|
|
51
|
+
t.files = ['lib/**/*.rb']
|
52
|
+
end
|
53
|
+
|
54
|
+
require 'rubocop/rake_task'
|
55
|
+
desc 'Run RuboCop on all directories'
|
56
|
+
RuboCop::RakeTask.new(:rubocop) do |task|
|
57
|
+
task.fail_on_error = true
|
58
|
+
task.requires << 'rubocop-rspec'
|
59
|
+
end
|
60
|
+
|
61
|
+
task :copyright do
|
62
|
+
sh "grep -q -r '#{Date.today.strftime('%Y')}' \
|
63
|
+
--include '*.rb' \
|
64
|
+
--include '*.yml' \
|
65
|
+
--include '*.txt' \
|
66
|
+
--include 'Rakefile' \
|
67
|
+
."
|
68
|
+
end
|
data/elapsed.gemspec
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (c) 2024 Yegor Bugayenko
|
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.
|
22
|
+
|
23
|
+
require 'English'
|
24
|
+
|
25
|
+
Gem::Specification.new do |s|
|
26
|
+
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
|
27
|
+
s.required_ruby_version = '>=3.2'
|
28
|
+
s.name = 'elapsed'
|
29
|
+
s.version = '0.0.1'
|
30
|
+
s.license = 'MIT'
|
31
|
+
s.summary = 'A simple Ruby function to measure the time elapsed by the execution of a block'
|
32
|
+
s.description =
|
33
|
+
'You simply pass a code block to the elapsed() function and it will ' \
|
34
|
+
'print the summary of execution to the log with the time it took'
|
35
|
+
s.authors = ['Yegor Bugayenko']
|
36
|
+
s.email = 'yegor256@gmail.com'
|
37
|
+
s.homepage = 'http://github.com/yegor256/elapsed'
|
38
|
+
s.files = `git ls-files`.split($RS)
|
39
|
+
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
40
|
+
s.rdoc_options = ['--charset=UTF-8']
|
41
|
+
s.extra_rdoc_files = ['README.md', 'LICENSE.txt']
|
42
|
+
s.add_dependency 'loog', '>0'
|
43
|
+
s.add_dependency 'tago', '>0'
|
44
|
+
s.metadata['rubygems_mfa_required'] = 'true'
|
45
|
+
end
|
data/lib/elapsed.rb
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (c) 2024 Yegor Bugayenko
|
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.
|
22
|
+
|
23
|
+
require 'logger'
|
24
|
+
require 'tago'
|
25
|
+
|
26
|
+
# The function measures the time taked by a block to execute and then prints
|
27
|
+
# it to the log.
|
28
|
+
#
|
29
|
+
# require 'elapsed'
|
30
|
+
# elapsed(log) do
|
31
|
+
# do_something_slow
|
32
|
+
# throw 'It was completed'
|
33
|
+
# end
|
34
|
+
#
|
35
|
+
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
36
|
+
# Copyright:: Copyright (c) 2024 Yegor Bugayenko
|
37
|
+
# License:: MIT
|
38
|
+
#
|
39
|
+
# @param [Object] log The log to send .debug() to
|
40
|
+
# @param [String] intro The message to start with
|
41
|
+
# @param [Integer] level The level of logging to use
|
42
|
+
def elapsed(log = nil, intro: 'Finished', level: Logger::DEBUG)
|
43
|
+
start = Time.now
|
44
|
+
begin
|
45
|
+
ret = yield
|
46
|
+
msg = intro.to_s
|
47
|
+
msg += " in #{start.ago}"
|
48
|
+
if log.nil?
|
49
|
+
puts msg
|
50
|
+
elsif level == Logger::DEBUG
|
51
|
+
log.debug(msg)
|
52
|
+
elsif level == Logger::INFO
|
53
|
+
log.info(msg)
|
54
|
+
else
|
55
|
+
log.warn(msg)
|
56
|
+
end
|
57
|
+
ret
|
58
|
+
rescue UncaughtThrowError => e
|
59
|
+
tag = e.tag
|
60
|
+
throw e unless tag.is_a?(Symbol)
|
61
|
+
msg = "#{tag} in #{start.ago}"
|
62
|
+
if log.nil?
|
63
|
+
puts msg
|
64
|
+
elsif level == Logger::DEBUG
|
65
|
+
log.debug(msg)
|
66
|
+
elsif level == Logger::INFO
|
67
|
+
log.info(msg)
|
68
|
+
else
|
69
|
+
log.warn(msg)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
data/renovate.json
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (c) 2024 Yegor Bugayenko
|
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.
|
22
|
+
|
23
|
+
$stdout.sync = true
|
24
|
+
|
25
|
+
require 'simplecov'
|
26
|
+
SimpleCov.start
|
27
|
+
|
28
|
+
require 'simplecov-cobertura'
|
29
|
+
SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter
|
30
|
+
|
31
|
+
require 'minitest/autorun'
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (c) 2024 Yegor Bugayenko
|
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.
|
22
|
+
|
23
|
+
require 'minitest/autorun'
|
24
|
+
require 'loog'
|
25
|
+
require_relative '../lib/elapsed'
|
26
|
+
|
27
|
+
# Test.
|
28
|
+
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
29
|
+
# Copyright:: Copyright (c) 2024 Yegor Bugayenko
|
30
|
+
# License:: MIT
|
31
|
+
class TestElapsed < Minitest::Test
|
32
|
+
def test_simple
|
33
|
+
loog = Loog::Buffer.new
|
34
|
+
r =
|
35
|
+
elapsed(loog, intro: 'Everything was good') do
|
36
|
+
4 + 5
|
37
|
+
end
|
38
|
+
assert_equal(9, r)
|
39
|
+
assert(loog.to_s.include?('was good'))
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_with_throw
|
43
|
+
loog = Loog::Buffer.new
|
44
|
+
elapsed(loog) do
|
45
|
+
throw :'Perfectly works'
|
46
|
+
end
|
47
|
+
assert(loog.to_s.include?('works'))
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_to_stdout
|
51
|
+
elapsed do
|
52
|
+
4 + 5
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: elapsed
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yegor Bugayenko
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-08-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: loog
|
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: tago
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: You simply pass a code block to the elapsed() function and it will print
|
42
|
+
the summary of execution to the log with the time it took
|
43
|
+
email: yegor256@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files:
|
47
|
+
- README.md
|
48
|
+
- LICENSE.txt
|
49
|
+
files:
|
50
|
+
- ".0pdd.yml"
|
51
|
+
- ".gitattributes"
|
52
|
+
- ".github/workflows/actionlint.yml"
|
53
|
+
- ".github/workflows/codecov.yml"
|
54
|
+
- ".github/workflows/license.yml"
|
55
|
+
- ".github/workflows/markdown-lint.yml"
|
56
|
+
- ".github/workflows/pdd.yml"
|
57
|
+
- ".github/workflows/rake.yml"
|
58
|
+
- ".github/workflows/xcop.yml"
|
59
|
+
- ".github/workflows/yamllint.yml"
|
60
|
+
- ".gitignore"
|
61
|
+
- ".pdd"
|
62
|
+
- ".rubocop.yml"
|
63
|
+
- ".rultor.yml"
|
64
|
+
- ".simplecov"
|
65
|
+
- Gemfile
|
66
|
+
- Gemfile.lock
|
67
|
+
- LICENSE.txt
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- elapsed.gemspec
|
71
|
+
- lib/elapsed.rb
|
72
|
+
- renovate.json
|
73
|
+
- test/test__helper.rb
|
74
|
+
- test/test_elapsed.rb
|
75
|
+
homepage: http://github.com/yegor256/elapsed
|
76
|
+
licenses:
|
77
|
+
- MIT
|
78
|
+
metadata:
|
79
|
+
rubygems_mfa_required: 'true'
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options:
|
82
|
+
- "--charset=UTF-8"
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.2'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
requirements: []
|
96
|
+
rubygems_version: 3.4.10
|
97
|
+
signing_key:
|
98
|
+
specification_version: 4
|
99
|
+
summary: A simple Ruby function to measure the time elapsed by the execution of a
|
100
|
+
block
|
101
|
+
test_files: []
|