cmd_executable 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: cae728361db48c6d1ea1efeae2d909d4c15374c40cf129ef16cbd6dcd6dcf36a
4
+ data.tar.gz: e08d899f9e6e1f823f1e6053781f3550125ecec893210139066481c5cc743c31
5
+ SHA512:
6
+ metadata.gz: 1ec669180c5fb42079f403fe6fcc975285f7aa864eb4b08e4e0f0ef6bebb804318b58d0ec03fc22bff4303791b3fd0a920651710bf5524d4599c8e817b7ba075
7
+ data.tar.gz: 34ea3ba543c927b4d9f62b722cc04e38e64f63f651acc83c783a28473e45d5e8ebada2f857b7f2bfbe7f4f875e5003d91f22cfa147afe2761b0a13a891353b17
@@ -0,0 +1,50 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Release
9
+
10
+ on:
11
+ push:
12
+ branches: [ master ]
13
+ pull_request:
14
+ branches: [ master ]
15
+
16
+ jobs:
17
+ release:
18
+
19
+ runs-on: ubuntu-latest
20
+
21
+ steps:
22
+ - uses: actions/checkout@v2
23
+ - name: Set up Ruby
24
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
25
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
26
+ # uses: ruby/setup-ruby@v1
27
+ uses: ruby/setup-ruby@ec106b438a1ff6ff109590de34ddc62c540232e0
28
+ with:
29
+ ruby-version: 2.7
30
+ - name: Install dependencies
31
+ run: |
32
+ bundle config set path 'vendor/bundle'
33
+ bundle install --jobs=8
34
+ - name: Create credentials
35
+ run: |
36
+ mkdir -p ~/.gem
37
+ echo '---' > ~/.gem/credentials
38
+ echo ":rubygems_api_key: $RUBYGEMS_API_ACCESS_KEY" >> ~/.gem/credentials
39
+ chmod 0600 ~/.gem/credentials
40
+ - name: Setup git
41
+ run: |
42
+ git config push.default current
43
+ git config user.email "toshiki.dev@protonmail.ch"
44
+ git config user.name "Toshiki"
45
+ - name: Release
46
+ run: |
47
+ bundle exec rake build
48
+ bundle exec rake release
49
+ - name: Remove credentials
50
+ run: shred -u ~/.gem/credentials
@@ -0,0 +1,65 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Ruby
9
+
10
+ on:
11
+ push:
12
+ branches:
13
+ - master
14
+ - develop
15
+ - feature/*
16
+ - bugfix/*
17
+ - hotfix/*
18
+ - release/*
19
+ pull_request:
20
+ branches:
21
+ - master
22
+ - develop
23
+ - feature/*
24
+ - bugfix/*
25
+ - hotfix/*
26
+ - release/*
27
+ schedule:
28
+ - cron: '0 15 * * 5'
29
+
30
+ jobs:
31
+ rspec:
32
+ runs-on: ubuntu-latest
33
+ steps:
34
+ - uses: actions/checkout@v2
35
+ - name: Set up Ruby
36
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
37
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
38
+ # uses: ruby/setup-ruby@v1
39
+ uses: ruby/setup-ruby@ec106b438a1ff6ff109590de34ddc62c540232e0
40
+ with:
41
+ ruby-version: 2.7
42
+ - name: Install dependencies
43
+ run: |
44
+ bundle config set path 'vendor/bundle'
45
+ bundle install --jobs=8
46
+ - name: Run rspec
47
+ run: bundle exec rspec
48
+
49
+ rubocop:
50
+ runs-on: ubuntu-latest
51
+ steps:
52
+ - uses: actions/checkout@v2
53
+ - name: Set up Ruby
54
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
55
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
56
+ # uses: ruby/setup-ruby@v1
57
+ uses: ruby/setup-ruby@ec106b438a1ff6ff109590de34ddc62c540232e0
58
+ with:
59
+ ruby-version: 2.7
60
+ - name: Install dependencies
61
+ run: |
62
+ bundle config set path 'vendor/bundle'
63
+ bundle install --jobs=8
64
+ - name: Run rubocop
65
+ run: bundle exec rubocop
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+
13
+ Gemfile.lock
@@ -0,0 +1,3 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.7.0
3
+ NewCops: enable
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.7.1
6
+ before_install: gem install bundler -v 2.1.4
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at toshiki.dev@protonmail.ch. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in cmd_executable.gemspec
6
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Toshiki
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1,61 @@
1
+ <a href="LICENSE" alt="MIT License"><img alt="GitHub" src="https://img.shields.io/github/license/toshiki670/cmd_executable?style=flat-square"></a>
2
+ <a href="https://github.com/toshiki670/cmd_executable/actions" alt="Check action"><img alt="GitHub" src="https://img.shields.io/github/workflow/status/toshiki670/cmd_executable/Ruby?label=Ruby&style=flat-square"></a>
3
+ <a href="https://rubygems.org/gems/cmd_executable" alt="Rubygems"><img alt="GitHub" src="https://img.shields.io/gem/dt/cmd_executable?style=flat-square"></a>
4
+ <a href="https://rubygems.org/gems/cmd_executable" alt="Rubygems"><img alt="GitHub" src="https://img.shields.io/gem/v/cmd_executable?style=flat-square"></a>
5
+
6
+ # CmdExecutable
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'cmd_executable'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install cmd_executable
22
+
23
+ ## Usage
24
+ ```
25
+ require 'cmd_executable'
26
+
27
+ class Klass
28
+ include 'CmdExecutable'
29
+
30
+ def instance_method
31
+ executable?('ls')
32
+ end
33
+ end
34
+ ```
35
+
36
+ ## Development
37
+
38
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
39
+
40
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
41
+
42
+ ## Contributing
43
+
44
+ Bug reports and pull requests are welcome on [GitHub][source]. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct][conduct].
45
+
46
+
47
+ ## License
48
+
49
+ The gem is available as open source under the terms of the [MIT License][license].
50
+
51
+ ## Code of Conduct
52
+
53
+ Everyone interacting in the CmdExecutable project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct][conduct].
54
+
55
+ ## Other links
56
+ - [Version History][version]
57
+
58
+ [source]:https://github.com/toshiki670/cmd_executable
59
+ [license]:https://github.com/toshiki670/cmd_executable/blob/master/LICENSE
60
+ [conduct]:https://github.com/toshiki670/cmd_executable/blob/master/CODE_OF_CONDUCT.md
61
+ [version]:https://github.com/toshiki670/cmd_executable/releases
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'cmd_executable'
6
+ require 'pry'
7
+
8
+ Pry.start
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle config set path 'vendor/bundle'
7
+ bundle install --jobs=8
8
+
9
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/cmd_executable/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'cmd_executable'
7
+ spec.version = CmdExecutable::VERSION
8
+ spec.authors = ['Toshiki']
9
+ spec.email = ['toshiki.dev@protonmail.ch']
10
+
11
+ spec.summary = 'The command executable module.'
12
+ spec.description = 'Please include CmdExecutable'
13
+ spec.homepage = 'https://github.com/toshiki670/cmd_executable/wiki'
14
+ spec.license = 'MIT'
15
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
16
+
17
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
18
+
19
+ spec.metadata['homepage_uri'] = spec.homepage
20
+ spec.metadata['source_code_uri'] = 'https://github.com/toshiki670/cmd_executable'
21
+ spec.metadata['changelog_uri'] = 'https://github.com/toshiki670/cmd_executable/releases'
22
+
23
+ # Specify which files should be added to the gem when it is released.
24
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
26
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
27
+ end
28
+ spec.bindir = 'exe'
29
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ['lib']
31
+
32
+ spec.add_development_dependency 'bundler'
33
+ spec.add_development_dependency 'pry'
34
+ spec.add_development_dependency 'rake'
35
+ spec.add_development_dependency 'rspec'
36
+ spec.add_development_dependency 'rubocop'
37
+ end
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'cmd_executable'
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ # The MIT License (MIT)
4
+ #
5
+ # Copyright (c) 2020 Toshiki
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the "Software"), to deal
9
+ # in the Software without restriction, including without limitation the rights
10
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ # copies of the Software, and to permit persons to whom the Software is
12
+ # furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included in
15
+ # all copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ # THE SOFTWARE.
24
+
25
+ require 'English'
26
+ require 'cmd_executable/version'
27
+
28
+ # Command Executable
29
+ #
30
+ # Usage:
31
+ # require 'cmd_executable'
32
+ #
33
+ # class Klass
34
+ # include 'CmdExecutable'
35
+ #
36
+ # def instance_method
37
+ # executable?('ls')
38
+ # end
39
+ # end
40
+ module CmdExecutable
41
+ class CmdExecutableError < StandardError; end
42
+
43
+ def executable?(command)
44
+ path = File.split(command).yield_self do |dirname, basename|
45
+ dirname = File.absolute_path?(dirname) ? dirname : ''
46
+ dirname += File::SEPARATOR if dirname.rindex(File::SEPARATOR)
47
+ dirname + basename.split.first
48
+ end
49
+
50
+ `type '#{path}' > /dev/null 2>&1`.yield_self do
51
+ $CHILD_STATUS.success?
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CmdExecutable
4
+ VERSION = '0.1.4'
5
+ end
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cmd_executable
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.4
5
+ platform: ruby
6
+ authors:
7
+ - Toshiki
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-06-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
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: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
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: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Please include CmdExecutable
84
+ email:
85
+ - toshiki.dev@protonmail.ch
86
+ executables:
87
+ - cmd_executable
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".github/workflows/release.yml"
92
+ - ".github/workflows/ruby_check.yml"
93
+ - ".gitignore"
94
+ - ".rubocop.yml"
95
+ - ".travis.yml"
96
+ - CODE_OF_CONDUCT.md
97
+ - Gemfile
98
+ - LICENSE
99
+ - README.md
100
+ - Rakefile
101
+ - bin/console
102
+ - bin/setup
103
+ - cmd_executable.gemspec
104
+ - exe/cmd_executable
105
+ - lib/cmd_executable.rb
106
+ - lib/cmd_executable/version.rb
107
+ homepage: https://github.com/toshiki670/cmd_executable/wiki
108
+ licenses:
109
+ - MIT
110
+ metadata:
111
+ allowed_push_host: https://rubygems.org
112
+ homepage_uri: https://github.com/toshiki670/cmd_executable/wiki
113
+ source_code_uri: https://github.com/toshiki670/cmd_executable
114
+ changelog_uri: https://github.com/toshiki670/cmd_executable/releases
115
+ post_install_message:
116
+ rdoc_options: []
117
+ require_paths:
118
+ - lib
119
+ required_ruby_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: 2.3.0
124
+ required_rubygems_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ requirements: []
130
+ rubygems_version: 3.1.3
131
+ signing_key:
132
+ specification_version: 4
133
+ summary: The command executable module.
134
+ test_files: []