toolrack 0.9.2 → 0.12.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 +4 -4
- data/README.md +54 -4
- data/lib/toolrack/mixin_helper.rb +27 -0
- data/lib/toolrack/password_utils.rb +9 -9
- data/lib/toolrack/version.rb +1 -1
- data/lib/toolrack.rb +21 -2
- data/toolrack.gemspec +3 -2
- metadata +28 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6017a232adad200e31c0e260e6c6a02b0a28024bdb966d105d3f5102b2e458a
|
4
|
+
data.tar.gz: 9e5000fc3e174e3d25421e35c45ebff61b5c7c0c8439e6d1b800c2f220e69b2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: abd273b83b3d2b20f05875ac4e17c190fa19799d7fb0038974038eb00cc5dcae3aeae1bc91db2b0ee0950dbe523be44f77618113b2e0d79b3a630a39678fec6d
|
7
|
+
data.tar.gz: 8e867b4b64cbc256bd6af290b1b987d1dbfd7ae92772665f6fbdb3ac58f96adeec9a0bdc756010ffe03a117ddda68d91224091ae03a8877c39f9c28926840fae
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Toolrack
|
2
2
|
|
3
|
-
Toolrack just the collection of utilities that helps in my code clarity
|
3
|
+
Toolrack just the collection of utilities that helps in my code clarity and assistance since those utils too small to be a gem on its own.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -40,10 +40,21 @@ class EditController
|
|
40
40
|
# enable instance method to access those uitilities
|
41
41
|
include ToolRack::ConditionUtils
|
42
42
|
include ToolRack::ExceptionUtils
|
43
|
+
include ToolRack::PasswordUtils
|
44
|
+
include ToolRack::RuntimeUtils
|
45
|
+
include ToolRack::DataConversionUtils
|
46
|
+
|
47
|
+
# there is also shortcut since I write it so often
|
48
|
+
include TR::CondUtils
|
49
|
+
include TR::ExpUtils
|
50
|
+
include TR::PassUtils
|
51
|
+
include TR::RTUtils
|
52
|
+
include TR::DataConvUtils
|
43
53
|
end
|
44
54
|
```
|
45
55
|
|
46
|
-
Currently it has
|
56
|
+
Currently it has 5 modules:
|
57
|
+
|
47
58
|
* Condition Utilities
|
48
59
|
* is\_empty?(obj) - I found that I've type the condition if not (x.nil? and x.empty?) too frequent that I think this is very best to turn this into a function. The empty test shall take the following test in sequence:
|
49
60
|
* First test is x.nil?. If it is return true
|
@@ -77,6 +88,45 @@ Currently it has 3 modules:
|
|
77
88
|
* raise\_if\_false(obj, message, error) - As the name implied
|
78
89
|
* raise\_if\_true(obj, message, error) - As the name implied
|
79
90
|
|
80
|
-
|
81
|
-
|
91
|
+
* Runtime utils - Tired rewriting this in other project. Detect if the running system is on which operating system / runtime. The function is pretty self descriptive
|
92
|
+
* RuntimeUtils.on\_windows?
|
93
|
+
* RuntimeUtils.on\_mac?
|
94
|
+
* RuntimeUtils.on\_linux?
|
95
|
+
* RuntimeUtils.on\_ruby?
|
96
|
+
* RuntimeUtils.on\_jruby?
|
97
|
+
|
98
|
+
* Password utils - Generate random password with designated complexity
|
99
|
+
* generate\_random\_password(length, options = { complexity: \<value\>, enforce\_quality: \<true/false\> })
|
100
|
+
* length - length of the required generated password
|
101
|
+
* options[:complexity]:
|
102
|
+
* 1 - lowercase alphabet
|
103
|
+
* 2 - lower + upper case alphabet [alpha]
|
104
|
+
* 3 - lower + upper + number [alpha numeric]
|
105
|
+
* 4 - lower + upper + number + symbol
|
106
|
+
* options[:enforce\_quality]
|
107
|
+
* true - generated password is guaranteed to contain the required complexity. E.g. if complexity 4 is required, the password MUST contain lower, upper, number and symbol as its output or a new password that comply to the complexity shall be regenerated. This process is repeated until the required complexity is achieved
|
108
|
+
* false - The rules of the complexity is relexed. E.g. if complexity 4 is requested, the output might not have symbol in it.
|
109
|
+
* gen\_rand\_pass(length, options = { }) & gen\_pass(length, options = { })
|
110
|
+
* Alias for method generate\_random\_password
|
111
|
+
|
112
|
+
* all\_lowercase\_alpha?(str)
|
113
|
+
* all\_uppercase\_alpha?(str)
|
114
|
+
* all\_alpha?(str)
|
115
|
+
* all\_number?(str)
|
116
|
+
* all\_symbol?(str)
|
117
|
+
* all\_alpha\_numeric?(str)
|
118
|
+
* all\_alpha\_numeric\_and\_symbol?(str)
|
119
|
+
* All methods above starts with all_\* is to check for strict compliance to the required output. E.g. if all\_alpha?(str) is used, the input str MUST be all alpha to get a true status
|
120
|
+
|
121
|
+
* has\_lowercase\_alpha?(str)
|
122
|
+
* has\_uppercase\_alpha?(str)
|
123
|
+
* has\_alpha?(str)
|
124
|
+
* has\_number?(str)
|
125
|
+
* has\_symbol?(str)
|
126
|
+
* has\_alpha\_numeric?(str)
|
127
|
+
* has\_alpha\_numeric\_or\_symbol?(str)
|
128
|
+
* All methods above start with has_\* is just to check if the given str contains the required specification. E.g string 'abcdE' will still get true status if pass to has\_lowercase\_alpha?(str). But value 1234 or '1234' or '$%^&' pass to has\_lowercase\_alpha?(str) shall return false.
|
129
|
+
|
130
|
+
|
131
|
+
Check out the rspec folder for usage
|
82
132
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module Antrapol
|
4
|
+
module ToolRack
|
5
|
+
module MixinHelper
|
6
|
+
|
7
|
+
module ClassMethods
|
8
|
+
def mixin(cls)
|
9
|
+
self.class_eval "include #{cls}"
|
10
|
+
end
|
11
|
+
|
12
|
+
def class_method(&block)
|
13
|
+
class_eval <<-END
|
14
|
+
module ClassMethods
|
15
|
+
end
|
16
|
+
END
|
17
|
+
ClassMethods.class_eval(&block)
|
18
|
+
end
|
19
|
+
end # module ClassMethods
|
20
|
+
|
21
|
+
def self.included(klass)
|
22
|
+
klass.extend(ClassMethods)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -116,7 +116,7 @@ module Antrapol
|
|
116
116
|
s = str.split("")
|
117
117
|
lalpha = ('a'..'z').to_a
|
118
118
|
|
119
|
-
(s
|
119
|
+
(s-lalpha).length == 0
|
120
120
|
end
|
121
121
|
|
122
122
|
def has_lowercase_alpha?(str)
|
@@ -134,7 +134,7 @@ module Antrapol
|
|
134
134
|
s = str.split("")
|
135
135
|
ualpha = ('A'..'Z').to_a
|
136
136
|
|
137
|
-
s
|
137
|
+
(s-ualpha).length == 0
|
138
138
|
end
|
139
139
|
|
140
140
|
def has_uppercase_alpha?(str)
|
@@ -157,8 +157,8 @@ module Antrapol
|
|
157
157
|
|
158
158
|
alpha = [lalpha, ualpha].flatten
|
159
159
|
|
160
|
-
t1 = (alpha
|
161
|
-
t2 = (alpha
|
160
|
+
t1 = (alpha-s).length == 0
|
161
|
+
t2 = (alpha-s).length == 0
|
162
162
|
|
163
163
|
t3 = (s & num).length > 0
|
164
164
|
t4 = (s & sym).length > 0
|
@@ -197,7 +197,7 @@ module Antrapol
|
|
197
197
|
s = str.split("")
|
198
198
|
num = ('0'..'9').to_a
|
199
199
|
|
200
|
-
!(s
|
200
|
+
!((s-num).length > 0)
|
201
201
|
|
202
202
|
end
|
203
203
|
|
@@ -206,7 +206,7 @@ module Antrapol
|
|
206
206
|
|
207
207
|
s = str.split("")
|
208
208
|
sym = ('!'..'?').to_a
|
209
|
-
!(s
|
209
|
+
!((s-sym).length > 0)
|
210
210
|
|
211
211
|
end
|
212
212
|
|
@@ -229,7 +229,7 @@ module Antrapol
|
|
229
229
|
ualpha = ('A'..'Z').to_a
|
230
230
|
num = ('0'..'9').to_a
|
231
231
|
sym = ('!'..'?').to_a
|
232
|
-
sym = sym
|
232
|
+
sym = sym-num
|
233
233
|
|
234
234
|
t1 = ((s & lalpha).length > 0)
|
235
235
|
t2 = ((s & ualpha).length > 0)
|
@@ -261,7 +261,7 @@ module Antrapol
|
|
261
261
|
ualpha = ('A'..'Z').to_a
|
262
262
|
num = ('0'..'9').to_a
|
263
263
|
sym = ('!'..'?').to_a
|
264
|
-
sym = sym
|
264
|
+
sym = sym-num
|
265
265
|
|
266
266
|
t1 = ((s & lalpha).length > 0)
|
267
267
|
t2 = ((s & ualpha).length > 0)
|
@@ -279,7 +279,7 @@ module Antrapol
|
|
279
279
|
ualpha = ('A'..'Z').to_a
|
280
280
|
num = ('0'..'9').to_a
|
281
281
|
sym = ('!'..'?').to_a
|
282
|
-
sym = sym
|
282
|
+
sym = sym-num
|
283
283
|
|
284
284
|
t1 = ((s & lalpha).length > 0)
|
285
285
|
t2 = ((s & ualpha).length > 0)
|
data/lib/toolrack/version.rb
CHANGED
data/lib/toolrack.rb
CHANGED
@@ -12,18 +12,37 @@ require_relative 'toolrack/process_utils'
|
|
12
12
|
require_relative 'toolrack/runtime_utils'
|
13
13
|
require_relative 'toolrack/data_conversion_utils'
|
14
14
|
require_relative 'toolrack/password_utils'
|
15
|
+
require_relative 'toolrack/mixin_helper'
|
15
16
|
|
16
17
|
module Antrapol
|
17
18
|
module ToolRack
|
18
19
|
class Error < StandardError; end
|
19
20
|
# Your code goes here...
|
20
|
-
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
+
# try to get rid of constant redefined warning
|
25
|
+
module TR
|
26
|
+
Antrapol::ToolRack
|
27
|
+
end
|
28
|
+
|
24
29
|
ToolRack = Antrapol::ToolRack
|
25
|
-
|
30
|
+
#TR = ToolRack
|
31
|
+
|
32
|
+
ToolRack::DataConvUtils = Antrapol::ToolRack::DataConversionUtils
|
33
|
+
TR::DataConvUtils = ToolRack::DataConvUtils
|
34
|
+
|
26
35
|
ToolRack::CondUtils = ToolRack::ConditionUtils
|
36
|
+
TR::CondUtils = ToolRack::ConditionUtils
|
37
|
+
|
27
38
|
ToolRack::PassUtils = ToolRack::PasswordUtils
|
39
|
+
TR::PassUtils = ToolRack::PasswordUtils
|
40
|
+
|
41
|
+
ToolRack::ExpUtils = ToolRack::ExceptionUtils
|
42
|
+
TR::ExpUtils = ToolRack::ExpUtils
|
43
|
+
|
44
|
+
ToolRack::RTUtils = ToolRack::RuntimeUtils
|
45
|
+
TR::RTUtils = ToolRack::RTUtils
|
28
46
|
|
47
|
+
TR::MixinHelper = ToolRack::MixinHelper
|
29
48
|
|
data/toolrack.gemspec
CHANGED
@@ -26,8 +26,9 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
27
|
spec.require_paths = ["lib"]
|
28
28
|
|
29
|
-
spec.add_dependency "tlogger"
|
29
|
+
spec.add_dependency "tlogger" #, "~> 0.21"
|
30
30
|
spec.add_dependency "base58"
|
31
31
|
|
32
|
-
spec.add_development_dependency "devops_helper"
|
32
|
+
spec.add_development_dependency "devops_helper" #, "~> 0.1.0"
|
33
|
+
spec.add_development_dependency "rspec"
|
33
34
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: toolrack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-09-
|
11
|
+
date: 2021-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tlogger
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0
|
19
|
+
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: base58
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -42,16 +42,30 @@ dependencies:
|
|
42
42
|
name: devops_helper
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0
|
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'
|
55
69
|
description: Just collections of utilities
|
56
70
|
email:
|
57
71
|
- chrisliaw@antrapol.com
|
@@ -73,6 +87,7 @@ files:
|
|
73
87
|
- lib/toolrack/data_conversion_utils.rb
|
74
88
|
- lib/toolrack/exception_utils.rb
|
75
89
|
- lib/toolrack/global.rb
|
90
|
+
- lib/toolrack/mixin_helper.rb
|
76
91
|
- lib/toolrack/password_utils.rb
|
77
92
|
- lib/toolrack/process_utils.rb
|
78
93
|
- lib/toolrack/runtime_utils.rb
|
@@ -88,7 +103,7 @@ licenses: []
|
|
88
103
|
metadata:
|
89
104
|
homepage_uri: https://github.com/chrisliaw/toolrack
|
90
105
|
source_code_uri: https://github.com/chrisliaw/toolrack
|
91
|
-
post_install_message:
|
106
|
+
post_install_message:
|
92
107
|
rdoc_options: []
|
93
108
|
require_paths:
|
94
109
|
- lib
|
@@ -104,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
119
|
version: '0'
|
105
120
|
requirements: []
|
106
121
|
rubygems_version: 3.2.22
|
107
|
-
signing_key:
|
122
|
+
signing_key:
|
108
123
|
specification_version: 4
|
109
124
|
summary: Collection of simple utilities but I find it increase clarity
|
110
125
|
test_files: []
|