decoor 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d776917878041e6ae9fff8283e0bb856d134031fd75e7df3add82151d0a6bdd2
4
+ data.tar.gz: e7642e9f9febe0efaf121081dbd226f112af1d67c5cf48fe0ec8551c886d7172
5
+ SHA512:
6
+ metadata.gz: '08afdc180df88e606bba313a2f4b51e2b9b62394e58b17c833b45d9bd390fbc7769da8df0b30fdca6b5c0ab07514b5966ee03d6e6da6daaa80c461b3062e8661'
7
+ data.tar.gz: e8fb3ec73cdb7f2e56dbd19262970ff75d802287f97d424924c5d2b5962108f2861ce17528bad7eec07e75393be4c4884937447be3cd1e6f691572dca180c384
data/.0pdd.yml ADDED
@@ -0,0 +1,25 @@
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
23
+ # alerts:
24
+ # github:
25
+ # - yegor256
data/.gitattributes ADDED
@@ -0,0 +1,7 @@
1
+ # Check out all text files in UNIX format, with LF as end of line
2
+ # Don't change this file. If you have any ideas about it, please
3
+ # submit a separate issue about it and we'll discuss.
4
+
5
+ * text=auto eol=lf
6
+ *.java ident
7
+ *.xml ident
@@ -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 NONINFINGEMENT. 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,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: copyrights
22
+ 'on':
23
+ push:
24
+ pull_request:
25
+ jobs:
26
+ copyrights:
27
+ runs-on: ubuntu-22.04
28
+ steps:
29
+ - uses: actions/checkout@v4
30
+ - uses: yegor256/copyrights-action@0.0.4
@@ -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 NONINFINGEMENT. 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,36 @@
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 NONINFINGEMENT. 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
35
+ with:
36
+ config_file: .yamllint.yml
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ coverage/
2
+ .idea/
3
+ *.gem
4
+ .bundle/
5
+ .DS_Store
6
+ rdoc/
7
+ doc/
8
+ .yardoc/
data/.pdd ADDED
@@ -0,0 +1,7 @@
1
+ --source=.
2
+ --verbose
3
+ --exclude target/**/*
4
+ --exclude coverage/**/*
5
+ --rule min-words:20
6
+ --rule min-estimate:15
7
+ --rule max-estimate:90
data/.rubocop.yml ADDED
@@ -0,0 +1,52 @@
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
+ Style/OptionalBooleanParameter:
32
+ Enabled: false
33
+ Lint/NestedMethodDefinition:
34
+ Enabled: false
35
+ Gemspec/RequiredRubyVersion:
36
+ Enabled: false
37
+ Metrics/MethodLength:
38
+ Enabled: false
39
+ Metrics/AbcSize:
40
+ Enabled: false
41
+ Metrics/BlockLength:
42
+ Enabled: false
43
+ Metrics/CyclomaticComplexity:
44
+ Enabled: false
45
+ Metrics/PerceivedComplexity:
46
+ Enabled: false
47
+ Metrics/ClassLength:
48
+ Enabled: false
49
+ Layout/EmptyLineAfterGuardClause:
50
+ Enabled: false
51
+ Layout/EndOfLine:
52
+ EnforcedStyle: lf
data/.rultor.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
+ 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" decoor.gemspec
35
+ git add decoor.gemspec
36
+ git commit -m "version set to ${tag}"
37
+ gem build decoor.gemspec
38
+ chmod 0600 ../rubygems.yml
39
+ gem push *.gem --config-file ../rubygems.yml
40
+ merge:
41
+ script: |-
42
+ 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 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
data/.yamllint.yml ADDED
@@ -0,0 +1,24 @@
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
+ rules:
22
+ line-length:
23
+ max: 80
24
+ allow-non-breakable-words: true
data/Gemfile ADDED
@@ -0,0 +1,34 @@
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.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
data/Gemfile.lock ADDED
@@ -0,0 +1,180 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ decoor (0.0.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
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)
38
+ 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)
69
+ ast (~> 2.4.1)
70
+ 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)
97
+ 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)
127
+ parser (>= 3.3.0.2)
128
+ 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)
132
+ 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)
141
+ 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)
147
+ 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)
160
+
161
+ PLATFORMS
162
+ arm64-darwin-22
163
+ x64-mingw-ucrt
164
+ x86_64-darwin-20
165
+ x86_64-linux
166
+
167
+ DEPENDENCIES
168
+ 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)
178
+
179
+ BUNDLED WITH
180
+ 2.4.22
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,62 @@
1
+ # True Object-Oriented Decorator
2
+
3
+ [![DevOps By Rultor.com](http://www.rultor.com/b/yegor256/decoor)](http://www.rultor.com/p/yegor256/decoor)
4
+ [![We recommend RubyMine](https://www.elegantobjects.org/rubymine.svg)](https://www.jetbrains.com/ruby/)
5
+
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)
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)
11
+ [![Hits-of-Code](https://hitsofcode.com/github/yegor256/decoor)](https://hitsofcode.com/view/github/yegor256/decoor)
12
+ [![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/yegor256/decoor/blob/master/LICENSE.txt)
13
+
14
+ Let's say, you have an object that you want to decorate, thus
15
+ adding new attributes and methods to it. Here is how:
16
+
17
+ ```ruby
18
+ require 'decoor'
19
+ s = ' Jeff Lebowski '
20
+ d = decoor(s, br: ' ') do
21
+ def parts
22
+ @origin.strip.split(@br)
23
+ end
24
+ end
25
+ assert(d.parts == ['Jeff', 'Lebowski'])
26
+ ```
27
+
28
+ You may also turn an existing class into a decorator:
29
+
30
+ ```ruby
31
+ require 'decoor'
32
+ class MyString
33
+ def initialize(s, br)
34
+ @s = s
35
+ @br = br
36
+ end
37
+ decoor(:s)
38
+ def parts
39
+ @origin.strip.split(@br)
40
+ end
41
+ end
42
+ d = MyString.new('Jeff Lebowski')
43
+ assert(d.parts == ['Jeff', 'Lebowski'])
44
+ ```
45
+
46
+ That's it.
47
+
48
+ ## How to contribute
49
+
50
+ Read
51
+ [these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).
52
+ Make sure you build is green before you contribute
53
+ your pull request. You will need to have
54
+ [Ruby](https://www.ruby-lang.org/en/) 3.2+ and
55
+ [Bundler](https://bundler.io/) installed. Then:
56
+
57
+ ```bash
58
+ bundle update
59
+ bundle exec rake
60
+ ```
61
+
62
+ If it's clean and you don't see any error messages, submit your pull request.
data/Rakefile ADDED
@@ -0,0 +1,66 @@
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 'rake/clean'
26
+
27
+ def name
28
+ @name ||= File.basename(Dir['*.gemspec'].first, '.*')
29
+ end
30
+
31
+ def version
32
+ Gem::Specification.load(Dir['*.gemspec'].first).version
33
+ end
34
+
35
+ task default: %i[clean test rubocop yard copyright]
36
+
37
+ require 'rake/testtask'
38
+ desc 'Run all unit tests'
39
+ Rake::TestTask.new(:test) do |test|
40
+ Rake::Cleaner.cleanup_files(['coverage'])
41
+ test.libs << 'lib' << 'test'
42
+ test.pattern = 'test/**/test_*.rb'
43
+ test.warning = true
44
+ test.verbose = false
45
+ end
46
+
47
+ require 'yard'
48
+ desc 'Build Yard documentation'
49
+ YARD::Rake::YardocTask.new do |t|
50
+ t.files = ['lib/**/*.rb']
51
+ end
52
+
53
+ require 'rubocop/rake_task'
54
+ desc 'Run RuboCop on all directories'
55
+ RuboCop::RakeTask.new(:rubocop) do |task|
56
+ 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
+ end
data/decoor.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
+ require_relative 'lib/decoor'
25
+
26
+ Gem::Specification.new do |s|
27
+ s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
28
+ s.required_ruby_version = '>=3.0'
29
+ s.name = 'decoor'
30
+ s.version = '0.0.1'
31
+ s.license = 'MIT'
32
+ s.summary = 'Decoor'
33
+ s.description =
34
+ 'A primitive gem that helps you decorate an object or turn an existing
35
+ class into a decorator. The key difference between this gem and a thousand
36
+ other gems that are doing almost the same is that this gem is really
37
+ object-oriented.'
38
+ s.authors = ['Yegor Bugayenko']
39
+ s.email = 'yegor256@gmail.com'
40
+ s.homepage = 'http://github.com/yegor256/decoor.rb'
41
+ s.files = `git ls-files`.split($RS)
42
+ s.rdoc_options = ['--charset=UTF-8']
43
+ s.extra_rdoc_files = ['README.md', 'LICENSE.txt']
44
+ s.metadata['rubygems_mfa_required'] = 'true'
45
+ end
data/lib/decoor.rb ADDED
@@ -0,0 +1,77 @@
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 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.
22
+
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
37
+ 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?
45
+ 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?
65
+ end
66
+ 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
+ end
76
+ end
77
+ end
data/renovate.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
+ "extends": [
4
+ "config:base"
5
+ ]
6
+ }
@@ -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 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.
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,77 @@
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 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.
22
+
23
+ require 'minitest/autorun'
24
+ require_relative '../lib/decoor'
25
+
26
+ # Decoor main module test.
27
+ # Author:: Yegor Bugayenko (yegor256@gmail.com)
28
+ # Copyright:: Copyright (c) 2024 Yegor Bugayenko
29
+ # License:: MIT
30
+ class TestDecoor < Minitest::Test
31
+ def test_object_decoration
32
+ cy = Class.new do
33
+ def booo
34
+ yield 55
35
+ end
36
+
37
+ def zero
38
+ 0
39
+ end
40
+ end
41
+ x = decoor(cy.new, bar: 42) do
42
+ def foo
43
+ @bar
44
+ end
45
+
46
+ def sum
47
+ @origin.zero + 10
48
+ end
49
+ end
50
+ assert_equal(42, x.foo)
51
+ assert_equal(10, x.sum)
52
+ assert_equal(56, x.booo { |v| v + 1 })
53
+ end
54
+
55
+ def test_class_decoration
56
+ cy = Class.new do
57
+ def booo
58
+ yield 44
59
+ end
60
+ end
61
+ cz = Class.new do
62
+ decoor(:origin)
63
+
64
+ def initialize(origin, bar: nil)
65
+ @origin = origin
66
+ @bar = bar
67
+ end
68
+
69
+ def foo
70
+ @bar
71
+ end
72
+ end
73
+ z = cz.new(cy.new, bar: 42)
74
+ assert_equal(42, z.foo)
75
+ assert_equal(45, z.booo { |v| v + 1 })
76
+ end
77
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: decoor
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-06-22 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: |-
14
+ A primitive gem that helps you decorate an object or turn an existing
15
+ class into a decorator. The key difference between this gem and a thousand
16
+ other gems that are doing almost the same is that this gem is really
17
+ object-oriented.
18
+ email: yegor256@gmail.com
19
+ executables: []
20
+ extensions: []
21
+ extra_rdoc_files:
22
+ - README.md
23
+ - LICENSE.txt
24
+ files:
25
+ - ".0pdd.yml"
26
+ - ".gitattributes"
27
+ - ".github/workflows/actionlint.yml"
28
+ - ".github/workflows/codecov.yml"
29
+ - ".github/workflows/copyrights.yml"
30
+ - ".github/workflows/markdown-lint.yml"
31
+ - ".github/workflows/pdd.yml"
32
+ - ".github/workflows/rake.yml"
33
+ - ".github/workflows/xcop.yml"
34
+ - ".github/workflows/yamllint.yml"
35
+ - ".gitignore"
36
+ - ".pdd"
37
+ - ".rubocop.yml"
38
+ - ".rultor.yml"
39
+ - ".simplecov"
40
+ - ".yamllint.yml"
41
+ - Gemfile
42
+ - Gemfile.lock
43
+ - LICENSE.txt
44
+ - README.md
45
+ - Rakefile
46
+ - decoor.gemspec
47
+ - lib/decoor.rb
48
+ - renovate.json
49
+ - test/test__helper.rb
50
+ - test/test_decoor.rb
51
+ homepage: http://github.com/yegor256/decoor.rb
52
+ licenses:
53
+ - MIT
54
+ metadata:
55
+ rubygems_mfa_required: 'true'
56
+ post_install_message:
57
+ rdoc_options:
58
+ - "--charset=UTF-8"
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: '3.0'
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ requirements: []
72
+ rubygems_version: 3.4.10
73
+ signing_key:
74
+ specification_version: 4
75
+ summary: Decoor
76
+ test_files: []