decoor 0.0.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d776917878041e6ae9fff8283e0bb856d134031fd75e7df3add82151d0a6bdd2
4
- data.tar.gz: e7642e9f9febe0efaf121081dbd226f112af1d67c5cf48fe0ec8551c886d7172
3
+ metadata.gz: 0e69b5f78457177d0bf13b43f218b9c75dacc9116423601e61ec408ada491a23
4
+ data.tar.gz: 225ac30d14b4fd8254b5524be6051892a013ccd67078446381b12294e9ea8bc9
5
5
  SHA512:
6
- metadata.gz: '08afdc180df88e606bba313a2f4b51e2b9b62394e58b17c833b45d9bd390fbc7769da8df0b30fdca6b5c0ab07514b5966ee03d6e6da6daaa80c461b3062e8661'
7
- data.tar.gz: e8fb3ec73cdb7f2e56dbd19262970ff75d802287f97d424924c5d2b5962108f2861ce17528bad7eec07e75393be4c4884937447be3cd1e6f691572dca180c384
6
+ metadata.gz: 10b1bd882a7cff4daf8dc55fdd0c7361e82c390adda55d6e917d9ce6d3dc962705cef185880b03bc80935ea48f5cd6e04b54da98a1a1636bada8e720e92f2e31
7
+ data.tar.gz: 4d515a370b8a7521ed15e6c6b81df2170447d0216f7b43fc8bb6ad39ed336cdbc3130a6a5b19e02da95ab0d7afdccc72eadede0425db9e2a5010114849deb60f
data/Gemfile CHANGED
@@ -1,34 +1,19 @@
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 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.
3
+ # SPDX-FileCopyrightText: Copyright (c) 2024-2026 Yegor Bugayenko
4
+ # SPDX-License-Identifier: MIT
22
5
 
23
6
  source 'https://rubygems.org'
24
7
  gemspec
25
8
 
26
- gem 'minitest', '5.24.0', require: false
27
- gem 'rake', '13.2.1', require: false
28
- gem 'rspec-rails', '6.1.3', require: false
29
- gem 'rubocop', '1.64.1', require: false
30
- gem 'rubocop-performance', '1.21.1', require: false
31
- gem 'rubocop-rspec', '3.0.1', require: false
32
- gem 'simplecov', '0.22.0', require: false
33
- gem 'simplecov-cobertura', '2.1.0', require: false
34
- gem 'yard', '0.9.36', require: false
9
+ gem 'minitest', '~>6.0', require: false
10
+ gem 'minitest-reporters', '~>1.7', require: false
11
+ gem 'rake', '~>13.2', require: false
12
+ gem 'rubocop', '~>1.65', require: false
13
+ gem 'rubocop-elegant', '~>0.5', require: false
14
+ gem 'rubocop-minitest', '~>0.38', require: false
15
+ gem 'rubocop-performance', '~>1.0', require: false
16
+ gem 'rubocop-rake', '~>0.7', require: false
17
+ gem 'simplecov', '~>1.0', require: false
18
+ gem 'simplecov-cobertura', '~>4.0', require: false
19
+ gem 'yard', '~>0.9', require: false
data/Gemfile.lock CHANGED
@@ -6,175 +6,99 @@ PATH
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- actionpack (7.1.3.4)
10
- actionview (= 7.1.3.4)
11
- activesupport (= 7.1.3.4)
12
- nokogiri (>= 1.8.5)
13
- racc
14
- rack (>= 2.2.4)
15
- rack-session (>= 1.0.1)
16
- rack-test (>= 0.6.3)
17
- rails-dom-testing (~> 2.2)
18
- rails-html-sanitizer (~> 1.6)
19
- actionview (7.1.3.4)
20
- activesupport (= 7.1.3.4)
21
- builder (~> 3.1)
22
- erubi (~> 1.11)
23
- rails-dom-testing (~> 2.2)
24
- rails-html-sanitizer (~> 1.6)
25
- activesupport (7.1.3.4)
26
- base64
27
- bigdecimal
28
- concurrent-ruby (~> 1.0, >= 1.0.2)
29
- connection_pool (>= 2.2.5)
30
- drb
31
- i18n (>= 1.6, < 2)
32
- minitest (>= 5.1)
33
- mutex_m
34
- tzinfo (~> 2.0)
35
- ast (2.4.2)
36
- base64 (0.2.0)
37
- bigdecimal (3.1.8)
9
+ ansi (1.6.1)
10
+ logger
11
+ ast (2.4.3)
38
12
  builder (3.3.0)
