joined 0.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: db52755ef87faa3e9cad4394811ca4305108bceeb3b3456852c49a7f13af87cb
4
+ data.tar.gz: 789ca4420f0a0d461306c95478efda9665a3617ea8ba41d47beb147c6b5868e4
5
+ SHA512:
6
+ metadata.gz: 3c2049dde1dc54630b03c71b2456034cc19cd3cc819ff11f88ceaa29f0015e77951ed9ceea4a5be7353f342f1583ba00d5896f13e2fb0b1d8c17af59c2b75533
7
+ data.tar.gz: 8caec01188aa49976f89ea3afbfbdcae7a7945d695711b44e1a7b3126c37a5a810898784cf6f4e421346afeb281e723752dafab01d4977d584b9281216102594
data/.0pdd.yml ADDED
@@ -0,0 +1,5 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
3
+ ---
4
+ errors:
5
+ - yegor256@gmail.com
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,25 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
3
+ ---
4
+ # yamllint disable rule:line-length
5
+ name: actionlint
6
+ 'on':
7
+ push:
8
+ branches:
9
+ - master
10
+ pull_request:
11
+ branches:
12
+ - master
13
+ jobs:
14
+ actionlint:
15
+ timeout-minutes: 15
16
+ runs-on: ubuntu-24.04
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+ - name: Download actionlint
20
+ id: get_actionlint
21
+ run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
22
+ shell: bash
23
+ - name: Check workflow files
24
+ run: ${{ steps.get_actionlint.outputs.executable }} -color
25
+ shell: bash
@@ -0,0 +1,25 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
3
+ ---
4
+ # yamllint disable rule:line-length
5
+ name: codecov
6
+ 'on':
7
+ push:
8
+ branches:
9
+ - master
10
+ jobs:
11
+ codecov:
12
+ timeout-minutes: 15
13
+ runs-on: ubuntu-24.04
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+ - uses: ruby/setup-ruby@v1
17
+ with:
18
+ ruby-version: 3.3
19
+ bundler-cache: true
20
+ - run: bundle config set --global path "$(pwd)/vendor/bundle"
21
+ - run: bundle install --no-color
22
+ - run: bundle exec rake
23
+ - uses: codecov/codecov-action@v5
24
+ with:
25
+ token: ${{ secrets.CODECOV_TOKEN }}
@@ -0,0 +1,19 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
3
+ ---
4
+ # yamllint disable rule:line-length
5
+ name: copyrights
6
+ 'on':
7
+ push:
8
+ branches:
9
+ - master
10
+ pull_request:
11
+ branches:
12
+ - master
13
+ jobs:
14
+ copyrights:
15
+ timeout-minutes: 15
16
+ runs-on: ubuntu-24.04
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+ - uses: yegor256/copyrights-action@0.0.8
@@ -0,0 +1,42 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
3
+ ---
4
+ # yamllint disable rule:line-length
5
+ name: license
6
+ 'on':
7
+ push:
8
+ branches:
9
+ - master
10
+ pull_request:
11
+ branches:
12
+ - master
13
+ jobs:
14
+ license:
15
+ timeout-minutes: 15
16
+ runs-on: ubuntu-24.04
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+ - shell: bash
20
+ run: |
21
+ header="Copyright (c) $(date +%Y) Yegor Bugayenko"
22
+ failed="false"
23
+ while IFS= read -r file; do
24
+ if ! grep -q "${header}" "${file}"; then
25
+ failed="true"
26
+ echo "⚠️ Copyright header is not found in: ${file}"
27
+ else
28
+ echo "File looks good: ${file}"
29
+ fi
30
+ done < <(find . -type f \( \
31
+ -name "Dockerfile" -o \
32
+ -name "LICENSE.txt" -o \
33
+ -name "Makefile" -o \
34
+ -name "Rakefile" -o \
35
+ -name "*.sh" -o \
36
+ -name "*.rb" -o \
37
+ -name "*.fe" -o \
38
+ -name "*.yml" \
39
+ \) -print)
40
+ if [ "${failed}" = "true" ]; then
41
+ exit 1
42
+ fi
@@ -0,0 +1,23 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
3
+ ---
4
+ # yamllint disable rule:line-length
5
+ name: markdown-lint
6
+ 'on':
7
+ push:
8
+ branches:
9
+ - master
10
+ pull_request:
11
+ branches:
12
+ - master
13
+ paths-ignore: ['paper/**', 'sandbox/**']
14
+ concurrency:
15
+ group: markdown-lint-${{ github.ref }}
16
+ cancel-in-progress: true
17
+ jobs:
18
+ markdown-lint:
19
+ timeout-minutes: 15
20
+ runs-on: ubuntu-24.04
21
+ steps:
22
+ - uses: actions/checkout@v4
23
+ - uses: articulate/actions-markdownlint@v1
@@ -0,0 +1,19 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
3
+ ---
4
+ # yamllint disable rule:line-length
5
+ name: pdd
6
+ 'on':
7
+ push:
8
+ branches:
9
+ - master
10
+ pull_request:
11
+ branches:
12
+ - master
13
+ jobs:
14
+ pdd:
15
+ timeout-minutes: 15
16
+ runs-on: ubuntu-24.04
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+ - uses: volodya-lombrozo/pdd-action@master
@@ -0,0 +1,28 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
3
+ ---
4
+ # yamllint disable rule:line-length
5
+ name: rake
6
+ 'on':
7
+ push:
8
+ branches:
9
+ - master
10
+ pull_request:
11
+ branches:
12
+ - master
13
+ jobs:
14
+ rake:
15
+ strategy:
16
+ matrix:
17
+ os: [ubuntu-24.04, macos-15, windows-2022]
18
+ ruby: [3.3]
19
+ runs-on: ${{ matrix.os }}
20
+ steps:
21
+ - uses: actions/checkout@v4
22
+ - uses: ruby/setup-ruby@v1
23
+ with:
24
+ ruby-version: ${{ matrix.ruby }}
25
+ bundler-cache: true
26
+ - run: bundle config set --global path "$(pwd)/vendor/bundle"
27
+ - run: bundle install --no-color
28
+ - run: bundle exec rake
@@ -0,0 +1,19 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
3
+ ---
4
+ # yamllint disable rule:line-length
5
+ name: reuse
6
+ 'on':
7
+ push:
8
+ branches:
9
+ - master
10
+ pull_request:
11
+ branches:
12
+ - master
13
+ jobs:
14
+ reuse:
15
+ timeout-minutes: 15
16
+ runs-on: ubuntu-24.04
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+ - uses: fsfe/reuse-action@v5
@@ -0,0 +1,15 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
3
+ ---
4
+ # yamllint disable rule:line-length
5
+ name: xcop
6
+ 'on':
7
+ push:
8
+ pull_request:
9
+ jobs:
10
+ xcop:
11
+ timeout-minutes: 15
12
+ runs-on: ubuntu-24.04
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+ - uses: g4s8/xcop-action@master
@@ -0,0 +1,19 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
3
+ ---
4
+ # yamllint disable rule:line-length
5
+ name: yamllint
6
+ 'on':
7
+ push:
8
+ branches:
9
+ - master
10
+ pull_request:
11
+ branches:
12
+ - master
13
+ jobs:
14
+ yamllint:
15
+ timeout-minutes: 15
16
+ runs-on: ubuntu-24.04
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+ - uses: ibiqlik/action-yamllint@v3
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ *.gem
2
+ .DS_Store
3
+ .bundle/
4
+ .idea/
5
+ .yardoc/
6
+ coverage/
7
+ doc/
8
+ node_modules/
9
+ rdoc/
10
+ temp/
11
+ vendor/
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,20 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
3
+ ---
4
+ AllCops:
5
+ Exclude:
6
+ - 'bin/**/*'
7
+ - 'assets/**/*'
8
+ - 'vendor/**/*'
9
+ DisplayCopNames: true
10
+ TargetRubyVersion: 3.2
11
+ SuggestExtensions: false
12
+ NewCops: enable
13
+ plugins:
14
+ - rubocop-rake
15
+ - rubocop-minitest
16
+ - rubocop-performance
17
+ Layout/EndOfLine:
18
+ EnforcedStyle: lf
19
+ Style/EvalWithLocation:
20
+ Enabled: false
data/.rultor.yml ADDED
@@ -0,0 +1,28 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
3
+ ---
4
+ # yamllint disable rule:line-length
5
+ docker:
6
+ image: yegor256/ruby
7
+ assets:
8
+ rubygems.yml: yegor256/home#assets/rubygems.yml
9
+ install: |
10
+ pdd -f /dev/null
11
+ bundle install --no-color
12
+ release:
13
+ pre: false
14
+ script: |-
15
+ [[ "${tag}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || exit -1
16
+ bundle exec rake
17
+ rm -rf *.gem
18
+ sed -i "s/0\.0\.0/${tag}/g" joined.gemspec
19
+ git add joined.gemspec
20
+ sed -i "s/0\.0\.0/${tag}/g" lib/joined.rb
21
+ git add lib/joined.rb
22
+ git commit -m "version set to ${tag}"
23
+ gem build joined.gemspec
24
+ chmod 0600 ../rubygems.yml
25
+ gem push *.gem --config-file ../rubygems.yml
26
+ merge:
27
+ script: |-
28
+ bundle exec rake
data/Gemfile ADDED
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ # SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
4
+ # SPDX-License-Identifier: MIT
5
+
6
+ source 'https://rubygems.org'
7
+ gemspec
8
+
9
+ gem 'minitest', '~>5.25', require: false
10
+ gem 'minitest-reporters', '~>1.7', require: false
11
+ gem 'rake', '~>13.2', require: false
12
+ gem 'rubocop', '~>1.64', require: false
13
+ gem 'rubocop-minitest', '>0', require: false
14
+ gem 'rubocop-performance', '>0', require: false
15
+ gem 'rubocop-rake', '>0', require: false
16
+ gem 'rubocop-rspec', '>0', require: false
17
+ gem 'simplecov', '~>0.22', require: false
18
+ gem 'simplecov-cobertura', '~>2.1', require: false
19
+ gem 'yard', '~>0.9', require: false
data/Gemfile.lock ADDED
@@ -0,0 +1,100 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ joined (0.0.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ansi (1.5.0)
10
+ ast (2.4.3)
11
+ builder (3.3.0)
12
+ docile (1.4.1)
13
+ json (2.11.3)
14
+ language_server-protocol (3.17.0.4)
15
+ lint_roller (1.1.0)
16
+ minitest (5.25.5)
17
+ minitest-reporters (1.7.1)
18
+ ansi
19
+ builder
20
+ minitest (>= 5.0)
21
+ ruby-progressbar
22
+ parallel (1.27.0)
23
+ parser (3.3.8.0)
24
+ ast (~> 2.4.1)
25
+ racc
26
+ prism (1.4.0)
27
+ racc (1.8.1)
28
+ rainbow (3.1.1)
29
+ rake (13.2.1)
30
+ regexp_parser (2.10.0)
31
+ rexml (3.4.1)
32
+ rubocop (1.75.4)
33
+ json (~> 2.3)
34
+ language_server-protocol (~> 3.17.0.2)
35
+ lint_roller (~> 1.1.0)
36
+ parallel (~> 1.10)
37
+ parser (>= 3.3.0.2)
38
+ rainbow (>= 2.2.2, < 4.0)
39
+ regexp_parser (>= 2.9.3, < 3.0)
40
+ rubocop-ast (>= 1.44.0, < 2.0)
41
+ ruby-progressbar (~> 1.7)
42
+ unicode-display_width (>= 2.4.0, < 4.0)
43
+ rubocop-ast (1.44.1)
44
+ parser (>= 3.3.7.2)
45
+ prism (~> 1.4)
46
+ rubocop-minitest (0.38.0)
47
+ lint_roller (~> 1.1)
48
+ rubocop (>= 1.75.0, < 2.0)
49
+ rubocop-ast (>= 1.38.0, < 2.0)
50
+ rubocop-performance (1.25.0)
51
+ lint_roller (~> 1.1)
52
+ rubocop (>= 1.75.0, < 2.0)
53
+ rubocop-ast (>= 1.38.0, < 2.0)
54
+ rubocop-rake (0.7.1)
55
+ lint_roller (~> 1.1)
56
+ rubocop (>= 1.72.1)
57
+ rubocop-rspec (3.6.0)
58
+ lint_roller (~> 1.1)
59
+ rubocop (~> 1.72, >= 1.72.1)
60
+ ruby-progressbar (1.13.0)
61
+ simplecov (0.22.0)
62
+ docile (~> 1.1)
63
+ simplecov-html (~> 0.11)
64
+ simplecov_json_formatter (~> 0.1)
65
+ simplecov-cobertura (2.1.0)
66
+ rexml
67
+ simplecov (~> 0.19)
68
+ simplecov-html (0.13.1)
69
+ simplecov_json_formatter (0.1.4)
70
+ unicode-display_width (3.1.4)
71
+ unicode-emoji (~> 4.0, >= 4.0.4)
72
+ unicode-emoji (4.0.4)
73
+ yard (0.9.37)
74
+
75
+ PLATFORMS
76
+ aarch64-linux
77
+ arm-linux
78
+ arm64-darwin
79
+ arm64-darwin-23
80
+ x64-mingw-ucrt
81
+ x86-linux
82
+ x86_64-darwin
83
+ x86_64-linux
84
+
85
+ DEPENDENCIES
86
+ joined!
87
+ minitest (~> 5.25)
88
+ minitest-reporters (~> 1.7)
89
+ rake (~> 13.2)
90
+ rubocop (~> 1.64)
91
+ rubocop-minitest (> 0)
92
+ rubocop-performance (> 0)
93
+ rubocop-rake (> 0)
94
+ rubocop-rspec (> 0)
95
+ simplecov (~> 0.22)
96
+ simplecov-cobertura (~> 2.1)
97
+ yard (~> 0.9)
98
+
99
+ BUNDLED WITH
100
+ 2.5.16
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2025 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/LICENSES/MIT.txt ADDED
@@ -0,0 +1,21 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2025 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,46 @@
1
+ # Adds a `.joined` method to `Array`
2
+
3
+ [![DevOps By Rultor.com](https://www.rultor.com/b/yegor256/joined)](https://www.rultor.com/p/yegor256/joined)
4
+ [![We recommend RubyMine](https://www.elegantobjects.org/rubymine.svg)](https://www.jetbrains.com/ruby/)
5
+
6
+ [![rake](https://github.com/yegor256/joined/actions/workflows/rake.yml/badge.svg)](https://github.com/yegor256/joined/actions/workflows/rake.yml)
7
+ [![PDD status](https://www.0pdd.com/svg?name=yegor256/joined)](https://www.0pdd.com/p?name=yegor256/joined)
8
+ [![Gem Version](https://badge.fury.io/rb/joined.svg)](https://badge.fury.io/rb/joined)
9
+ [![Test Coverage](https://img.shields.io/codecov/c/github/yegor256/joined.svg)](https://codecov.io/github/yegor256/joined?branch=master)
10
+ [![Yard Docs](https://img.shields.io/badge/yard-docs-blue.svg)](https://rubydoc.info/github/yegor256/joined/master/frames)
11
+ [![Hits-of-Code](https://hitsofcode.com/github/yegor256/joined)](https://hitsofcode.com/view/github/yegor256/joined)
12
+ [![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/yegor256/joined/blob/master/LICENSE.txt)
13
+
14
+ Maybe you know [`to_sentence`][to_sentence] from Rails.
15
+ This gem does exactly the same, but without Rails.
16
+
17
+ ```ruby
18
+ require 'joined'
19
+ puts ['orange', 'banana', 'pear'].joined
20
+ ```
21
+
22
+ Prints:
23
+
24
+ ```text
25
+ orange, banana, and pear
26
+ ```
27
+
28
+ That's it.
29
+
30
+ ## How to contribute
31
+
32
+ Read
33
+ [these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).
34
+ Make sure your build is green before you contribute
35
+ your pull request. You will need to have
36
+ [Ruby](https://www.ruby-lang.org/en/) 3.0+ and
37
+ [Bundler](https://bundler.io/) installed. Then:
38
+
39
+ ```bash
40
+ bundle update
41
+ bundle exec rake
42
+ ```
43
+
44
+ If it's clean and you don't see any error messages, submit your pull request.
45
+
46
+ [to_sentence]: https://api.rubyonrails.org/classes/Array.html#method-i-to_sentence
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
+ "**.json",
8
+ "**.md",
9
+ "**.txt",
10
+ "**/*.csv",
11
+ "**/*.jpg",
12
+ "**/*.json",
13
+ "**/*.md",
14
+ "**/*.pdf",
15
+ "**/*.png",
16
+ "**/*.svg",
17
+ "**/*.txt",
18
+ "**/*.vm",
19
+ "**/.DS_Store",
20
+ "**/.gitignore",
21
+ "**/.pdd",
22
+ "**/CNAME",
23
+ "**/Gemfile.lock",
24
+ ".DS_Store",
25
+ ".gitattributes",
26
+ ".gitignore",
27
+ ".pdd",
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 ADDED
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ # SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
4
+ # SPDX-License-Identifier: MIT
5
+
6
+ require 'rubygems'
7
+ require 'rake'
8
+ require 'rake/clean'
9
+
10
+ def name
11
+ @name ||= File.basename(Dir['*.gemspec'].first, '.*')
12
+ end
13
+
14
+ def version
15
+ Gem::Specification.load(Dir['*.gemspec'].first).version
16
+ end
17
+
18
+ task default: %i[clean test rubocop yard]
19
+
20
+ require 'rake/testtask'
21
+ desc 'Run all unit tests'
22
+ Rake::TestTask.new(:test) do |test|
23
+ Rake::Cleaner.cleanup_files(['coverage'])
24
+ test.libs << 'lib' << 'test'
25
+ test.pattern = 'test/**/test_*.rb'
26
+ test.warning = true
27
+ test.verbose = false
28
+ end
29
+
30
+ require 'yard'
31
+ desc 'Build Yard documentation'
32
+ YARD::Rake::YardocTask.new do |t|
33
+ t.files = ['lib/**/*.rb']
34
+ end
35
+
36
+ require 'rubocop/rake_task'
37
+ desc 'Run RuboCop on all directories'
38
+ RuboCop::RakeTask.new(:rubocop) do |task|
39
+ task.fail_on_error = true
40
+ end
data/joined.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ # SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
4
+ # SPDX-License-Identifier: MIT
5
+
6
+ require 'English'
7
+
8
+ Gem::Specification.new do |s|
9
+ s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
10
+ s.required_ruby_version = '>=3.2'
11
+ s.name = 'joined'
12
+ s.version = '0.0.1'
13
+ s.license = 'MIT'
14
+ s.summary = 'A simple Ruby gem that adds a .joined() method to Array'
15
+ s.description =
16
+ 'This gem adds a .joined() method to the Array class. ' \
17
+ 'This method concatenates all elements of the array into a string, ' \
18
+ 'separating them with commas and placing "and" before the last element.'
19
+ s.authors = ['Yegor Bugayenko']
20
+ s.email = 'yegor256@gmail.com'
21
+ s.homepage = 'http://github.com/yegor256/joined'
22
+ s.files = `git ls-files`.split($RS)
23
+ s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
24
+ s.rdoc_options = ['--charset=UTF-8']
25
+ s.extra_rdoc_files = ['README.md', 'LICENSE.txt']
26
+ s.metadata['rubygems_mfa_required'] = 'true'
27
+ end
data/lib/joined.rb ADDED
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ # SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
4
+ # SPDX-License-Identifier: MIT
5
+
6
+ # Joins elements of array.
7
+ #
8
+ # Author:: Yegor Bugayenko (yegor256@gmail.com)
9
+ # Copyright:: Copyright (c) 2025 Yegor Bugayenko
10
+ # License:: MIT
11
+ class Array
12
+ def joined
13
+ return '' if empty?
14
+ return first if length == 1
15
+
16
+ "#{self[0...-1].join(', ')}#{',' if length > 2} and #{self[-1]}"
17
+ end
18
+ 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
+ # SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
4
+ # SPDX-License-Identifier: MIT
5
+
6
+ $stdout.sync = true
7
+
8
+ require 'simplecov'
9
+ require 'simplecov-cobertura'
10
+ unless SimpleCov.running || ENV['PICKS']
11
+ SimpleCov.command_name('test')
12
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
13
+ [
14
+ SimpleCov::Formatter::HTMLFormatter,
15
+ SimpleCov::Formatter::CoberturaFormatter
16
+ ]
17
+ )
18
+ SimpleCov.minimum_coverage 95
19
+ SimpleCov.minimum_coverage_by_file 90
20
+ SimpleCov.start do
21
+ add_filter 'test/'
22
+ add_filter 'vendor/'
23
+ add_filter 'target/'
24
+ track_files 'lib/**/*.rb'
25
+ track_files '*.rb'
26
+ end
27
+ end
28
+
29
+ require 'minitest/autorun'
30
+ require 'minitest/reporters'
31
+ Minitest::Reporters.use! [Minitest::Reporters::SpecReporter.new]
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ # SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
4
+ # SPDX-License-Identifier: MIT
5
+
6
+ require_relative '../lib/joined'
7
+
8
+ # Test.
9
+ # Author:: Yegor Bugayenko (yegor256@gmail.com)
10
+ # Copyright:: Copyright (c) 2025 Yegor Bugayenko
11
+ # License:: MIT
12
+ class Testjoined < Minitest::Test
13
+ def test_simple
14
+ assert_equal('', [].joined)
15
+ assert_equal('apple', ['apple'].joined)
16
+ assert_equal('apple and banana', %w[apple banana].joined)
17
+ assert_equal('apple, banana, and orange', %w[apple banana orange].joined)
18
+ assert_equal('apple, banana, orange, and pear', %w[apple banana orange pear].joined)
19
+ end
20
+ end
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: joined
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Yegor Bugayenko
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies: []
12
+ description: This gem adds a .joined() method to the Array class. This method concatenates
13
+ all elements of the array into a string, separating them with commas and placing
14
+ "and" before the last element.
15
+ email: yegor256@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files:
19
+ - LICENSE.txt
20
+ - README.md
21
+ files:
22
+ - ".0pdd.yml"
23
+ - ".gitattributes"
24
+ - ".github/workflows/actionlint.yml"
25
+ - ".github/workflows/codecov.yml"
26
+ - ".github/workflows/copyrights.yml"
27
+ - ".github/workflows/license.yml"
28
+ - ".github/workflows/markdown-lint.yml"
29
+ - ".github/workflows/pdd.yml"
30
+ - ".github/workflows/rake.yml"
31
+ - ".github/workflows/reuse.yml"
32
+ - ".github/workflows/xcop.yml"
33
+ - ".github/workflows/yamllint.yml"
34
+ - ".gitignore"
35
+ - ".pdd"
36
+ - ".rubocop.yml"
37
+ - ".rultor.yml"
38
+ - Gemfile
39
+ - Gemfile.lock
40
+ - LICENSE.txt
41
+ - LICENSES/MIT.txt
42
+ - README.md
43
+ - REUSE.toml
44
+ - Rakefile
45
+ - joined.gemspec
46
+ - lib/joined.rb
47
+ - renovate.json
48
+ - test/test__helper.rb
49
+ - test/test_joined.rb
50
+ homepage: http://github.com/yegor256/joined
51
+ licenses:
52
+ - MIT
53
+ metadata:
54
+ rubygems_mfa_required: 'true'
55
+ rdoc_options:
56
+ - "--charset=UTF-8"
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '3.2'
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ requirements: []
70
+ rubygems_version: 3.6.7
71
+ specification_version: 4
72
+ summary: A simple Ruby gem that adds a .joined() method to Array
73
+ test_files: []