qbash 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: fccb41b161a6c90a23d521fa77e25afa0524e90fe208e3438c9b4d5af83d6c78
4
+ data.tar.gz: 85260c4600d72f50d1c3fe38030ea9a939c62e335c5ca2851b25d9d5a2c68696
5
+ SHA512:
6
+ metadata.gz: c709f5c9ca3b1683d11e9bbc019e84fbf4a9c782e043fe36f88b0467f3a63123713eea48a0d8bd2f24c3ebb9fbbb2edaf4c796b0dc73615ccea8e4f5bb248953
7
+ data.tar.gz: 2343e378d673146501843e35998b7e3efbd0ca8f32e3ee1e67b46dc96319d0f1e0fa23caf118da2e883135360b00a168ce7b4e5809bcd8e6c02726273ee87585
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 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: actionlint
22
+ 'on':
23
+ push:
24
+ branches:
25
+ - master
26
+ pull_request:
27
+ branches:
28
+ - master
29
+ jobs:
30
+ actionlint:
31
+ runs-on: ubuntu-24.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-24.04
29
+ steps:
30
+ - uses: actions/checkout@v4
31
+ - uses: ruby/setup-ruby@v1
32
+ with:
33
+ ruby-version: 3.3
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,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: copyrights
22
+ 'on':
23
+ push:
24
+ branches:
25
+ - master
26
+ pull_request:
27
+ branches:
28
+ - master
29
+ jobs:
30
+ copyrights:
31
+ runs-on: ubuntu-24.04
32
+ steps:
33
+ - uses: actions/checkout@v4
34
+ - uses: yegor256/copyrights-action@0.0.5
@@ -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 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: 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-24.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-24.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-24.04, macos-12]
35
+ ruby: [3.3]
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,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: xcop
22
+ 'on':
23
+ push:
24
+ branches:
25
+ - master
26
+ pull_request:
27
+ branches:
28
+ - master
29
+ jobs:
30
+ xcop:
31
+ runs-on: ubuntu-24.04
32
+ steps:
33
+ - uses: actions/checkout@v4
34
+ - uses: g4s8/xcop-action@master
@@ -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: yamllint
22
+ 'on':
23
+ push:
24
+ branches:
25
+ - master
26
+ pull_request:
27
+ branches:
28
+ - master
29
+ jobs:
30
+ yamllint:
31
+ runs-on: ubuntu-24.04
32
+ steps:
33
+ - uses: actions/checkout@v4
34
+ - uses: ibiqlik/action-yamllint@v3
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ coverage/
2
+ .idea/
3
+ *.gem
4
+ .bundle/
5
+ .DS_Store
6
+ rdoc/
7
+ doc/
8
+ .yardoc/
9
+ temp/
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,64 @@
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
+ Metrics/ParameterLists:
32
+ Enabled: false
33
+ Style/GlobalVars:
34
+ Enabled: false
35
+ Metrics/MethodLength:
36
+ Enabled: false
37
+ Gemspec/RequiredRubyVersion:
38
+ Enabled: false
39
+ Style/ClassAndModuleChildren:
40
+ Enabled: false
41
+ Layout/MultilineMethodCallIndentation:
42
+ Enabled: false
43
+ Metrics/AbcSize:
44
+ Enabled: false
45
+ Metrics/ClassLength:
46
+ Enabled: false
47
+ Metrics/BlockLength:
48
+ Enabled: false
49
+ Metrics/CyclomaticComplexity:
50
+ Enabled: false
51
+ Metrics/PerceivedComplexity:
52
+ Enabled: false
53
+ Layout/EmptyLineAfterGuardClause:
54
+ Enabled: false
55
+ Layout/CaseIndentation:
56
+ Enabled: false
57
+ Naming/MethodParameterName:
58
+ MinNameLength: 2
59
+ Layout/EndOfLine:
60
+ EnforcedStyle: lf
61
+ Layout/MultilineAssignmentLayout:
62
+ Enabled: true
63
+ Layout/FirstHashElementIndentation:
64
+ EnforcedStyle: consistent
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-ruby
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" qbash.gemspec
35
+ git add qbash.gemspec
36
+ git commit -m "version set to ${tag}"
37
+ gem build qbash.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 NONINFRINGEMENT. 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/Gemfile ADDED
@@ -0,0 +1,40 @@
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 'cucumber', '9.2.0', require: false
27
+ gem 'minitest', '5.25.1', require: false
28
+ gem 'minitest-reporters', '1.7.1', require: false
29
+ gem 'net-ping', '2.0.8', require: false
30
+ gem 'rake', '13.2.1', require: false
31
+ gem 'random-port', '~>0.0', require: false
32
+ gem 'rspec-rails', '7.0.1', require: false
33
+ gem 'rubocop', '1.66.1', require: false
34
+ gem 'rubocop-performance', '1.21.1', require: false
35
+ gem 'rubocop-rspec', '3.0.5', require: false
36
+ gem 'simplecov', '0.22.0', require: false
37
+ gem 'simplecov-cobertura', '2.1.0', require: false
38
+ gem 'w3c_validators', '1.3.7', require: false
39
+ gem 'webmock', '3.23.1', require: false
40
+ gem 'yard', '0.9.37', require: false
data/Gemfile.lock ADDED
@@ -0,0 +1,264 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ qbash (0.0.0)
5
+ backtrace (> 0)
6
+ elapsed (> 0)
7
+ loog (> 0)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ actionpack (7.2.1)
13
+ actionview (= 7.2.1)
14
+ activesupport (= 7.2.1)
15
+ nokogiri (>= 1.8.5)
16
+ racc
17
+ rack (>= 2.2.4, < 3.2)
18
+ rack-session (>= 1.0.1)
19
+ rack-test (>= 0.6.3)
20
+ rails-dom-testing (~> 2.2)
21
+ rails-html-sanitizer (~> 1.6)
22
+ useragent (~> 0.16)
23
+ actionview (7.2.1)
24
+ activesupport (= 7.2.1)
25
+ builder (~> 3.1)
26
+ erubi (~> 1.11)
27
+ rails-dom-testing (~> 2.2)
28
+ rails-html-sanitizer (~> 1.6)
29
+ activesupport (7.2.1)
30
+ base64
31
+ bigdecimal
32
+ concurrent-ruby (~> 1.0, >= 1.3.1)
33
+ connection_pool (>= 2.2.5)
34
+ drb
35
+ i18n (>= 1.6, < 2)
36
+ logger (>= 1.4.2)
37
+ minitest (>= 5.1)
38
+ securerandom (>= 0.3)
39
+ tzinfo (~> 2.0, >= 2.0.5)
40
+ addressable (2.8.7)
41
+ public_suffix (>= 2.0.2, < 7.0)
42
+ ansi (1.5.0)
43
+ ast (2.4.2)
44
+ backtrace (0.4.0)
45
+ base64 (0.2.0)
46
+ bigdecimal (3.1.8)
47
+ builder (3.3.0)
48
+ concurrent-ruby (1.3.4)
49
+ connection_pool (2.4.1)
50
+ crack (1.0.0)
51
+ bigdecimal
52
+ rexml
53
+ crass (1.0.6)
54
+ cucumber (9.2.0)
55
+ builder (~> 3.2)
56
+ cucumber-ci-environment (> 9, < 11)
57
+ cucumber-core (> 13, < 14)
58
+ cucumber-cucumber-expressions (~> 17.0)
59
+ cucumber-gherkin (> 24, < 28)
60
+ cucumber-html-formatter (> 20.3, < 22)
61
+ cucumber-messages (> 19, < 25)
62
+ diff-lcs (~> 1.5)
63
+ mini_mime (~> 1.1)
64
+ multi_test (~> 1.1)
65
+ sys-uname (~> 1.2)
66
+ cucumber-ci-environment (10.0.1)
67
+ cucumber-core (13.0.3)
68
+ cucumber-gherkin (>= 27, < 28)
69
+ cucumber-messages (>= 20, < 23)
70
+ cucumber-tag-expressions (> 5, < 7)
71
+ cucumber-cucumber-expressions (17.1.0)
72
+ bigdecimal
73
+ cucumber-gherkin (27.0.0)
74
+ cucumber-messages (>= 19.1.4, < 23)
75
+ cucumber-html-formatter (21.7.0)
76
+ cucumber-messages (> 19, < 27)
77
+ cucumber-messages (22.0.0)
78
+ cucumber-tag-expressions (6.1.0)
79
+ diff-lcs (1.5.1)
80
+ docile (1.4.1)
81
+ drb (2.2.1)
82
+ elapsed (0.0.1)
83
+ loog (> 0)
84
+ tago (> 0)
85
+ erubi (1.13.0)
86
+ ffi (1.17.0-aarch64-linux-gnu)
87
+ ffi (1.17.0-arm-linux-gnu)
88
+ ffi (1.17.0-arm64-darwin)
89
+ ffi (1.17.0-x64-mingw-ucrt)
90
+ ffi (1.17.0-x86-linux-gnu)
91
+ ffi (1.17.0-x86_64-darwin)
92
+ ffi (1.17.0-x86_64-linux-gnu)
93
+ hashdiff (1.1.1)
94
+ i18n (1.14.6)
95
+ concurrent-ruby (~> 1.0)
96
+ io-console (0.7.2)
97
+ irb (1.14.0)
98
+ rdoc (>= 4.0.0)
99
+ reline (>= 0.4.2)
100
+ json (2.7.2)
101
+ language_server-protocol (3.17.0.3)
102
+ logger (1.6.1)
103
+ loofah (2.22.0)
104
+ crass (~> 1.0.2)
105
+ nokogiri (>= 1.12.0)
106
+ loog (0.6.0)
107
+ mini_mime (1.1.5)
108
+ minitest (5.25.1)
109
+ minitest-reporters (1.7.1)
110
+ ansi
111
+ builder
112
+ minitest (>= 5.0)
113
+ ruby-progressbar
114
+ multi_test (1.1.0)
115
+ net-ping (2.0.8)
116
+ nokogiri (1.16.7-aarch64-linux)
117
+ racc (~> 1.4)
118
+ nokogiri (1.16.7-arm-linux)
119
+ racc (~> 1.4)
120
+ nokogiri (1.16.7-arm64-darwin)
121
+ racc (~> 1.4)
122
+ nokogiri (1.16.7-x64-mingw-ucrt)
123
+ racc (~> 1.4)
124
+ nokogiri (1.16.7-x86-linux)
125
+ racc (~> 1.4)
126
+ nokogiri (1.16.7-x86_64-darwin)
127
+ racc (~> 1.4)
128
+ nokogiri (1.16.7-x86_64-linux)
129
+ racc (~> 1.4)
130
+ parallel (1.26.3)
131
+ parser (3.3.5.0)
132
+ ast (~> 2.4.1)
133
+ racc
134
+ psych (5.1.2)
135
+ stringio
136
+ public_suffix (6.0.1)
137
+ racc (1.8.1)
138
+ rack (3.1.7)
139
+ rack-session (2.0.0)
140
+ rack (>= 3.0.0)
141
+ rack-test (2.1.0)
142
+ rack (>= 1.3)
143
+ rackup (2.1.0)
144
+ rack (>= 3)
145
+ webrick (~> 1.8)
146
+ rails-dom-testing (2.2.0)
147
+ activesupport (>= 5.0.0)
148
+ minitest
149
+ nokogiri (>= 1.6)
150
+ rails-html-sanitizer (1.6.0)
151
+ loofah (~> 2.21)
152
+ nokogiri (~> 1.14)
153
+ railties (7.2.1)
154
+ actionpack (= 7.2.1)
155
+ activesupport (= 7.2.1)
156
+ irb (~> 1.13)
157
+ rackup (>= 1.0.0)
158
+ rake (>= 12.2)
159
+ thor (~> 1.0, >= 1.2.2)
160
+ zeitwerk (~> 2.6)
161
+ rainbow (3.1.1)
162
+ rake (13.2.1)
163
+ random-port (0.7.1)
164
+ rdoc (6.7.0)
165
+ psych (>= 4.0.0)
166
+ regexp_parser (2.9.2)
167
+ reline (0.5.10)
168
+ io-console (~> 0.5)
169
+ rexml (3.3.7)
170
+ rspec-core (3.13.1)
171
+ rspec-support (~> 3.13.0)
172
+ rspec-expectations (3.13.3)
173
+ diff-lcs (>= 1.2.0, < 2.0)
174
+ rspec-support (~> 3.13.0)
175
+ rspec-mocks (3.13.1)
176
+ diff-lcs (>= 1.2.0, < 2.0)
177
+ rspec-support (~> 3.13.0)
178
+ rspec-rails (7.0.1)
179
+ actionpack (>= 7.0)
180
+ activesupport (>= 7.0)
181
+ railties (>= 7.0)
182
+ rspec-core (~> 3.13)
183
+ rspec-expectations (~> 3.13)
184
+ rspec-mocks (~> 3.13)
185
+ rspec-support (~> 3.13)
186
+ rspec-support (3.13.1)
187
+ rubocop (1.66.1)
188
+ json (~> 2.3)
189
+ language_server-protocol (>= 3.17.0)
190
+ parallel (~> 1.10)
191
+ parser (>= 3.3.0.2)
192
+ rainbow (>= 2.2.2, < 4.0)
193
+ regexp_parser (>= 2.4, < 3.0)
194
+ rubocop-ast (>= 1.32.2, < 2.0)
195
+ ruby-progressbar (~> 1.7)
196
+ unicode-display_width (>= 2.4.0, < 3.0)
197
+ rubocop-ast (1.32.3)
198
+ parser (>= 3.3.1.0)
199
+ rubocop-performance (1.21.1)
200
+ rubocop (>= 1.48.1, < 2.0)
201
+ rubocop-ast (>= 1.31.1, < 2.0)
202
+ rubocop-rspec (3.0.5)
203
+ rubocop (~> 1.61)
204
+ ruby-progressbar (1.13.0)
205
+ securerandom (0.3.1)
206
+ simplecov (0.22.0)
207
+ docile (~> 1.1)
208
+ simplecov-html (~> 0.11)
209
+ simplecov_json_formatter (~> 0.1)
210
+ simplecov-cobertura (2.1.0)
211
+ rexml
212
+ simplecov (~> 0.19)
213
+ simplecov-html (0.13.1)
214
+ simplecov_json_formatter (0.1.4)
215
+ stringio (3.1.1)
216
+ sys-uname (1.3.0)
217
+ ffi (~> 1.1)
218
+ tago (0.0.2)
219
+ thor (1.3.2)
220
+ tzinfo (2.0.6)
221
+ concurrent-ruby (~> 1.0)
222
+ unicode-display_width (2.6.0)
223
+ useragent (0.16.10)
224
+ w3c_validators (1.3.7)
225
+ json (>= 1.8)
226
+ nokogiri (~> 1.6)
227
+ rexml (~> 3.2)
228
+ webmock (3.23.1)
229
+ addressable (>= 2.8.0)
230
+ crack (>= 0.3.2)
231
+ hashdiff (>= 0.4.0, < 2.0.0)
232
+ webrick (1.8.1)
233
+ yard (0.9.37)
234
+ zeitwerk (2.6.18)
235
+
236
+ PLATFORMS
237
+ aarch64-linux
238
+ arm-linux
239
+ arm64-darwin
240
+ x64-mingw-ucrt
241
+ x86-linux
242
+ x86_64-darwin
243
+ x86_64-linux
244
+
245
+ DEPENDENCIES
246
+ cucumber (= 9.2.0)
247
+ minitest (= 5.25.1)
248
+ minitest-reporters (= 1.7.1)
249
+ net-ping (= 2.0.8)
250
+ qbash!
251
+ rake (= 13.2.1)
252
+ random-port (~> 0.0)
253
+ rspec-rails (= 7.0.1)
254
+ rubocop (= 1.66.1)
255
+ rubocop-performance (= 1.21.1)
256
+ rubocop-rspec (= 3.0.5)
257
+ simplecov (= 0.22.0)
258
+ simplecov-cobertura (= 2.1.0)
259
+ w3c_validators (= 1.3.7)
260
+ webmock (= 3.23.1)
261
+ yard (= 0.9.37)
262
+
263
+ BUNDLED WITH
264
+ 2.5.16
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,52 @@
1
+ # Quick and Simple Executor of Bash Commands
2
+
3
+ [![DevOps By Rultor.com](http://www.rultor.com/b/yegor256/bash)](http://www.rultor.com/p/yegor256/bash)
4
+ [![We recommend RubyMine](https://www.elegantobjects.org/rubymine.svg)](https://www.jetbrains.com/ruby/)
5
+
6
+ [![rake](https://github.com/yegor256/bash/actions/workflows/rake.yml/badge.svg)](https://github.com/yegor256/bash/actions/workflows/rake.yml)
7
+ [![PDD status](http://www.0pdd.com/svg?name=yegor256/bash)](http://www.0pdd.com/p?name=yegor256/bash)
8
+ [![Gem Version](https://badge.fury.io/rb/bash.svg)](http://badge.fury.io/rb/bash)
9
+ [![Test Coverage](https://img.shields.io/codecov/c/github/yegor256/bash.svg)](https://codecov.io/github/yegor256/bash?branch=master)
10
+ [![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](http://rubydoc.info/github/yegor256/bash/master/frames)
11
+ [![Hits-of-Code](https://hitsofcode.com/github/yegor256/bash)](https://hitsofcode.com/view/github/yegor256/bash)
12
+ [![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/yegor256/bash/blob/master/LICENSE.txt)
13
+
14
+ First, install it:
15
+
16
+ ```bash
17
+ gem install qbash
18
+ ```
19
+
20
+ Simply execute a bash command from Ruby:
21
+
22
+ ```ruby
23
+ require 'qbash'
24
+ stdout = qbash('echo "Hello, world!"')
25
+ ```
26
+
27
+ If the command fails, an exception will be raised.
28
+
29
+ It's possible to provide the standard input and environment variables:
30
+
31
+ ```ruby
32
+ stdout = qbash('cat > $FILE', env: { 'FILE' => 'a.txt' }, stdin: 'Hello!')
33
+ ```
34
+
35
+ It's possible to configure the logging facility too, with the help
36
+ of the [loog](https://github.com/yegor256/loog) gem.
37
+
38
+ ## How to contribute
39
+
40
+ Read
41
+ [these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).
42
+ Make sure you build is green before you contribute
43
+ your pull request. You will need to have
44
+ [Ruby](https://www.ruby-lang.org/en/) 3.0+ and
45
+ [Bundler](https://bundler.io/) installed. Then:
46
+
47
+ ```bash
48
+ bundle update
49
+ bundle exec rake
50
+ ```
51
+
52
+ If it's clean and you don't see any error messages, submit your pull request.
data/Rakefile ADDED
@@ -0,0 +1,70 @@
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 'rdoc'
26
+ require 'rake/clean'
27
+
28
+ def name
29
+ @name ||= File.basename(Dir['*.gemspec'].first, '.*')
30
+ end
31
+
32
+ def version
33
+ Gem::Specification.load(Dir['*.gemspec'].first).version
34
+ end
35
+
36
+ ENV['RACK_ENV'] = 'test'
37
+
38
+ task default: %i[clean test rubocop yard copyright]
39
+
40
+ require 'rake/testtask'
41
+ desc 'Run all unit tests'
42
+ Rake::TestTask.new(:test) do |test|
43
+ Rake::Cleaner.cleanup_files(['coverage'])
44
+ test.libs << 'lib' << 'test'
45
+ test.pattern = 'test/**/test_*.rb'
46
+ test.warning = true
47
+ test.verbose = false
48
+ end
49
+
50
+ require 'yard'
51
+ desc 'Build Yard documentation'
52
+ YARD::Rake::YardocTask.new do |t|
53
+ t.files = ['lib/**/*.rb']
54
+ end
55
+
56
+ require 'rubocop/rake_task'
57
+ desc 'Run RuboCop on all directories'
58
+ RuboCop::RakeTask.new(:rubocop) do |task|
59
+ task.fail_on_error = true
60
+ task.requires << 'rubocop-rspec'
61
+ end
62
+
63
+ task :copyright do
64
+ sh "grep -q -r '#{Date.today.strftime('%Y')}' \
65
+ --include '*.rb' \
66
+ --include '*.yml' \
67
+ --include '*.txt' \
68
+ --include 'Rakefile' \
69
+ ."
70
+ end
data/lib/qbash.rb ADDED
@@ -0,0 +1,69 @@
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 'open3'
24
+ require 'loog'
25
+ require 'backtrace'
26
+
27
+ # Execute one bash command.
28
+ #
29
+ # Author:: Yegor Bugayenko (yegor256@gmail.com)
30
+ # Copyright:: Copyright (c) 2024 Yegor Bugayenko
31
+ # License:: MIT
32
+ module Kernel
33
+ # Execute a single bash command.
34
+ #
35
+ # If exit code is not zero, an exception will be raised.
36
+ #
37
+ # To escape arguments, use +Shellwords.escape()+ method.
38
+ #
39
+ # @param [String] cmd The command to run
40
+ # @param [String] stdin Input string
41
+ # @param [Hash] env Environment variables
42
+ # @param [Loog] loog Logging facility with +.debug()+ method
43
+ # @param [Array] accept List of accepted exit codes (accept all if empty)
44
+ # @param [Boolean] both If set to TRUE, the function returns an array +(stdout, code)+
45
+ # @return [String] Stdout
46
+ def qbash(cmd, stdin: '', env: {}, loog: Loog::NULL, accept: [0], both: false)
47
+ loog.debug("+ #{cmd}")
48
+ buf = ''
49
+ e = 1
50
+ cmd = cmd.join(' ') if cmd.is_a?(Array)
51
+ Open3.popen2e(env, "/bin/bash -c #{Shellwords.escape(cmd)}") do |sin, sout, thr|
52
+ sin.write(stdin)
53
+ sin.close
54
+ until sout.eof?
55
+ begin
56
+ ln = sout.gets
57
+ rescue IOError => e
58
+ ln = Backtrace.new(e).to_s
59
+ end
60
+ loog.debug(ln)
61
+ buf += ln
62
+ end
63
+ e = thr.value.to_i
64
+ raise "The command '#{cmd}' failed with exit code ##{e}\n#{buf}" if !accept.empty? && !accept.include?(e)
65
+ end
66
+ return [buf, e] if both
67
+ buf
68
+ end
69
+ end
data/qbash.gemspec ADDED
@@ -0,0 +1,46 @@
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
+
25
+ Gem::Specification.new do |s|
26
+ s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
27
+ s.required_ruby_version = '>=3.2'
28
+ s.name = 'qbash'
29
+ s.version = '0.0.1'
30
+ s.license = 'MIT'
31
+ s.summary = 'Quick Executor of a BASH Command'
32
+ s.description =
33
+ 'With the help of Open3 executes bash command and conveniently ' \
34
+ 'returns its output and exit code'
35
+ s.authors = ['Yegor Bugayenko']
36
+ s.email = 'yegor256@gmail.com'
37
+ s.homepage = 'http://github.com/yegor256/qbash'
38
+ s.files = `git ls-files`.split($RS)
39
+ s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
40
+ s.rdoc_options = ['--charset=UTF-8']
41
+ s.extra_rdoc_files = ['README.md', 'LICENSE.txt']
42
+ s.add_dependency 'backtrace', '>0'
43
+ s.add_dependency 'elapsed', '>0'
44
+ s.add_dependency 'loog', '>0'
45
+ s.metadata['rubygems_mfa_required'] = 'true'
46
+ 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,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
+ $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'
32
+
33
+ require 'minitest/reporters'
34
+ Minitest::Reporters.use! [Minitest::Reporters::SpecReporter.new]
@@ -0,0 +1,79 @@
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 'minitest/autorun'
24
+ require 'tmpdir'
25
+ require 'loog'
26
+ require 'shellwords'
27
+ require_relative 'test__helper'
28
+ require_relative '../lib/qbash'
29
+
30
+ # Test.
31
+ # Author:: Yegor Bugayenko (yegor256@gmail.com)
32
+ # Copyright:: Copyright (c) 2024 Yegor Bugayenko
33
+ # License:: MIT
34
+ class TestQbash < Minitest::Test
35
+ def test_basic_run
36
+ Dir.mktmpdir do |home|
37
+ qbash("cd #{Shellwords.escape(home)}; echo $FOO | cat > a.txt", env: { 'FOO' => '42' })
38
+ assert(File.exist?(File.join(home, 'a.txt')))
39
+ assert_equal("42\n", File.read(File.join(home, 'a.txt')))
40
+ end
41
+ end
42
+
43
+ def test_command_as_array
44
+ assert_equal('123', qbash(['printf 1;', 'printf 2;', 'printf 3']))
45
+ end
46
+
47
+ def test_with_stdin
48
+ Dir.mktmpdir do |home|
49
+ f = File.join(home, 'a b c.txt')
50
+ qbash("cat > #{Shellwords.escape(f)}", stdin: 'hello')
51
+ assert(File.exist?(f))
52
+ assert_equal('hello', File.read(f))
53
+ end
54
+ end
55
+
56
+ def test_with_special_symbols
57
+ assert_equal("'hi'\n", qbash("echo \"'hi'\""))
58
+ end
59
+
60
+ def test_with_error
61
+ Dir.mktmpdir do |home|
62
+ assert_raises { qbash("cat #{Shellwords.escape(File.join(home, 'b.txt'))}") }
63
+ end
64
+ end
65
+
66
+ def test_ignore_errors
67
+ Dir.mktmpdir do |home|
68
+ qbash("cat #{Shellwords.escape(File.join(home, 'b.txt'))}", accept: [])
69
+ end
70
+ end
71
+
72
+ def test_with_both
73
+ Dir.mktmpdir do |home|
74
+ stdout, code = qbash("cat #{Shellwords.escape(File.join(home, 'foo.txt'))}", accept: [], both: true)
75
+ assert(code.positive?)
76
+ assert(!stdout.empty?)
77
+ end
78
+ end
79
+ end
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: qbash
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-09-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: backtrace
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">"
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">"
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: elapsed
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">"
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">"
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: loog
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">"
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">"
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: With the help of Open3 executes bash command and conveniently returns
56
+ its output and exit code
57
+ email: yegor256@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files:
61
+ - README.md
62
+ - LICENSE.txt
63
+ files:
64
+ - ".0pdd.yml"
65
+ - ".gitattributes"
66
+ - ".github/workflows/actionlint.yml"
67
+ - ".github/workflows/codecov.yml"
68
+ - ".github/workflows/copyrights.yml"
69
+ - ".github/workflows/markdown-lint.yml"
70
+ - ".github/workflows/pdd.yml"
71
+ - ".github/workflows/rake.yml"
72
+ - ".github/workflows/xcop.yml"
73
+ - ".github/workflows/yamllint.yml"
74
+ - ".gitignore"
75
+ - ".pdd"
76
+ - ".rubocop.yml"
77
+ - ".rultor.yml"
78
+ - ".simplecov"
79
+ - Gemfile
80
+ - Gemfile.lock
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - lib/qbash.rb
85
+ - qbash.gemspec
86
+ - renovate.json
87
+ - test/test__helper.rb
88
+ - test/test_qbash.rb
89
+ homepage: http://github.com/yegor256/qbash
90
+ licenses:
91
+ - MIT
92
+ metadata:
93
+ rubygems_mfa_required: 'true'
94
+ post_install_message:
95
+ rdoc_options:
96
+ - "--charset=UTF-8"
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '3.2'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubygems_version: 3.4.10
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: Quick Executor of a BASH Command
114
+ test_files: []