39
- concurrent-ruby (1.3.3)
40
- connection_pool (2.4.1)
41
- crass (1.0.6)
42
- diff-lcs (1.5.1)
43
- docile (1.4.0)
44
- drb (2.2.1)
45
- erubi (1.13.0)
46
- i18n (1.14.5)
47
- concurrent-ruby (~> 1.0)
48
- io-console (0.7.2)
49
- irb (1.13.2)
50
- rdoc (>= 4.0.0)
51
- reline (>= 0.4.2)
52
- json (2.7.2)
53
- language_server-protocol (3.17.0.3)
54
- loofah (2.22.0)
55
- crass (~> 1.0.2)
56
- nokogiri (>= 1.12.0)
57
- minitest (5.24.0)
58
- mutex_m (0.2.0)
59
- nokogiri (1.16.6-arm64-darwin)
60
- racc (~> 1.4)
61
- nokogiri (1.16.6-x64-mingw-ucrt)
62
- racc (~> 1.4)
63
- nokogiri (1.16.6-x86_64-darwin)
64
- racc (~> 1.4)
65
- nokogiri (1.16.6-x86_64-linux)
66
- racc (~> 1.4)
67
- parallel (1.25.1)
68
- parser (3.3.3.0)
13
+ drb (2.2.3)
14
+ json (3.2.0)
15
+ language_server-protocol (3.17.0.6)
16
+ lint_roller (1.1.0)
17
+ logger (1.7.0)
18
+ minitest (6.1.0)
19
+ drb (~> 2.0)
20
+ prism (>= 1.5, < 3)
21
+ minitest-reporters (1.8.0)
22
+ ansi
23
+ builder
24
+ minitest (>= 5.0, < 7)
25
+ ruby-progressbar
26
+ parallel (2.3.0)
27
+ parser (3.3.14.0)
69
28
  ast (~> 2.4.1)
70
29
  racc
71
- psych (5.1.2)
72
- stringio
73
- racc (1.8.0)
74
- rack (3.1.3)
75
- rack-session (2.0.0)
76
- rack (>= 3.0.0)
77
- rack-test (2.1.0)
78
- rack (>= 1.3)
79
- rackup (2.1.0)
80
- rack (>= 3)
81
- webrick (~> 1.8)
82
- rails-dom-testing (2.2.0)
83
- activesupport (>= 5.0.0)
84
- minitest
85
- nokogiri (>= 1.6)
86
- rails-html-sanitizer (1.6.0)
87
- loofah (~> 2.21)
88
- nokogiri (~> 1.14)
89
- railties (7.1.3.4)
90
- actionpack (= 7.1.3.4)
91
- activesupport (= 7.1.3.4)
92
- irb
93
- rackup (>= 1.0.0)
94
- rake (>= 12.2)
95
- thor (~> 1.0, >= 1.2.2)
96
- zeitwerk (~> 2.6)
30
+ prism (2.1.0)
31
+ prism (2.1.0-arm64-darwin)
32
+ prism (2.1.0-x64-mingw-ucrt)
33
+ prism (2.1.0-x86_64-darwin)
34
+ prism (2.1.0-x86_64-linux-gnu)
35
+ racc (1.8.1)
97
36
  rainbow (3.1.1)
98
- rake (13.2.1)
99
- rdoc (6.7.0)
100
- psych (>= 4.0.0)
101
- regexp_parser (2.9.2)
102
- reline (0.5.9)
103
- io-console (~> 0.5)
104
- rexml (3.3.0)
105
- strscan
106
- rspec-core (3.13.0)
107
- rspec-support (~> 3.13.0)
108
- rspec-expectations (3.13.1)
109
- diff-lcs (>= 1.2.0, < 2.0)
110
- rspec-support (~> 3.13.0)
111
- rspec-mocks (3.13.1)
112
- diff-lcs (>= 1.2.0, < 2.0)
113
- rspec-support (~> 3.13.0)
114
- rspec-rails (6.1.3)
115
- actionpack (>= 6.1)
116
- activesupport (>= 6.1)
117
- railties (>= 6.1)
118
- rspec-core (~> 3.13)
119
- rspec-expectations (~> 3.13)
120
- rspec-mocks (~> 3.13)
121
- rspec-support (~> 3.13)
122
- rspec-support (3.13.1)
123
- rubocop (1.64.1)
124
- json (~> 2.3)
125
- language_server-protocol (>= 3.17.0)
126
- parallel (~> 1.10)
37
+ rake (13.4.2)
38
+ regexp_parser (2.13.4)
39
+ rexml (3.4.4)
40
+ rubocop (1.93.0)
41
+ json (>= 2.3)
42
+ language_server-protocol (~> 3.17.0.2)
43
+ lint_roller (~> 1.1.0)
44
+ parallel (>= 1.10)
127
45
  parser (>= 3.3.0.2)
