check_names 0.1.3 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b0874e995854cc533fb38818a5b9f089e6a4e0d7332d0c17fccc938c53cf0b3
4
- data.tar.gz: 6f5e08486246c0e0eb450aa5a96e471bfe6a70a3d8f5019cb51d53b5dff2b890
3
+ metadata.gz: 1d0cf11e9076de1fa47bd7958d036569900222f8ffbe9aefd86e4cee94fdaa2c
4
+ data.tar.gz: 0d3450cd0d9825a3d99d7169df84a321203ed85a516587ac974b7bc361d59fa2
5
5
  SHA512:
6
- metadata.gz: d5b237cc2c4de5f6e8c300a1fbfd63d6bcd3a0f7104710b3f6d586fb29b564b62c64fb5a20a840a3beb6b431b27487700efefa76c1fc291336953886dc29cbe9
7
- data.tar.gz: fb1ecdc704ecbeb204394e4f54aed1896d3879b6884e8cc5c3966bcae1a5df64d3a674a1623c16c77bcd579f717693a57a56edc67b21f3cf665793fa2e978c29
6
+ metadata.gz: a57acda4efb147a008062b2660ff1473ae93b7a499d6cc425c386c9eae69177692193a52c3fa576ecb4d82c857c71b450436a7965debc3d30e5cc3398494b8a8
7
+ data.tar.gz: 830e2e02569026fd527180a71f786d975d9ca7c258655955f59cc74f513a4e50a153a0523a92d83a444197f1771186488f9896e5325faa567ae1eab7a40f7e96
data/exe/check_names CHANGED
@@ -31,31 +31,30 @@ of the following meanings:
31
31
  3 You have an executable (reachable via \$PATH) with this name
32
32
  4 You have a shell function with this name
33
33
  5 You have an alias with this name
34
+ 6 This name is used by a Ruby standard class
34
35
 
35
36
  If more than one name was given, the return code is the maximum return code
36
37
  received for any name.
37
38
 
38
39
  The following options are available:
39
40
 
40
- --help -h Print this help information
41
- --verbose -v Print messages about the status of the name check
42
- --verbose is the default if more than one name is given
41
+ --help -h Print this help information
42
+ --quiet -q Suppress messages about the status of the name check
43
43
  HELP
44
44
  end
45
45
 
46
46
  def main(args)
47
47
  args = args.map { |arg| arg.downcase }
48
- verbose = args.index { |arg| %w{-v --verbose}.include?(arg) }
49
- args.delete_at(verbose) if verbose
48
+ quiet = args.index { |arg| %w{-q --quiet}.include?(arg) }
49
+ args.delete_at(quiet) if quiet
50
50
  if args.size == 0 || %w{-h --help help}.include?(args.first)
51
51
  show_help
52
52
  exit
53
53
  end
54
- verbose ||= args.size > 1
55
54
  rc = 0
56
55
  args.each do |arg|
57
56
  status = GemName.check(arg)
58
- puts "#{arg}: #{status[:message]}." if verbose
57
+ puts "#{arg}: #{status[:message]}." unless quiet
59
58
  rc = status[:rc] if status[:rc] > rc
60
59
  end
61
60
  exit(rc)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CheckNames
4
- VERSION = "0.1.3"
4
+ VERSION = "0.2.0"
5
5
 
6
6
  def self.version
7
7
  VERSION
data/lib/check_names.rb CHANGED
@@ -46,7 +46,13 @@ module GemName
46
46
  system("zsh -lic 'alias #{Shellwords.escape(name)}' >/dev/null")
47
47
  end
48
48
 
49
+ def self.standard_class_exists?(name)
50
+ class_name = name.split('_').map(&:capitalize).join
51
+ Module.const_defined?(class_name)
52
+ end
53
+
49
54
  def self.check(name)
55
+ name = name.downcase
50
56
  if ruby_gem_exists?(name)
51
57
  return {rc: 1, message: "A Gem on RubyGems"}
52
58
  end
@@ -62,6 +68,9 @@ module GemName
62
68
  if alias_exists?(name)
63
69
  return {rc: 5, message: "An alias"}
64
70
  end
71
+ if standard_class_exists?(name)
72
+ return {rc: 6, message: "A Ruby class"}
73
+ end
65
74
  {rc: 0, message: "Available"}
66
75
  end
67
76
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: check_names
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard LeBer