check_names 0.1.0
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 +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +8 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/LICENSE.txt +22 -0
- data/README.md +59 -0
- data/Rakefile +6 -0
- data/VERSION.txt +1 -0
- data/exe/check_names +62 -0
- data/lib/.keep +0 -0
- data/lib/check_names/version.rb +9 -0
- data/lib/check_names.rb +67 -0
- data/sig/check_names.rbs +4 -0
- metadata +63 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5ae24e5c2f8e58e99a99cbc138ae6956f8bc36c3c7bbfa9b07f19e955baba5b2
|
4
|
+
data.tar.gz: 65d72a1e16ec15f331da734b970d0f5b02079ef615996fcebc0efe4dac93d665
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7f5e70c3081b31e1f32e0b7cbc485bcfcd86db99f300d5590b4c76890bf9a0ec107901c0e08986787ac30933699d52a42d5fdfdc28b1e1110e0d7b57d6143493
|
7
|
+
data.tar.gz: 496da5b5fafe22d439b89424d3a059a587906752715d8a9fbf51b8f058403f692e030a68c2466233856e1da0b60029cb61cf37e71ad58ce962734ebaa4933564
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -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 richard.leber@gmail.com. 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/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT LICENSE
|
2
|
+
|
3
|
+
Copyright (c) 2020 Richard LeBer
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# check_names
|
2
|
+
|
3
|
+
http://github.com/rleber/check_names
|
4
|
+
|
5
|
+
## Description
|
6
|
+
|
7
|
+
To be provided
|
8
|
+
|
9
|
+
## Features
|
10
|
+
|
11
|
+
* To be provided
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
require 'check_names'
|
16
|
+
...
|
17
|
+
|
18
|
+
## Requirements
|
19
|
+
|
20
|
+
* None
|
21
|
+
|
22
|
+
## Installation
|
23
|
+
|
24
|
+
### For an app, with bundler
|
25
|
+
|
26
|
+
* Add this to your application's Gemfile:
|
27
|
+
```ruby
|
28
|
+
gem 'check_names'
|
29
|
+
```
|
30
|
+
|
31
|
+
* And then execute:
|
32
|
+
|
33
|
+
$ bundle install* gem install check_names
|
34
|
+
|
35
|
+
### Without bundler
|
36
|
+
|
37
|
+
$ gem install check_names
|
38
|
+
|
39
|
+
## Development
|
40
|
+
|
41
|
+
* Run `bin/setup` to install dependencies.
|
42
|
+
* Run `rake spec` (or just `rake`) to run the tests.
|
43
|
+
* Run `console` to experiment with the gem.
|
44
|
+
* Run `bundle exec rake install` to install this gem on your system.
|
45
|
+
* To release a new version, update the version number in `VERSION.txt`
|
46
|
+
* You may 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).
|
47
|
+
|
48
|
+
## Contributing
|
49
|
+
|
50
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/rleber/check_names.
|
51
|
+
|
52
|
+
|
53
|
+
## License
|
54
|
+
|
55
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
56
|
+
|
57
|
+
## Code of Conduct
|
58
|
+
|
59
|
+
This project is intended to be a safe, welcoming space for collaboration. Everyone interacting in the check_names project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/rleber/check_names/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/VERSION.txt
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
data/exe/check_names
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Check: Does a gem name exist
|
4
|
+
# Usage:
|
5
|
+
# check_names <name>
|
6
|
+
|
7
|
+
# Where to check:
|
8
|
+
# 1. Does a Rubygem of this name already exist?
|
9
|
+
# 2. Does a Github repository of mine with this name already exist?
|
10
|
+
# 3. Does an executable with this name already exist?
|
11
|
+
# 4. Does an alias with this name already exist?
|
12
|
+
# 5. Does a function with this name already exist?
|
13
|
+
|
14
|
+
require_relative '../lib/check_names/version'
|
15
|
+
require_relative '../lib/check_names'
|
16
|
+
|
17
|
+
def show_help
|
18
|
+
puts <<-HELP
|
19
|
+
check_names: Check whether a proposed gem name already exists
|
20
|
+
Version #{GemName.version}
|
21
|
+
|
22
|
+
Usage:
|
23
|
+
check_names [OPTIONS]... [names]...
|
24
|
+
|
25
|
+
check_names exits with a zero return code (success) if no conflicting gem
|
26
|
+
name exists. Otherwise it exits with a non-zero return code, with one
|
27
|
+
of the following meanings:
|
28
|
+
|
29
|
+
1 A gem exists on Rubygems with this name
|
30
|
+
2 You have a github repository of this name
|
31
|
+
3 You have an executable (reachable via \$PATH) with this name
|
32
|
+
4 You have a shell function with this name
|
33
|
+
5 You have an alias with this name
|
34
|
+
|
35
|
+
The following options are supported:
|
36
|
+
|
37
|
+
--help -h Print this help information
|
38
|
+
--verbose -v Print messages about the status of the name check
|
39
|
+
HELP
|
40
|
+
end
|
41
|
+
|
42
|
+
def main(args)
|
43
|
+
args = args.map { |arg| arg.downcase }
|
44
|
+
verbose = args.index { |arg| %w{-v --verbose}.include?(arg) }
|
45
|
+
args.delete_at(verbose) if verbose
|
46
|
+
if args.size == 0 || %w{-h --help help}.include?(args.first)
|
47
|
+
show_help
|
48
|
+
exit
|
49
|
+
end
|
50
|
+
verbose ||= arg.size > 1
|
51
|
+
rc = 0
|
52
|
+
args.each do |arg|
|
53
|
+
status = GemName.check(arg)
|
54
|
+
puts "#{arg}: #{status[:message]}." if verbose
|
55
|
+
rc = status[:rc] if status[:rc] > rc
|
56
|
+
end
|
57
|
+
exit(rc)
|
58
|
+
end
|
59
|
+
|
60
|
+
if __FILE__ == $0
|
61
|
+
main(ARGV)
|
62
|
+
end
|
data/lib/.keep
ADDED
File without changes
|
data/lib/check_names.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "check_names/version"
|
4
|
+
require 'shellwords'
|
5
|
+
require 'httparty'
|
6
|
+
|
7
|
+
module GemName
|
8
|
+
class Error < StandardError; end
|
9
|
+
|
10
|
+
def self.ruby_gem_exists?(name)
|
11
|
+
response = HTTParty.get("https://rubygems.org/gems/#{name}")
|
12
|
+
response.code == 200
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.github_repository_exists?(name)
|
16
|
+
github_user = `git config github.user`.chomp
|
17
|
+
system("git ls-remote https://github.com/#{Shellwords.escape(github_user)}/#{Shellwords.escape(name)} 2>/dev/null >/dev/null")
|
18
|
+
end
|
19
|
+
|
20
|
+
# Note: This method does not distinguish between executables, functions, and aliases
|
21
|
+
def self.is_executable?(name)
|
22
|
+
system("zsh -lic 'which #{Shellwords.escape(name)}' >/dev/null")
|
23
|
+
end
|
24
|
+
|
25
|
+
# Note: This version explicitly excludes functions and aliases
|
26
|
+
def self.executable_exists?(name)
|
27
|
+
return false if self.function_exists?(name)
|
28
|
+
return false if self.alias_exists?(name)
|
29
|
+
self.is_executable?(name)
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.function_exists?(name)
|
33
|
+
test_command = <<-COMMAND
|
34
|
+
if typeset -f #{Shellwords.escape(name)} > /dev/null; then
|
35
|
+
return 0
|
36
|
+
else
|
37
|
+
return 1
|
38
|
+
fi
|
39
|
+
COMMAND
|
40
|
+
test_command_lines = test_command.split("\n")
|
41
|
+
zsh_command = "zsh -lic '#{test_command_lines.join(';')}' >/dev/null"
|
42
|
+
system(zsh_command)
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.alias_exists?(name)
|
46
|
+
system("zsh -lic 'alias #{Shellwords.escape(name)}' >/dev/null")
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.check(name)
|
50
|
+
if ruby_gem_exists?(name)
|
51
|
+
return {rc: 1, message: "A Gem on RubyGems"}
|
52
|
+
end
|
53
|
+
if github_repository_exists?(name)
|
54
|
+
return {rc: 2, message: "A personal Github repository"}
|
55
|
+
end
|
56
|
+
if executable_exists?(name)
|
57
|
+
return {rc: 3, message: "An executable"}
|
58
|
+
end
|
59
|
+
if function_exists?(name)
|
60
|
+
return {rc: 4, message: "A function"}
|
61
|
+
end
|
62
|
+
if alias_exists?(name)
|
63
|
+
return {rc: 5, message: "An alias"}
|
64
|
+
end
|
65
|
+
{rc: 0, message: "Available"}
|
66
|
+
end
|
67
|
+
end
|
data/sig/check_names.rbs
ADDED
metadata
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: check_names
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Richard LeBer
|
8
|
+
bindir: exe
|
9
|
+
cert_chain: []
|
10
|
+
date: 2025-06-14 00:00:00.000000000 Z
|
11
|
+
dependencies: []
|
12
|
+
description: Check whether names are in use
|
13
|
+
email:
|
14
|
+
- richard.leber@gmail.com
|
15
|
+
executables:
|
16
|
+
- check_names
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- ".rspec"
|
21
|
+
- ".rubocop.yml"
|
22
|
+
- CHANGELOG.md
|
23
|
+
- CODE_OF_CONDUCT.md
|
24
|
+
- LICENSE.txt
|
25
|
+
- README.md
|
26
|
+
- Rakefile
|
27
|
+
- VERSION.txt
|
28
|
+
- exe/check_names
|
29
|
+
- lib/.keep
|
30
|
+
- lib/check_names.rb
|
31
|
+
- lib/check_names/version.rb
|
32
|
+
- sig/check_names.rbs
|
33
|
+
homepage: http://github.com/rleber/check_names
|
34
|
+
licenses:
|
35
|
+
- MIT
|
36
|
+
metadata:
|
37
|
+
homepage_uri: http://github.com/rleber/check_names
|
38
|
+
changelog_uri: http://github.com/rleber/check_names/blob/master/CHANGELOG.md
|
39
|
+
rdoc_options:
|
40
|
+
- "--charset=UTF-8"
|
41
|
+
- "--main"
|
42
|
+
- README.md
|
43
|
+
- "--title"
|
44
|
+
- rleber check_names library
|
45
|
+
- "--line-numbers"
|
46
|
+
- "--inline-source"
|
47
|
+
require_paths:
|
48
|
+
- lib
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 3.1.0
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
requirements: []
|
60
|
+
rubygems_version: 3.6.9
|
61
|
+
specification_version: 4
|
62
|
+
summary: Check whether names are in use
|
63
|
+
test_files: []
|