128
46
  rainbow (>= 2.2.2, < 4.0)
129
- regexp_parser (>= 1.8, < 3.0)
130
- rexml (>= 3.2.5, < 4.0)
131
- rubocop-ast (>= 1.31.1, < 2.0)
47
+ regexp_parser (>= 2.11.3, < 3.0)
48
+ rubocop-ast (>= 1.54.0, < 2.0)
132
49
  ruby-progressbar (~> 1.7)
133
- unicode-display_width (>= 2.4.0, < 3.0)
134
- rubocop-ast (1.31.3)
135
- parser (>= 3.3.1.0)
136
- rubocop-performance (1.21.1)
137
- rubocop (>= 1.48.1, < 2.0)
138
- rubocop-ast (>= 1.31.1, < 2.0)
139
- rubocop-rspec (3.0.1)
140
- rubocop (~> 1.61)
50
+ unicode-display_width (>= 2.4.0, < 4.0)
51
+ rubocop-ast (1.54.0)
52
+ ast (~> 2.4)
53
+ parser (>= 3.3.7.2)
54
+ prism (>= 1.7)
55
+ racc
56
+ rubocop-elegant (0.8.0)
57
+ lint_roller (~> 1.1)
58
+ rubocop (~> 1.75)
59
+ rubocop-minitest (0.41.0)
60
+ lint_roller (~> 1.1)
61
+ rubocop (>= 1.89.0, < 2.0)
62
+ rubocop-ast (>= 1.38.0, < 2.0)
63
+ rubocop-performance (1.27.0)
64
+ lint_roller (~> 1.1)
65
+ rubocop (>= 1.89.0, < 2.0)
66
+ rubocop-ast (>= 1.47.1, < 2.0)
67
+ rubocop-rake (0.7.1)
68
+ lint_roller (~> 1.1)
69
+ rubocop (>= 1.72.1)
141
70
  ruby-progressbar (1.13.0)
142
- simplecov (0.22.0)
143
- docile (~> 1.1)
144
- simplecov-html (~> 0.11)
145
- simplecov_json_formatter (~> 0.1)
146
- simplecov-cobertura (2.1.0)
71
+ simplecov (1.3.2)
72
+ simplecov-cobertura (4.0.0)
147
73
  rexml
148
- simplecov (~> 0.19)
149
- simplecov-html (0.12.3)
150
- simplecov_json_formatter (0.1.4)
151
- stringio (3.1.1)
152
- strscan (3.1.0)
153
- thor (1.3.1)
154
- tzinfo (2.0.6)
155
- concurrent-ruby (~> 1.0)
156
- unicode-display_width (2.5.0)
157
- webrick (1.8.1)
158
- yard (0.9.36)
159
- zeitwerk (2.6.16)
74
+ simplecov (~> 1.0)
75
+ unicode-display_width (3.3.0)
76
+ unicode-emoji (~> 4.3)
77
+ unicode-emoji (4.3.0)
78
+ yard (0.9.46)
160
79
 
161
80
  PLATFORMS
162
81
  arm64-darwin-22
82
+ arm64-darwin-23
83
+ arm64-darwin-24
84
+ ruby
163
85
  x64-mingw-ucrt
164
86
  x86_64-darwin-20
165
87
  x86_64-linux
166
88
 
167
89
  DEPENDENCIES
168
90
  decoor!
