tools 0.0.5 → 0.0.6
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/aux +3 -0
- data/aux2 +2 -0
- data/bin/tools +18 -0
- data/lib/lib/config.rb +3 -2
- data/lib/lib/files.rb +16 -1
- data/lib/lib/utils.rb +29 -2
- data/lib/tools/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c13d9941d230d3a94e25bb91f46b2d8aaf1a6434bef0946b975b1c1ca8b32caf
|
4
|
+
data.tar.gz: 53e6f648142c4ab31502df123f03b3ce10f350c76dab47dda028c030afc12466
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04c14f0d10dc087d0c0699c0dc27df65f48fbf6b5792aada784fa21981c1cce27063e0ad363b37780a1db48a4278c21d8906595ae570c690c64a94a84eb4baf1
|
7
|
+
data.tar.gz: 8ce27180551a0373665b251f52c85ed6d97a4d9c5a67b7f9a181b97308dc610b8818cfa21c474b2ab6d2e9725a16ec27d99f8040253491e357009f8ec4eb2640
|
data/aux
CHANGED
@@ -109,3 +109,6 @@ require 'tools'
|
|
109
109
|
|
110
110
|
# ToolsConfig.create_config_file 'glbapi', '/home/francisco/.glbapi/glbapi.config'
|
111
111
|
|
112
|
+
# k = 'teste_xxx'
|
113
|
+
# pattern = { "status": Integer}
|
114
|
+
# ToolsConfig.insert_in_config "/home/francisco/.newcmdapi/cmdapi.config", {'cmdapi' => {"#{k}" => pattern}}
|
data/bin/tools
CHANGED
@@ -51,6 +51,24 @@ class Tools_exec < Thor
|
|
51
51
|
|
52
52
|
def method_missing(method, *args, &block)
|
53
53
|
|
54
|
+
|
55
|
+
# ap method
|
56
|
+
# ap args.extract_option '-v', false #=> 8
|
57
|
+
# ap args.extract_option '-x' #=> true
|
58
|
+
# ap args.extract_option '-f' #=> false
|
59
|
+
# ap args.extract_symbol :json #=> true
|
60
|
+
# ap args.extract_symbol :yaml #=> false
|
61
|
+
# ap args.extract_color #=> :yellow
|
62
|
+
# ap args.extract_color #=> red
|
63
|
+
# ap args.extract_option_value '--class' #=> 'tools'
|
64
|
+
# ap args #=> [-c -vcv -v2 -s ]
|
65
|
+
|
66
|
+
|
67
|
+
ToolsDisplay.show "To export ldap variables use: ".fix(60,'.'), :cyan
|
68
|
+
ToolsDisplay.show "export ldap_user=<your_ldap_login> ".fix(65,'.'), :cyan
|
69
|
+
ToolsDisplay.show "export ldap_pass=<your_ldap_password>".fix(65,'.'), :cyan
|
70
|
+
|
71
|
+
|
54
72
|
exit()
|
55
73
|
end
|
56
74
|
|
data/lib/lib/config.rb
CHANGED
@@ -21,12 +21,13 @@ class ToolsConfig
|
|
21
21
|
# @param logname
|
22
22
|
# @param logfile
|
23
23
|
# @return
|
24
|
-
def self.create_config_file config_name, config_file, config_type = :json
|
24
|
+
def self.create_config_file config_name, config_file, config_type = :json, data = {}
|
25
25
|
unless File.exists? config_file
|
26
26
|
case config_type
|
27
27
|
when :json
|
28
28
|
config = File.open(config_file, 'w')
|
29
|
-
data = {}
|
29
|
+
#data = {}
|
30
|
+
ap data
|
30
31
|
config.write JSON.pretty_generate(data)
|
31
32
|
config.close
|
32
33
|
ToolsLog.tools_info "Json config file '#{config_file}' was created!'"
|
data/lib/lib/files.rb
CHANGED
@@ -45,7 +45,22 @@ class ToolsFiles
|
|
45
45
|
ToolsUtil.set_variable file_name_set, complete_file
|
46
46
|
end
|
47
47
|
|
48
|
-
|
48
|
+
# Load a file in work area
|
49
|
+
#
|
50
|
+
# Sample
|
51
|
+
#
|
52
|
+
# ToolsFiles.load_file xyko, file_to_load
|
53
|
+
# xyko = (ToolsUtil.get_variable 'xyko_file') => ~/2018/xykotools/tools/home/xyko_file.txt
|
54
|
+
#
|
55
|
+
# @param file_name
|
56
|
+
# @param file_name_path
|
57
|
+
# @return
|
58
|
+
def self.load_file file_key, file_to_load
|
59
|
+
if File.exists? file_to_load
|
60
|
+
file = File.open( complete_file , 'r')
|
61
|
+
return file
|
62
|
+
end
|
63
|
+
end
|
49
64
|
|
50
65
|
|
51
66
|
end
|
data/lib/lib/utils.rb
CHANGED
@@ -250,6 +250,20 @@ class Object
|
|
250
250
|
def boolean?
|
251
251
|
self.is_a?(TrueClass) || self.is_a?(FalseClass)
|
252
252
|
end
|
253
|
+
|
254
|
+
# Self test Trueclass.
|
255
|
+
#
|
256
|
+
# @return boolean
|
257
|
+
def true?
|
258
|
+
self.is_a?(TrueClass)
|
259
|
+
end
|
260
|
+
# Self test Falseclass.
|
261
|
+
#
|
262
|
+
# @return boolean
|
263
|
+
def false?
|
264
|
+
self.is_a?(FalseClass)
|
265
|
+
end
|
266
|
+
|
253
267
|
# Self test Symbol class.
|
254
268
|
#
|
255
269
|
# @return boolean
|
@@ -348,15 +362,28 @@ class Array
|
|
348
362
|
aux_string = argument.sub('-','')
|
349
363
|
count = argument.count(search_char)
|
350
364
|
if (count == aux_string.size)
|
351
|
-
result
|
352
|
-
self.delete(argument)
|
365
|
+
result = result + count
|
366
|
+
#self.delete(argument)
|
353
367
|
end
|
354
368
|
end
|
369
|
+
|
355
370
|
end
|
356
371
|
end
|
357
372
|
return result
|
358
373
|
end
|
359
374
|
|
375
|
+
def extract_option_value option
|
376
|
+
result = false
|
377
|
+
value = nil
|
378
|
+
if self.include? option
|
379
|
+
index = self.index(option)
|
380
|
+
self.delete_at(index)
|
381
|
+
result = true
|
382
|
+
value = self.at(index)
|
383
|
+
self.delete_at(index)
|
384
|
+
end
|
385
|
+
return [result, value]
|
386
|
+
end
|
360
387
|
|
361
388
|
|
362
389
|
|
data/lib/tools/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Xyko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -387,6 +387,7 @@ files:
|
|
387
387
|
- Rakefile
|
388
388
|
- TODO.txt
|
389
389
|
- aux
|
390
|
+
- aux2
|
390
391
|
- bin/tools
|
391
392
|
- lib/files/pt-BR.yml
|
392
393
|
- lib/files/requireds.rb
|