others 0.0.3 → 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.
data/test/test__helper.rb CHANGED
@@ -1,31 +1,29 @@
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
  $stdout.sync = true
24
7
 
25
8
  require 'simplecov'
26
- SimpleCov.start
27
-
28
9
  require 'simplecov-cobertura'
29
- SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter
10
+ unless SimpleCov.running
11
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
12
+ [
13
+ SimpleCov::Formatter::HTMLFormatter,
14
+ SimpleCov::Formatter::CoberturaFormatter
15
+ ]
16
+ )
17
+ SimpleCov.minimum_coverage 85
18
+ SimpleCov.minimum_coverage_by_file 85
19
+ SimpleCov.start do
20
+ add_filter 'test/'
21
+ add_filter 'vendor/'
22
+ add_filter 'target/'
23
+ track_files 'lib/**/*.rb'
24
+ end
25
+ end
30
26
 
31
27
  require 'minitest/autorun'
28
+ require 'minitest/reporters'
29
+ Minitest::Reporters.use! [Minitest::Reporters::SpecReporter.new]
data/test/test_others.rb CHANGED
@@ -1,31 +1,14 @@
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
- require 'minitest/autorun'
6
+ require_relative 'test__helper'
24
7
  require_relative '../lib/others'
25
8
 
26
9
  # Others main module test.
27
10
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
28
- # Copyright:: Copyright (c) 2024 Yegor Bugayenko
11
+ # Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
29
12
  # License:: MIT
30
13
  class TestOthers < Minitest::Test
31
14
  def test_as_function
@@ -45,21 +28,30 @@ class TestOthers < Minitest::Test
45
28
  end
46
29
  end
47
30
  x.foo = 42
31
+ assert_respond_to(x, :foo)
48
32
  assert_equal(42, x.foo)
49
33
  end
50
34
 
51
35
  def test_as_function_with_args
52
36
  x = others(foo: 42) do |*args|
37
+ raise "Must be just two arg here, given: #{args}" unless args.size == 2
53
38
  @foo + args[1]
54
39
  end
55
40
  assert_equal(97, x.bar(55))
56
41
  end
57
42
 
43
+ def test_with_block
44
+ x = others(foo: 42) do |*args|
45
+ @foo + args.last.call
46
+ end
47
+ assert_equal(55, x.bar { 13 })
48
+ end
49
+
58
50
  def test_as_function_with_block
59
51
  x = others(foo: 42) do
60
52
  yield 42
61
53
  end
62
- assert_raises do
54
+ assert_raises(StandardError) do
63
55
  x.bar { |i| i + 1 }
64
56
  end
65
57
  end
@@ -70,14 +62,26 @@ class TestOthers < Minitest::Test
70
62
  abc + 1
71
63
  end
72
64
  others do |*args|
65
+ raise "Must be just two arg here, given: #{args}" unless args.size == 2
73
66
  args[1] + 2
74
67
  end
75
68
  end
76
69
  x = cx.new
70
+ assert_respond_to(x, :foo)
77
71
  assert_equal(43, x.foo(42))
78
72
  assert_equal(44, x.bar(42))
79
73
  end
80
74
 
75
+ def test_as_class_with_block
76
+ cx = Class.new do
77
+ others do |*args|
78
+ args[1] + args.last.call
79
+ end
80
+ end
81
+ x = cx.new
82
+ assert_equal(53, x.foo(42) { 11 })
83
+ end
84
+
81
85
  def test_as_class_setter
82
86
  cx = Class.new do
83
87
  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.1
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