169
- minitest (= 5.24.0)
170
- rake (= 13.2.1)
171
- rspec-rails (= 6.1.3)
172
- rubocop (= 1.64.1)
173
- rubocop-performance (= 1.21.1)
174
- rubocop-rspec (= 3.0.1)
175
- simplecov (= 0.22.0)
176
- simplecov-cobertura (= 2.1.0)
177
- yard (= 0.9.36)
91
+ minitest (~> 6.0)
92
+ minitest-reporters (~> 1.7)
93
+ rake (~> 13.2)
94
+ rubocop (~> 1.65)
95
+ rubocop-elegant (~> 0.5)
96
+ rubocop-minitest (~> 0.38)
97
+ rubocop-performance (~> 1.0)
98
+ rubocop-rake (~> 0.7)
99
+ simplecov (~> 1.0)
100
+ simplecov-cobertura (~> 4.0)
101
+ yard (~> 0.9)
178
102
 
179
103
  BUNDLED WITH
180
- 2.4.22
104
+ 4.0.24
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  (The MIT License)
2
2
 
3
- Copyright (c) 2024 Yegor Bugayenko
3
+ Copyright (c) 2024-2026 Yegor Bugayenko
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the 'Software'), to deal
data/LICENSES/MIT.txt ADDED
@@ -0,0 +1,21 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2024-2026 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 CHANGED
@@ -1,13 +1,13 @@
1
1
  # True Object-Oriented Decorator
2
2
 
