password_util 0.0.4 → 0.0.5
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 +4 -4
- data/bin/password_util +17 -0
- data/lib/password_util.rb +12 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4af24e1ec068268a89fcafaf6a05f968ac9f1128bbb8cbf805c13c76344bdd4a
|
4
|
+
data.tar.gz: 8f8056f8479dde813d25628a799400c6a0b1cbc17ac436529b176159c6f7675b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 895f0bdd59d36c6b4b7aabc5790bda344bde777074ca12eeea46cf4e4d14ddb5c43ef4226b1e9c01047283dbd19a46fe420560cd017f777e056bfdd7d4210710
|
7
|
+
data.tar.gz: 2af852bfde063c96556a7f818500b5ee6ca01ed972d91dfdcf8eed4b033dae5fb07b348d0138d58e133063d28d02d852ff7eadff170afcd80ccde41cb0b6fc7a
|
data/bin/password_util
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'password_util'
|
4
|
+
|
5
|
+
password_length = ENV['LENGTH']
|
6
|
+
has_upper_letters = ENV['UPPER_LETTERS']
|
7
|
+
has_lower_letters = ENV['LOWER_LETTERS']
|
8
|
+
has_numbers = ENV['NUMBERS']
|
9
|
+
has_symbols = ENV['SYMBOLS']
|
10
|
+
|
11
|
+
PasswordUtil.password_length = password_length.to_i if password_length.to_s =~ /\A\d+\z/
|
12
|
+
PasswordUtil.has_upper_letters = has_upper_letters == 1 if has_upper_letters.to_s =~ /\A(?:0|1)\z/
|
13
|
+
PasswordUtil.has_lower_letters = has_lower_letters == 1 if has_lower_letters.to_s =~ /\A(?:0|1)\z/
|
14
|
+
PasswordUtil.has_numbers = has_numbers == 1 if has_numbers.to_s =~ /\A(?:0|1)\z/
|
15
|
+
PasswordUtil.has_symbols = has_symbols == 1 if has_symbols.to_s =~ /\A(?:0|1)\z/
|
16
|
+
|
17
|
+
puts PasswordUtil.generate
|
data/lib/password_util.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
module PasswordUtil
|
2
|
+
##
|
3
|
+
# Configuration exception.
|
2
4
|
class ConfigurationError < StandardError; end
|
3
5
|
|
4
6
|
UPPER_LETTERS = ('A'..'Z').to_a.freeze
|
@@ -6,6 +8,10 @@ module PasswordUtil
|
|
6
8
|
NUMBERS = ('0'..'9').to_a.freeze
|
7
9
|
SYMBOLS = %w[~ ` ! @ # $ % ^ & * ( ) _ - + = { \[ } \] | \\ : ; " ' < , > . ? /].freeze
|
8
10
|
|
11
|
+
##
|
12
|
+
# Validates configuration.
|
13
|
+
#
|
14
|
+
# @return [String] the generated password
|
9
15
|
def self.validate_config!
|
10
16
|
boolean_classes = [TrueClass, FalseClass]
|
11
17
|
|
@@ -22,6 +28,8 @@ module PasswordUtil
|
|
22
28
|
raise ConfigurationError, 'No usable character set.' unless has_lower_letters || has_upper_letters || has_numbers || has_symbols
|
23
29
|
end
|
24
30
|
|
31
|
+
##
|
32
|
+
# Resets configuration to default.
|
25
33
|
def self.reset_config
|
26
34
|
self.password_length = 8
|
27
35
|
self.has_lower_letters = true
|
@@ -34,6 +42,10 @@ module PasswordUtil
|
|
34
42
|
self.min_symbols = 1
|
35
43
|
end
|
36
44
|
|
45
|
+
##
|
46
|
+
# Generates password.
|
47
|
+
#
|
48
|
+
# @return [String] the generated password
|
37
49
|
def self.generate
|
38
50
|
validate_config!
|
39
51
|
charset = []
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: password_util
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Reinier John Avila
|
@@ -10,12 +10,14 @@ bindir: bin
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2022-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
13
|
+
description: Utility tool to generate password.
|
14
14
|
email: reinieravila@gmail.com
|
15
|
-
executables:
|
15
|
+
executables:
|
16
|
+
- password_util
|
16
17
|
extensions: []
|
17
18
|
extra_rdoc_files: []
|
18
19
|
files:
|
20
|
+
- bin/password_util
|
19
21
|
- lib/password_util.rb
|
20
22
|
homepage: https://github.com/reinieravila/password_util.git
|
21
23
|
licenses:
|
@@ -39,5 +41,5 @@ requirements: []
|
|
39
41
|
rubygems_version: 3.3.7
|
40
42
|
signing_key:
|
41
43
|
specification_version: 4
|
42
|
-
summary: Password Utility Tool
|
44
|
+
summary: Password Generation Utility Tool
|
43
45
|
test_files: []
|