others 0.0.3 → 0.1.0

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.
data/test/test_others.rb CHANGED
@@ -1,31 +1,15 @@
1
1
  # frozen_string_literal: true
2
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 NONINFINGEMENT. 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.
3
+ # SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
4
+ # SPDX-License-Identifier: MIT
22
5
 
23
6
  require 'minitest/autorun'
24
7
  require_relative '../lib/others'
8
+ require_relative 'test__helper'
25
9
 
26
10
  # Others main module test.
27
11
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
28
- # Copyright:: Copyright (c) 2024 Yegor Bugayenko
12
+ # Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
29
13
  # License:: MIT
30
14
  class TestOthers < Minitest::Test
31
15
  def test_as_function
@@ -55,11 +39,18 @@ class TestOthers < Minitest::Test
55
39
  assert_equal(97, x.bar(55))
56
40
  end
57
41
 
42
+ def test_with_block
43
+ x = others(foo: 42) do |*args|
44
+ @foo + args.last.call
45
+ end
46
+ assert_equal(55, x.bar { 13 })
47
+ end
48
+
58
49
  def test_as_function_with_block
59
50
  x = others(foo: 42) do
60
51
  yield 42
61
52
  end
62
- assert_raises do
53
+ assert_raises(StandardError) do
63
54
  x.bar { |i| i + 1 }
64
55
  end
65
56
  end
@@ -78,6 +69,16 @@ class TestOthers < Minitest::Test
78
69
  assert_equal(44, x.bar(42))
79
70
  end
80
71
 
72
+ def test_as_class_with_block
73
+ cx = Class.new do
74
+ others do |*args|
75
+ args[1] + args.last.call
76
+ end
77
+ end
78
+ x = cx.new
79
+ assert_equal(53, x.foo(42) { 11 })
80
+ end
81
+
81
82
  def test_as_class_setter
82
83
  cx = Class.new do
83
84
  def initialize(map)
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: others
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-06-24 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies: []
13
12
  description: |-
14
13
  A primitive gem that helps you decorate an object or turn an existing
@@ -19,8 +18,8 @@ email: yegor256@gmail.com
19
18
  executables: []
20
19
  extensions: []
21
20
  extra_rdoc_files:
22
- - README.md
23
21
  - LICENSE.txt
22
+ - README.md
24
23
  files:
25
24
  - ".0pdd.yml"
26
25
  - ".gitattributes"
@@ -30,18 +29,21 @@ files:
30
29
  - ".github/workflows/markdown-lint.yml"
31
30
  - ".github/workflows/pdd.yml"
32
31
  - ".github/workflows/rake.yml"
32
+ - ".github/workflows/reuse.yml"
33
+ - ".github/workflows/typos.yml"
33
34
  - ".github/workflows/xcop.yml"
34
35
  - ".github/workflows/yamllint.yml"
35
36
  - ".gitignore"
36
37
  - ".pdd"
37
38
  - ".rubocop.yml"
38
39
  - ".rultor.yml"
39
- - ".simplecov"
40
40
  - ".yamllint.yml"
41
41
  - Gemfile
42
42
  - Gemfile.lock
43
43
  - LICENSE.txt
44
+ - LICENSES/MIT.txt
44
45
  - README.md
46
+ - REUSE.toml
45
47
  - Rakefile
46
48
  - lib/others.rb
47
49
  - others.gemspec
@@ -53,7 +55,6 @@ licenses:
53
55
  - MIT
54
56
  metadata:
55
57
  rubygems_mfa_required: 'true'
56
- post_install_message:
57
58
  rdoc_options:
58
59
  - "--charset=UTF-8"
59
60
  require_paths:
@@ -69,8 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
70
  - !ruby/object:Gem::Version
70
71
  version: '0'
71
72
  requirements: []
72
- rubygems_version: 3.4.10
73
- signing_key:
73
+ rubygems_version: 3.6.7
74
74
  specification_version: 4
75
75
  summary: others
76
76
  test_files: []
data/.simplecov DELETED
@@ -1,41 +0,0 @@
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 NONINFINGEMENT. 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