3
- [![DevOps By Rultor.com](http://www.rultor.com/b/yegor256/decoor)](http://www.rultor.com/p/yegor256/decoor)
3
+ [![DevOps By Rultor.com](https://www.rultor.com/b/yegor256/decoor)](https://www.rultor.com/p/yegor256/decoor)
4
4
  [![We recommend RubyMine](https://www.elegantobjects.org/rubymine.svg)](https://www.jetbrains.com/ruby/)
5
5
 
6
6
  [![rake](https://github.com/yegor256/decoor/actions/workflows/rake.yml/badge.svg)](https://github.com/yegor256/decoor/actions/workflows/rake.yml)
7
- [![PDD status](http://www.0pdd.com/svg?name=yegor256/decoor)](http://www.0pdd.com/p?name=yegor256/decoor)
8
- [![Gem Version](https://badge.fury.io/rb/decoor.svg)](http://badge.fury.io/rb/decoor)
7
+ [![PDD status](https://www.0pdd.com/svg?name=yegor256/decoor)](https://www.0pdd.com/p?name=yegor256/decoor)
8
+ [![Gem Version](https://badge.fury.io/rb/decoor.svg)](https://badge.fury.io/rb/decoor)
9
9
  [![Test Coverage](https://img.shields.io/codecov/c/github/yegor256/decoor.svg)](https://codecov.io/github/yegor256/decoor?branch=master)
10
- [![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](http://rubydoc.info/github/yegor256/decoor/master/frames)
10
+ [![Yard Docs](https://img.shields.io/badge/yard-docs-blue.svg)](https://rubydoc.info/github/yegor256/decoor/master/frames)
11
11
  [![Hits-of-Code](https://hitsofcode.com/github/yegor256/decoor)](https://hitsofcode.com/view/github/yegor256/decoor)
12
12
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/yegor256/decoor/blob/master/LICENSE.txt)
13
13
 
@@ -39,7 +39,7 @@ class MyString
39
39
  @origin.strip.split(@br)
40
40
  end
41
41
  end
42
- d = MyString.new('Jeff Lebowski')
42
+ d = MyString.new('Jeff Lebowski', ' ')
43
43
  assert(d.parts == ['Jeff', 'Lebowski'])
44
44
  ```
45
45
 
@@ -49,7 +49,7 @@ That's it.
49
49
 
50
50
  Read
51
51
  [these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).
52
- Make sure you build is green before you contribute
52
+ Make sure your build is green before you contribute
53
53
  your pull request. You will need to have
54
54
  [Ruby](https://www.ruby-lang.org/en/) 3.2+ and
55
55
  [Bundler](https://bundler.io/) installed. Then:
data/REUSE.toml ADDED
@@ -0,0 +1,34 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ version = 1
5
+ [[annotations]]
6
+ path = [
7
+ ".DS_Store",
8
+ ".gitattributes",
9
+ ".gitignore",
10
+ ".pdd",
11
+ "**.json",
12
+ "**.md",
13
+ "**.txt",
14
+ "**/.DS_Store",
15
+ "**/.gitignore",
16
+ "**/.pdd",
17
+ "**/*.csv",
18
+ "**/*.jpg",
19
+ "**/*.json",
20
+ "**/*.md",
21
+ "**/*.pdf",
22
+ "**/*.png",
23
+ "**/*.svg",
24
+ "**/*.txt",
25
+ "**/*.vm",
26
+ "**/CNAME",
27
+ "**/Gemfile.lock",
28
+ "Gemfile.lock",
29
+ "README.md",
30
+ "renovate.json",
31
+ ]
32
+ precedence = "override"
33
+ SPDX-FileCopyrightText = "Copyright (c) 2025 Yegor Bugayenko"
34
+ SPDX-License-Identifier = "MIT"
data/Rakefile CHANGED
@@ -1,28 +1,11 @@
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 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.
3
+ # SPDX-FileCopyrightText: Copyright (c) 2024-2026 Yegor Bugayenko
4
+ # SPDX-License-Identifier: MIT
22
5
 
23
- require 'rubygems'
24
6
  require 'rake'
25
7
  require 'rake/clean'
8
+ require 'rubygems'
26
9
 
27
10
  def name
28
11
  @name ||= File.basename(Dir['*.gemspec'].first, '.*')
@@ -32,7 +15,7 @@ def version
32
15
  Gem::Specification.load(Dir['*.gemspec'].first).version
33
16
  end
34
17
 
35
- task default: %i[clean test rubocop yard copyright]
18
+ task default: %i[clean test rubocop yard]
36
19
 
37
20
  require 'rake/testtask'
38
21
  desc 'Run all unit tests'
@@ -48,19 +31,11 @@ require 'yard'
48
31
  desc 'Build Yard documentation'
49
32
  YARD::Rake::YardocTask.new do |t|
50
33
  t.files = ['lib/**/*.rb']
34
+ t.options = ['--fail-on-warning']
51
35
  end
52
36
 
53
37
  require 'rubocop/rake_task'
54
38
  desc 'Run RuboCop on all directories'
55
39
  RuboCop::RakeTask.new(:rubocop) do |task|
56
40
  task.fail_on_error = true
57
- task.requires << 'rubocop-rspec'
58
- end
59
-
60
- task :copyright do
61
- sh "grep -q -r '#{Date.today.strftime('%Y')}' \
62
- --include '*.rb' \
63
- --include '*.txt' \
64
- --include 'Rakefile' \
65
- ."
66
41
  end
data/decoor.gemspec CHANGED
@@ -1,33 +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 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.
3
+ # SPDX-FileCopyrightText: Copyright (c) 2024-2026 Yegor Bugayenko
4
+ # SPDX-License-Identifier: MIT
22
5
 
23
6
  require 'English'
24
- require_relative 'lib/decoor'
25
7
 
26
8
  Gem::Specification.new do |s|
27
- s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
9
+ s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to?(:required_rubygems_version=)
28
10
  s.required_ruby_version = '>=3.0'
29
11
  s.name = 'decoor'
30
- s.version = '0.0.1'
12
+ s.version = '0.1.1'
31
13
  s.license = 'MIT'
32
14
  s.summary = 'Decoor'
33
15
  s.description =
@@ -37,8 +19,8 @@ Gem::Specification.new do |s|
37
19
  object-oriented.'
38
20
  s.authors = ['Yegor Bugayenko']
39
21
  s.email = 'yegor256@gmail.com'
40
- s.homepage = 'http://github.com/yegor256/decoor.rb'
41
- s.files = `git ls-files`.split($RS)
22
+ s.homepage = 'https://github.com/yegor256/decoor'
23
+ s.files = `git ls-files | grep -v -E '^(test/|\\.|renovate)'`.split($RS)
42
24
  s.rdoc_options = ['--charset=UTF-8']
43
25
  s.extra_rdoc_files = ['README.md', 'LICENSE.txt']
44
26
  s.metadata['rubygems_mfa_required'] = 'true'
data/lib/decoor.rb CHANGED
@@ -1,77 +1,73 @@
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-2026 Yegor Bugayenko
4
+ # SPDX-License-Identifier: MIT
22
5
 
23
- # A function that turns decorates an object.
24
- #
25
- # Author:: Yegor Bugayenko (yegor256@gmail.com)
26
- # Copyright:: Copyright (c) 2024 Yegor Bugayenko
27
- # License:: MIT
28
- def decoor(origin, attrs = {}, &)
29
- if block_given?
30
- c = Class.new do
31
- def initialize(origin, attrs)
32
- @origin = origin
33
- # rubocop:disable Style/HashEachMethods
34
- # rubocop:disable Lint/UnusedBlockArgument
35
- attrs.each do |k, v|
36
- instance_eval("@#{k} = v", __FILE__, __LINE__) # @foo = v
6
+ # System module, for global functions.
7
+ module Kernel
8
+ # Decorates an object by creating a proxy that delegates method calls to the original object.
9
+ #
10
+ # This function creates a decorator pattern implementation that allows transparent delegation
11
+ # to an origin object while optionally adding additional behavior through a block.
12
+ #
13
+ # When called with a block, it creates a new anonymous class that wraps the origin object
14
+ # and evaluates the block in the context of that class, allowing additional methods to be defined.
15
+ #
16
+ # When called without a block from within a class definition, it sets up method_missing
17
+ # to delegate calls to the specified instance variable.
18
+ #
19
+ # @param origin [Object, Symbol] The object to be decorated (when block given) or the name
20
+ # of an instance variable to delegate to (when no block given)
21
+ # @param attrs [Hash] Optional attributes to be set as instance variables on the decorator
22
+ # (only used when block is given)
23
+ # @yield Block to be evaluated in the context of the decorator class, allowing additional
24
+ # methods to be defined
25
+ # @return [Object] The decorated object (when block given) or nil (when no block given)
26
+ #
27
+ # @example Decorating an object with additional behavior
28
+ # decorated = decoor(original_object, {cache: {}}) do
29
+ # def cached_result
30
+ # @cache[:result] ||= @origin.expensive_operation
31
+ # end
32
+ # end
33
+ #
34
+ # @example Setting up delegation within a class
35
+ # class MyClass
36
+ # def initialize(collaborator)
37
+ # @collaborator = collaborator
38
+ # end
39
+ # decoor :collaborator
40
+ # end
41
+ #
42
+ # @author Yegor Bugayenko (yegor256@gmail.com)
43
+ # @since 0.1.0
44
+ def decoor(origin, attrs = {}, &)
45
+ if block_given?
46
+ c =
47
+ Class.new do
48
+ def initialize(origin, attrs)
49
+ @origin = origin
50
+ attrs.each { |k, v| instance_variable_set(:"@#{k}", v) }
51
+ end
52
+ def method_missing(...)
53
+ @origin.public_send(...)
54
+ end
55
+ def respond_to_missing?(mtd, inc = false)
56
+ @origin.respond_to?(mtd, inc) || super
57
+ end
37
58
  end
38
- # rubocop:enable Style/HashEachMethods
39
- # rubocop:enable Lint/UnusedBlockArgument
40
- end
41
-
42
- def method_missing(*args)
43
- @origin.__send__(*args) do |*a|
44
- yield(*a) if block_given?
59
+ c.class_eval(&)
60
+ c.new(origin, attrs)
61
+ else
62
+ class_eval("def __get_origin__; @#{origin}; end # def __get_origin__; @origin; end", __FILE__, __LINE__)
63
+ class_eval do
64
+ def method_missing(...)
65
+ __get_origin__.public_send(...)
45
66
  end
46
- end
47
-
48
- def respond_to?(_mtd, _inc = false)
49
- true
50
- end
51
-
52
- def respond_to_missing?(_mtd, _inc = false)
53
- true
54
- end
55
- end
56
- c.class_eval(&)
57
- c.new(origin, attrs)
58
- else
59
- class_eval("def __get_origin__; @#{origin}; end", __FILE__, __LINE__) # def _get; @name; end
60
- class_eval do
61
- def method_missing(*args)
62
- o = __get_origin__
63
- o.send(*args) do |*a|
64
- yield(*a) if block_given?
67
+ def respond_to_missing?(mtd, inc = false)
68
+ __get_origin__.respond_to?(mtd, inc) || super
65
69
  end
66
70
  end
67
-
68
- def respond_to?(_mtd, _inc = false)
69
- true
70
- end
71
-
72
- def respond_to_missing?(_mtd, _inc = false)
73
- true
74
- end
75
71
  end
76
72
  end
77
73
  end