elib_mgmt-cli 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +77 -0
- data/README.md +31 -0
- data/Rakefile +10 -0
- data/elib_mgmt-cli.gemspec +49 -0
- data/exe/elm_auto_sort +50 -0
- data/exe/elm_config_auto_sort +113 -0
- data/exe/elm_find_duplicated +77 -0
- data/exe/elm_search +71 -0
- data/lib/elib_mgmt/cli/config.rb +29 -0
- data/lib/elib_mgmt/cli/file_filter.rb +140 -0
- data/lib/elib_mgmt/cli/version.rb +7 -0
- data/lib/elib_mgmt/cli.rb +41 -0
- data/mapping.yml +357 -0
- data/regex_live_text.rb +32 -0
- data/regex_test.rb +37 -0
- data/sig/elib_mgmt/cli.rbs +6 -0
- metadata +148 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: cc02917ef49a75758f8b4cfb956a7918c9a822ada8257af08eedbc2a61fbe1e1
|
4
|
+
data.tar.gz: 28d3da7a1f2dc1a02bf61376bd35a261410bb0ae9df3e335da7d8a1891f92eda
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ff64fb9f1ef00a672a2083511ed714b3ac6da6412b8e5511b34ca5b9d410cbfe7b22c70390465825677a5204ec9e7f905cb6338ba2f37006562781b989395afb
|
7
|
+
data.tar.gz: ac2e3c905d3842c60f5c4edf447df99a9cb8eedde2a4f7612ea76fa7e487a788375609351da2d0b920d0671cf4a95a3ae1585a9f6b6b2e278ce572b244d45523
|
data/.rspec
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
elib_mgmt-cli (0.1.0)
|
5
|
+
colorize
|
6
|
+
string-similarity
|
7
|
+
teLogger
|
8
|
+
toolrack
|
9
|
+
tty-prompt
|
10
|
+
|
11
|
+
GEM
|
12
|
+
remote: https://rubygems.org/
|
13
|
+
specs:
|
14
|
+
base58 (0.2.3)
|
15
|
+
colorize (0.8.1)
|
16
|
+
devops_assist (0.3.3)
|
17
|
+
git_cli
|
18
|
+
git_cli_prompt
|
19
|
+
gvcs
|
20
|
+
teLogger
|
21
|
+
toolrack
|
22
|
+
tty-prompt
|
23
|
+
diff-lcs (1.5.0)
|
24
|
+
git_cli (0.11.2)
|
25
|
+
gvcs
|
26
|
+
ptools (~> 1.4.0)
|
27
|
+
teLogger
|
28
|
+
toolrack
|
29
|
+
git_cli_prompt (0.3.1)
|
30
|
+
teLogger
|
31
|
+
toolrack
|
32
|
+
tty-prompt
|
33
|
+
gvcs (0.1.1)
|
34
|
+
pastel (0.8.0)
|
35
|
+
tty-color (~> 0.5)
|
36
|
+
ptools (1.4.3)
|
37
|
+
rake (13.0.6)
|
38
|
+
rspec (3.12.0)
|
39
|
+
rspec-core (~> 3.12.0)
|
40
|
+
rspec-expectations (~> 3.12.0)
|
41
|
+
rspec-mocks (~> 3.12.0)
|
42
|
+
rspec-core (3.12.1)
|
43
|
+
rspec-support (~> 3.12.0)
|
44
|
+
rspec-expectations (3.12.2)
|
45
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
46
|
+
rspec-support (~> 3.12.0)
|
47
|
+
rspec-mocks (3.12.4)
|
48
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
49
|
+
rspec-support (~> 3.12.0)
|
50
|
+
rspec-support (3.12.0)
|
51
|
+
string-similarity (2.1.0)
|
52
|
+
teLogger (0.2.2)
|
53
|
+
toolrack (0.20.1)
|
54
|
+
base58
|
55
|
+
tty-color (0.6.0)
|
56
|
+
tty-cursor (0.7.1)
|
57
|
+
tty-prompt (0.23.1)
|
58
|
+
pastel (~> 0.8)
|
59
|
+
tty-reader (~> 0.8)
|
60
|
+
tty-reader (0.9.0)
|
61
|
+
tty-cursor (~> 0.7)
|
62
|
+
tty-screen (~> 0.8)
|
63
|
+
wisper (~> 2.0)
|
64
|
+
tty-screen (0.8.1)
|
65
|
+
wisper (2.0.1)
|
66
|
+
|
67
|
+
PLATFORMS
|
68
|
+
x86_64-linux
|
69
|
+
|
70
|
+
DEPENDENCIES
|
71
|
+
devops_assist
|
72
|
+
elib_mgmt-cli!
|
73
|
+
rake (~> 13.0)
|
74
|
+
rspec (~> 3.0)
|
75
|
+
|
76
|
+
BUNDLED WITH
|
77
|
+
2.4.6
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# ElibMgmt::Cli
|
2
|
+
|
3
|
+
TODO: Delete this and the text below, and describe your gem
|
4
|
+
|
5
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/elib_mgmt/cli`. To experiment with that code, run `bin/console` for an interactive prompt.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
|
10
|
+
|
11
|
+
Install the gem and add to the application's Gemfile by executing:
|
12
|
+
|
13
|
+
$ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
|
14
|
+
|
15
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
16
|
+
|
17
|
+
$ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Development
|
24
|
+
|
25
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
26
|
+
|
27
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/elib_mgmt-cli.
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/elib_mgmt/cli/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "elib_mgmt-cli"
|
7
|
+
spec.version = ElibMgmt::Cli::VERSION
|
8
|
+
spec.authors = ["Chris"]
|
9
|
+
spec.email = ["chris@antrapol.com"]
|
10
|
+
|
11
|
+
spec.summary = ""
|
12
|
+
spec.description = ""
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.required_ruby_version = ">= 2.6.0"
|
15
|
+
|
16
|
+
#spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
|
17
|
+
|
18
|
+
#spec.metadata["homepage_uri"] = spec.homepage
|
19
|
+
#spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
|
20
|
+
#spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
21
|
+
|
22
|
+
# Specify which files should be added to the gem when it is released.
|
23
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
24
|
+
spec.files = Dir.chdir(__dir__) do
|
25
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
26
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|circleci)|appveyor)})
|
27
|
+
end
|
28
|
+
end
|
29
|
+
spec.bindir = "exe"
|
30
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ["lib"]
|
32
|
+
|
33
|
+
spec.add_dependency "string-similarity"
|
34
|
+
#spec.add_dependency "diff-lcs"
|
35
|
+
#spec.add_dependency "damerau-levenshtein"
|
36
|
+
|
37
|
+
spec.add_dependency "toolrack"
|
38
|
+
spec.add_dependency "teLogger"
|
39
|
+
|
40
|
+
spec.add_dependency "tty-prompt"
|
41
|
+
spec.add_dependency "colorize"
|
42
|
+
|
43
|
+
spec.add_development_dependency 'devops_assist'
|
44
|
+
# Uncomment to register a new dependency of your gem
|
45
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
46
|
+
|
47
|
+
# For more information and examples about making a new gem, check out our
|
48
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
49
|
+
end
|
data/exe/elm_auto_sort
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'elib_mgmt/cli'
|
4
|
+
require 'tty/prompt'
|
5
|
+
require 'colorize'
|
6
|
+
|
7
|
+
require 'string/similarity'
|
8
|
+
require 'openssl'
|
9
|
+
|
10
|
+
if ARGV.length < 3
|
11
|
+
STDERR.puts " <root> <dir name> <keyword, split by ','>".red
|
12
|
+
exit(0)
|
13
|
+
|
14
|
+
else
|
15
|
+
pmt = TTY::Prompt.new
|
16
|
+
|
17
|
+
pmt.puts "\n eLib Management Utilities version #{ElibMgmt::Cli::VERSION}\n\n"
|
18
|
+
pmt.puts " Auto sort files into specific directory\n\n"
|
19
|
+
|
20
|
+
root = ARGV.first
|
21
|
+
root = File.expand_path(root)
|
22
|
+
|
23
|
+
outDir = ARGV[1]
|
24
|
+
|
25
|
+
kw = ARGV[2]
|
26
|
+
kw = kw.split(",").map { |v| v.strip }.reject { |v| v.empty? }
|
27
|
+
|
28
|
+
pmt.puts " Root to search : #{root}\n\n"
|
29
|
+
pmt.puts " Keyword to search : #{kw.join(", ")}\n\n"
|
30
|
+
|
31
|
+
output = File.join(root,"AS_#{outDir.gsub(" ","-")}")
|
32
|
+
FileUtils.mkdir_p(output) if not File.exist?(output)
|
33
|
+
|
34
|
+
filter = ElibMgmt::Cli::FileFilter.new(root)
|
35
|
+
ttl = 0
|
36
|
+
kw.each do |k|
|
37
|
+
res = filter.filter(k,"**/**")
|
38
|
+
|
39
|
+
ttl += res.length
|
40
|
+
pmt.puts " Moving #{res.length} file(s)".light_blue
|
41
|
+
res.each do |f|
|
42
|
+
dest = File.join(output, File.basename(f))
|
43
|
+
FileUtils.mv(f, dest) if f != dest
|
44
|
+
end
|
45
|
+
pmt.puts " #{res.length} file(s) moved".light_blue
|
46
|
+
end
|
47
|
+
|
48
|
+
pmt.puts "\n\n Total #{ttl} file(s) moved\n\n".green
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'elib_mgmt/cli'
|
4
|
+
require 'tty/prompt'
|
5
|
+
require 'colorize'
|
6
|
+
require 'yaml'
|
7
|
+
require 'toolrack'
|
8
|
+
include TR::CondUtils
|
9
|
+
|
10
|
+
require 'string/similarity'
|
11
|
+
require 'openssl'
|
12
|
+
|
13
|
+
if ARGV.length < 1
|
14
|
+
STDERR.puts " <root> <config file>".red
|
15
|
+
exit(0)
|
16
|
+
|
17
|
+
else
|
18
|
+
pmt = TTY::Prompt.new
|
19
|
+
|
20
|
+
pmt.puts "\n eLib Management Utilities version #{ElibMgmt::Cli::VERSION}\n\n"
|
21
|
+
pmt.puts " Auto sort files into specific directory\n\n"
|
22
|
+
|
23
|
+
root = ARGV.first
|
24
|
+
root = File.expand_path(root)
|
25
|
+
|
26
|
+
pmt.puts " Root to search : #{root}\n\n"
|
27
|
+
|
28
|
+
conf = ARGV[1]
|
29
|
+
if is_empty?(conf)
|
30
|
+
raise RuntimeError, "Config file is empty"
|
31
|
+
else
|
32
|
+
conf = File.expand_path(conf)
|
33
|
+
raise RuntimeError, "Given config file '#{conf}' is not available" if not File.exist?(conf)
|
34
|
+
end
|
35
|
+
|
36
|
+
moveConf = YAML.load(File.open(conf))
|
37
|
+
|
38
|
+
if moveConf["config"]["reset_before_sort"]
|
39
|
+
pmt.puts "Reset all files before sorting start"
|
40
|
+
res = Dir.glob(File.join(root,"**/**")).reject { |f| File.directory?(f) }
|
41
|
+
res.each do |f|
|
42
|
+
dest = File.join(root, File.basename(f))
|
43
|
+
FileUtils.mv(f, dest) if dest != f
|
44
|
+
end
|
45
|
+
pmt.puts " #{res.length} files moved to root for sorting process"
|
46
|
+
end
|
47
|
+
|
48
|
+
ttl = 0
|
49
|
+
moveConf[:sort_spec].each do |c|
|
50
|
+
|
51
|
+
outDir = c[:outdir]
|
52
|
+
|
53
|
+
kw = c[:matcher]
|
54
|
+
pmt.puts " Keyword to search : #{kw.join(", ")}\n\n"
|
55
|
+
|
56
|
+
output = File.join(root,"AS_#{outDir.gsub(" ","-")}")
|
57
|
+
FileUtils.mkdir_p(output) if not File.exist?(output)
|
58
|
+
|
59
|
+
filter = ElibMgmt::Cli::FileFilter.new(root)
|
60
|
+
|
61
|
+
kw.each do |k|
|
62
|
+
|
63
|
+
case k
|
64
|
+
when Hash
|
65
|
+
found = filter.filter(k.keys.first, "**/**", k.values.first)
|
66
|
+
else
|
67
|
+
found = filter.filter(k, "**/**")
|
68
|
+
end
|
69
|
+
|
70
|
+
ttl += found.length
|
71
|
+
pmt.puts " Moving #{found.length} file(s)".light_blue
|
72
|
+
found.uniq.each do |f|
|
73
|
+
dest = File.join(output, File.basename(f))
|
74
|
+
FileUtils.mv(f, dest) if f != dest
|
75
|
+
end
|
76
|
+
pmt.puts " #{found.length} file(s) moved".light_blue
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
# sub directory
|
81
|
+
if not_empty?(c[:sub_dir_spec])
|
82
|
+
|
83
|
+
subFilter = ElibMgmt::Cli::FileFilter.new(output)
|
84
|
+
c[:sub_dir_spec].each do |sf|
|
85
|
+
sfOut = File.join(output, sf[:outdir])
|
86
|
+
FileUtils.mkdir_p(sfOut) if not File.exist?(sfOut)
|
87
|
+
|
88
|
+
kw = sf[:matcher]
|
89
|
+
pmt.puts " Keyword to search for sub : #{kw.join(", ")}\n\n"
|
90
|
+
|
91
|
+
kw.each do |k|
|
92
|
+
found = subFilter.filter(k, "**")
|
93
|
+
|
94
|
+
uf = found.uniq
|
95
|
+
ttl += uf.length
|
96
|
+
if not uf.empty?
|
97
|
+
pmt.puts " Moving #{uf.length} sub directory file(s)".light_blue
|
98
|
+
uf.each do |ff|
|
99
|
+
dest = File.join(sfOut, File.basename(ff))
|
100
|
+
FileUtils.mv(ff, dest) if ff != dest
|
101
|
+
end
|
102
|
+
pmt.puts " #{uf.length} sub directory file(s) moved".light_blue
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
end # sub dir
|
108
|
+
|
109
|
+
end
|
110
|
+
|
111
|
+
pmt.puts "\n\n Total #{ttl} file(s) moved\n\n".green
|
112
|
+
|
113
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'elib_mgmt/cli'
|
4
|
+
require 'tty/prompt'
|
5
|
+
require 'colorize'
|
6
|
+
|
7
|
+
require 'string/similarity'
|
8
|
+
require 'openssl'
|
9
|
+
|
10
|
+
if ARGV.length == 0
|
11
|
+
STDERR.puts " Root to find the files is required.".red
|
12
|
+
exit(0)
|
13
|
+
|
14
|
+
else
|
15
|
+
pmt = TTY::Prompt.new
|
16
|
+
|
17
|
+
pmt.puts "\n eLib Management Utilities version #{ElibMgmt::Cli::VERSION}\n\n"
|
18
|
+
pmt.puts " File duplicated files from the given path\n\n"
|
19
|
+
|
20
|
+
root = ARGV.first
|
21
|
+
root = File.expand_path(root)
|
22
|
+
|
23
|
+
pmt.puts " Root to search : #{root}\n\n"
|
24
|
+
|
25
|
+
path = File.join(root,"**/**")
|
26
|
+
|
27
|
+
res = Dir.glob(path).reject { |f| File.directory?(f) }
|
28
|
+
pmt.puts " Total #{res.length} file(s) found\n\n".yellow
|
29
|
+
|
30
|
+
db = { }
|
31
|
+
seen = []
|
32
|
+
found = []
|
33
|
+
res.each do |f|
|
34
|
+
|
35
|
+
d = Digest::SHA1.digest(File.read(f))
|
36
|
+
if seen.include?(d)
|
37
|
+
puts "#{f} : #{db[d]}"
|
38
|
+
found << [f, db[d]]
|
39
|
+
else
|
40
|
+
db[d] = f
|
41
|
+
seen << d
|
42
|
+
puts "Processed #{seen.length} / #{res.length} (#{(seen.length.to_f/res.length.to_f*100.0).ceil(2)} %)"
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
if found.length > 0
|
48
|
+
begin
|
49
|
+
found.each do |f|
|
50
|
+
sel = pmt.select(" There are some duplicated files found. Please select which one to DELETE or keep both : ".yellow) do |m|
|
51
|
+
m.choice f[0], f[0]
|
52
|
+
m.choice f[1], f[1]
|
53
|
+
m.choice "Keep both", :keep
|
54
|
+
end
|
55
|
+
|
56
|
+
if sel != :keep
|
57
|
+
proceed = pmt.yes?(" Delete file at ? \n #{sel}".yellow)
|
58
|
+
if proceed
|
59
|
+
ElibMgmt::Cli.move_to_int_bin(root, sel)
|
60
|
+
pmt.puts " Duplicated file '#{sel}' moved to bin".green
|
61
|
+
else
|
62
|
+
pmt.puts " File deletion skipped.".yellow
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
rescue TTY::Reader::InputInterrup
|
67
|
+
ensure
|
68
|
+
pmt.puts " All duplicated files done processing".green
|
69
|
+
end
|
70
|
+
|
71
|
+
#pmt.puts " All duplicated files done processing".green
|
72
|
+
else
|
73
|
+
pmt.puts " There is no duplicated files found".green
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
data/exe/elm_search
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'elib_mgmt/cli'
|
4
|
+
require 'tty/prompt'
|
5
|
+
require 'colorize'
|
6
|
+
|
7
|
+
require 'string/similarity'
|
8
|
+
require 'openssl'
|
9
|
+
|
10
|
+
if ARGV.length < 2
|
11
|
+
STDERR.puts " <root> <keyword, split by ','>".red
|
12
|
+
exit(0)
|
13
|
+
|
14
|
+
else
|
15
|
+
pmt = TTY::Prompt.new
|
16
|
+
|
17
|
+
pmt.puts "\n eLib Management Utilities version #{ElibMgmt::Cli::VERSION}\n\n"
|
18
|
+
pmt.puts " Search files with specific keywords"
|
19
|
+
|
20
|
+
root = ARGV.first
|
21
|
+
root = File.expand_path(root)
|
22
|
+
pmt.puts " Root to search : #{root}\n\n"
|
23
|
+
|
24
|
+
kw = ARGV[1]
|
25
|
+
kw = kw.split(",").map { |v| v.strip }.reject { |v| v.empty? }
|
26
|
+
|
27
|
+
pmt.puts " Keyword to search : #{kw.join(", ")}\n\n"
|
28
|
+
|
29
|
+
ttl = 0
|
30
|
+
found = { }
|
31
|
+
|
32
|
+
files = Dir.glob(File.join(root,"**/**")).reject { |f| File.directory?(f) }
|
33
|
+
|
34
|
+
filter = ElibMgmt::Cli::FileFilter.new(root)
|
35
|
+
kw.each do |k|
|
36
|
+
res = filter.filter(k, "**/**")
|
37
|
+
|
38
|
+
found[k] = res
|
39
|
+
ttl += res.length
|
40
|
+
end
|
41
|
+
|
42
|
+
pmt.puts " Found #{ttl} file(s) \n\n".light_blue
|
43
|
+
if TR::RTUtils.on_linux?
|
44
|
+
begin
|
45
|
+
sel = pmt.select(" Open the files? ".yellow) do |m|
|
46
|
+
found.values.flatten.each do |f|
|
47
|
+
m.choice " * #{f}", f
|
48
|
+
end
|
49
|
+
m.choice " + I've done", :abort
|
50
|
+
end
|
51
|
+
|
52
|
+
if sel != :abort
|
53
|
+
`xdg-open #{sel}`
|
54
|
+
else
|
55
|
+
pmt.puts "\n\n Have a nice day\n\n".yellow
|
56
|
+
end
|
57
|
+
rescue TTY::Reader::InputInterrupt
|
58
|
+
pmt.puts "\n\n Have a nice day\n\n".yellow
|
59
|
+
end
|
60
|
+
|
61
|
+
else
|
62
|
+
|
63
|
+
found.each do |k,v|
|
64
|
+
v.each do |f|
|
65
|
+
pmt.puts " * #{f}"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
require 'yaml'
|
3
|
+
require 'toolrack'
|
4
|
+
|
5
|
+
module ElibMgmt
|
6
|
+
module Cli
|
7
|
+
class ConfigError < StandardError; end
|
8
|
+
class Config
|
9
|
+
include TR::CondUtils
|
10
|
+
|
11
|
+
def self.load(conf)
|
12
|
+
raise ConfigError, "Config file given is null" if is_empty?(conf)
|
13
|
+
raise ConfigError, "Config file '#{conf}' not found" if not File.exist?(conf)
|
14
|
+
|
15
|
+
Config.new(YAML.load(File.read(conf)))
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
def initialize(existing = { })
|
20
|
+
@rec = existing || { }
|
21
|
+
end
|
22
|
+
|
23
|
+
def matching_spec(outdir, spec)
|
24
|
+
@rec[:sort_spec]
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,140 @@
|
|
1
|
+
|
2
|
+
require 'toolrack'
|
3
|
+
require 'teLogger'
|
4
|
+
|
5
|
+
module ElibMgmt
|
6
|
+
module Cli
|
7
|
+
class FileFilter
|
8
|
+
include TR::CondUtils
|
9
|
+
|
10
|
+
SPat = "[-,_,.,\\s]"
|
11
|
+
SPat2 = "[\(,\),-,_,.,\\s]"
|
12
|
+
SPatL = "[\(,-,_,.,\\s]"
|
13
|
+
SPatR = "[\),-,_,.,\\s]"
|
14
|
+
|
15
|
+
attr_reader :base_path
|
16
|
+
def initialize(base)
|
17
|
+
@base_path = base
|
18
|
+
@logger = TeLogger::Tlogger.new(STDOUT)
|
19
|
+
@logger.tag = :ffilter
|
20
|
+
end
|
21
|
+
|
22
|
+
def filter(name, pattern = "**/**", opts = {})
|
23
|
+
if is_empty?(name)
|
24
|
+
[]
|
25
|
+
else
|
26
|
+
|
27
|
+
defOpts = {
|
28
|
+
mode: :relax
|
29
|
+
}
|
30
|
+
|
31
|
+
sOpts = defOpts.merge(opts)
|
32
|
+
|
33
|
+
spec = []
|
34
|
+
if name.include?("*")
|
35
|
+
|
36
|
+
found = Dir.glob(File.join(@base_path, pattern)).reject { |f| File.directory?(f) }.select { |v|
|
37
|
+
|
38
|
+
vv = File.basename(v)
|
39
|
+
spec = name.gsub("*","\\w*")
|
40
|
+
case sOpts[:mode]
|
41
|
+
when :strict
|
42
|
+
#@logger.odebug "Word with '*' '#{name}' strict mode"
|
43
|
+
vv =~ /[\(,-,_,.,\s]#{spec}[\),-,_,.,\s]/i or
|
44
|
+
vv =~ /^#{spec}#{SPat}/i or
|
45
|
+
vv =~ /#{SPat}#{spec}\z/i
|
46
|
+
else
|
47
|
+
#@logger.odebug "Word with '*' '#{name}' relax mode"
|
48
|
+
vv =~ /#{SPat}#{spec}#{SPat}/i or
|
49
|
+
vv =~ /#{SPat}#{spec}/i or
|
50
|
+
vv =~ /#{spec}#{SPat}/i
|
51
|
+
end
|
52
|
+
|
53
|
+
}
|
54
|
+
|
55
|
+
elsif name.include?(" ")
|
56
|
+
|
57
|
+
pname = name.split(" ").map { |v| "#{v}" }
|
58
|
+
spec = pname.join(SPat)
|
59
|
+
|
60
|
+
found = Dir.glob(File.join(@base_path, pattern)).reject { |f| File.directory?(f) }.select { |v|
|
61
|
+
|
62
|
+
vv = File.basename(v)
|
63
|
+
case sOpts[:mode]
|
64
|
+
when :strict
|
65
|
+
#@logger.odebug "Word with space '#{name}' strict mode"
|
66
|
+
vv =~ /#{SPat}#{spec}#{SPat}/i or
|
67
|
+
vv =~ /^#{spec}#{SPat}/i or
|
68
|
+
vv =~ /#{SPat}#{spec}\z/i
|
69
|
+
else
|
70
|
+
#@logger.odebug "Word with space '#{name}' relax mode"
|
71
|
+
vv =~ /#{SPat}#{spec}#{SPat}/i or
|
72
|
+
vv =~ /#{SPat}#{spec}/i or
|
73
|
+
vv =~ /#{spec}#{SPat}/i
|
74
|
+
end
|
75
|
+
|
76
|
+
}
|
77
|
+
|
78
|
+
|
79
|
+
else
|
80
|
+
|
81
|
+
# single word
|
82
|
+
found = Dir.glob(File.join(@base_path, pattern)).reject { |f| File.directory?(f) }.select { |v|
|
83
|
+
|
84
|
+
vv = File.basename(v)
|
85
|
+
case sOpts[:mode]
|
86
|
+
when :strict
|
87
|
+
#@logger.debug "Single word '#{name}' strict mode"
|
88
|
+
vv =~ /^#{name}[-,_,.,\s]/i or vv =~ /[-,_,.,\s]#{name}[-,_,.,\s]/i or vv =~ /[-,_,.,\s]#{name}\z/i
|
89
|
+
else
|
90
|
+
#@logger.debug "Single word '#{name}' relex mode"
|
91
|
+
vv =~ /[-,_,.,\s]#{name}[-,_,.,\s]/i or
|
92
|
+
vv =~ /[-,_,.,\s]#{name}/i or
|
93
|
+
vv =~ /#{name}[-,_,.,\s]/i
|
94
|
+
end
|
95
|
+
|
96
|
+
}
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
#if name.include?(" ")
|
101
|
+
|
102
|
+
# ["-","_","."].each do |c|
|
103
|
+
# key = name.downcase.split(" ")
|
104
|
+
# res = Dir.glob(File.join(@base_path, pattern)).reject { |f| File.directory?(f) }.select { |v|
|
105
|
+
# n = File.basename(v, File.extname(v)).downcase
|
106
|
+
# (key - n.split(" ").map(&:strip)).empty? || (key - n.split("-").map(&:strip)).empty? || (key - n.split("_").map(&:strip)).empty? || (key - n.split(".").map(&:strip)).empty?
|
107
|
+
# }
|
108
|
+
# found += res
|
109
|
+
# end
|
110
|
+
|
111
|
+
#else
|
112
|
+
|
113
|
+
# key = name.downcase
|
114
|
+
# res = Dir.glob(File.join(@base_path, pattern)).reject { |f| File.directory?(f) }.select { |v|
|
115
|
+
# n = File.basename(v, File.extname(v)).downcase
|
116
|
+
# n.split(" ").map(&:strip).include?(key) || n.split("-").map(&:strip).include?(key) || n.split("_").map(&:strip).include?(key) || n.split(".").map(&:strip).include?(key)
|
117
|
+
# }
|
118
|
+
# found += res
|
119
|
+
|
120
|
+
#end
|
121
|
+
|
122
|
+
#found.uniq
|
123
|
+
found
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
127
|
+
|
128
|
+
private
|
129
|
+
def const_pattern(val)
|
130
|
+
[
|
131
|
+
"#{SPat}#{val}#{SPat}",
|
132
|
+
"#{SPat}#{val}",
|
133
|
+
"#{val}#{SPat}"
|
134
|
+
]
|
135
|
+
end
|
136
|
+
|
137
|
+
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'toolrack'
|
4
|
+
require 'teLogger'
|
5
|
+
|
6
|
+
require_relative "cli/version"
|
7
|
+
require_relative 'cli/file_filter'
|
8
|
+
|
9
|
+
module ElibMgmt
|
10
|
+
module Cli
|
11
|
+
class Error < StandardError; end
|
12
|
+
# Your code goes here...
|
13
|
+
|
14
|
+
include TR::CondUtils
|
15
|
+
|
16
|
+
def udebug(msg)
|
17
|
+
logger.tdebug(:elib, msg) if is_user_debug_on?
|
18
|
+
end
|
19
|
+
def self.logger
|
20
|
+
if @_logger.nil?
|
21
|
+
@_logger = TeLogger::Tlogger.new
|
22
|
+
end
|
23
|
+
@_logger
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.is_user_debug_on?
|
27
|
+
val = ENV["ELIBMGMT_DEBUG"]
|
28
|
+
(not_empty?(val) and val == "true")
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.move_to_int_bin(root, file)
|
32
|
+
if @_bin.nil?
|
33
|
+
@_bin = File.join(root, ".elBin")
|
34
|
+
FileUtils.mkdir_p(@_bin) if not File.exist?(@_bin)
|
35
|
+
end
|
36
|
+
|
37
|
+
FileUtils.mv(file, File.join(@_bin, File.basename(file)))
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
data/mapping.yml
ADDED
@@ -0,0 +1,357 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
---
|
4
|
+
"config":
|
5
|
+
"reset_before_sort": true
|
6
|
+
:sort_spec:
|
7
|
+
- :outdir: "R"
|
8
|
+
:matcher:
|
9
|
+
- "r":
|
10
|
+
:mode: :strict
|
11
|
+
- :outdir: "Design related"
|
12
|
+
:matcher:
|
13
|
+
- "design"
|
14
|
+
- "ux"
|
15
|
+
- "user experience"
|
16
|
+
- "designing interfaces"
|
17
|
+
- :outdir: "Javascript"
|
18
|
+
:matcher:
|
19
|
+
- "javascript"
|
20
|
+
- "d3"
|
21
|
+
- "ext-js"
|
22
|
+
- "highchart"
|
23
|
+
- :outdir: "Javascript/jQuery"
|
24
|
+
:matcher:
|
25
|
+
- "jquery"
|
26
|
+
- :outdir: "Javascript/React"
|
27
|
+
:matcher:
|
28
|
+
- "react"
|
29
|
+
- :outdir: "Javascript/Vue"
|
30
|
+
:matcher:
|
31
|
+
- "vue"
|
32
|
+
- :outdir: "Javascript/Node"
|
33
|
+
:matcher:
|
34
|
+
- "node"
|
35
|
+
- :outdir: "Blockchain"
|
36
|
+
:matcher:
|
37
|
+
- "blockchain"
|
38
|
+
- "bitcoin"
|
39
|
+
- "ethereum"
|
40
|
+
- :outdir: "Ada"
|
41
|
+
:matcher:
|
42
|
+
- "ada"
|
43
|
+
- :outdir: "Security"
|
44
|
+
:matcher:
|
45
|
+
- "secur*"
|
46
|
+
- "tls"
|
47
|
+
- "ssl"
|
48
|
+
- "cryptogra*"
|
49
|
+
- "threat"
|
50
|
+
- "malware"
|
51
|
+
- "penetrat*"
|
52
|
+
- "reverse*"
|
53
|
+
- "bounty*"
|
54
|
+
- "offensive*"
|
55
|
+
- "ethical"
|
56
|
+
- "forensic"
|
57
|
+
- "crack*"
|
58
|
+
- "hack*"
|
59
|
+
- "cybercrime"
|
60
|
+
- "attack*"
|
61
|
+
- "defend*"
|
62
|
+
- "dark web"
|
63
|
+
- "trustworthy"
|
64
|
+
- "exploit*"
|
65
|
+
- "blackhat"
|
66
|
+
- "gray hat"
|
67
|
+
- "dump analysis"
|
68
|
+
- "threat*"
|
69
|
+
- "antivirus"
|
70
|
+
- "backtrack"
|
71
|
+
- "obfuscation*"
|
72
|
+
- "devopssec"
|
73
|
+
- "hack*"
|
74
|
+
- "memory analysis"
|
75
|
+
- "openvpn"
|
76
|
+
- "rootkit*"
|
77
|
+
- "intrusion*"
|
78
|
+
- "pentest*"
|
79
|
+
- "fuzz*"
|
80
|
+
- "burp"
|
81
|
+
- "red team"
|
82
|
+
- "blue team"
|
83
|
+
- "ghidra"
|
84
|
+
- "binary analysis"
|
85
|
+
- "radare*"
|
86
|
+
- :outdir: "Security/Metasploit"
|
87
|
+
:matcher:
|
88
|
+
- "metasploit"
|
89
|
+
- :outdir: "Security/netcat"
|
90
|
+
:matcher:
|
91
|
+
- "netcat"
|
92
|
+
- :outdir: "Security/nmap"
|
93
|
+
:matcher:
|
94
|
+
- "nmap"
|
95
|
+
- :outdir: "Security/Wireshark"
|
96
|
+
:matcher:
|
97
|
+
- "wireshark"
|
98
|
+
- :outdir: "Security/CISSP"
|
99
|
+
:matcher:
|
100
|
+
- "cissp"
|
101
|
+
- :outdir: "Security/SANS"
|
102
|
+
:matcher:
|
103
|
+
- "sans"
|
104
|
+
- :outdir: "Security/IDA"
|
105
|
+
:matcher:
|
106
|
+
- "ida"
|
107
|
+
- :outdir: "Arduino"
|
108
|
+
:matcher:
|
109
|
+
- "arduino"
|
110
|
+
- :outdir: "Scala"
|
111
|
+
:matcher:
|
112
|
+
- "scala"
|
113
|
+
- :outdir: "Clojure"
|
114
|
+
:matcher:
|
115
|
+
- "clojure"
|
116
|
+
- :outdir: "Java"
|
117
|
+
:matcher:
|
118
|
+
- "java"
|
119
|
+
- "jdk"
|
120
|
+
- "jre"
|
121
|
+
- "hibernate"
|
122
|
+
- "swt"
|
123
|
+
- "jfx"
|
124
|
+
- "javafx"
|
125
|
+
- :outdir: "Java/Android"
|
126
|
+
:matcher:
|
127
|
+
- "android"
|
128
|
+
- :outdir: "Agile-Scrum"
|
129
|
+
:matcher:
|
130
|
+
- "agile"
|
131
|
+
- "scrum"
|
132
|
+
- :outdir: "Software Business"
|
133
|
+
:matcher:
|
134
|
+
- "in search of stupidity"
|
135
|
+
- "open source"
|
136
|
+
- :outdir: "Software Engineering"
|
137
|
+
:matcher:
|
138
|
+
- "domain driven"
|
139
|
+
- "test driven"
|
140
|
+
- "tdd"
|
141
|
+
- "bdd"
|
142
|
+
- "software testing"
|
143
|
+
- "continuous delivery"
|
144
|
+
- "event processing"
|
145
|
+
- "devops"
|
146
|
+
- "software estimation"
|
147
|
+
- "software by number"
|
148
|
+
- "software technology"
|
149
|
+
- "programming architecture"
|
150
|
+
- "iterative software development"
|
151
|
+
- :outdir: "Software Engineering/Testing"
|
152
|
+
:matcher:
|
153
|
+
- "testing"
|
154
|
+
- :outdir: "Software Engineering/Clean"
|
155
|
+
:matcher:
|
156
|
+
- "clean"
|
157
|
+
- :outdir: "Software Engineering/Design Pattern"
|
158
|
+
:matcher:
|
159
|
+
- "design pattern*"
|
160
|
+
- "pattern*"
|
161
|
+
- :outdir: "Software Engineering Tools"
|
162
|
+
:matcher:
|
163
|
+
- "git"
|
164
|
+
- "vagrant"
|
165
|
+
- "docker"
|
166
|
+
- "elastic"
|
167
|
+
- "cassandra"
|
168
|
+
- "entity framework"
|
169
|
+
- "hadoop"
|
170
|
+
- "test automation"
|
171
|
+
- "jenkin"
|
172
|
+
- "jmeter"
|
173
|
+
- "gradle"
|
174
|
+
- "apache"
|
175
|
+
- "libvirt"
|
176
|
+
- "telegram"
|
177
|
+
- :outdir: "Database"
|
178
|
+
:matcher:
|
179
|
+
- "graph databases"
|
180
|
+
- :outdir: "Database/PostgreSQL"
|
181
|
+
:matcher:
|
182
|
+
- "postgres*"
|
183
|
+
- :outdir: "Raspberry-Pi"
|
184
|
+
:matcher:
|
185
|
+
- "raspberry*"
|
186
|
+
- :outdir: "Mobile Dev"
|
187
|
+
:matcher:
|
188
|
+
- "mobile"
|
189
|
+
- "hybrid"
|
190
|
+
- :outdir: "Python"
|
191
|
+
:matcher:
|
192
|
+
- "python"
|
193
|
+
- :outdir: "Windows"
|
194
|
+
:matcher:
|
195
|
+
- "windows"
|
196
|
+
- :outdir: "_nix"
|
197
|
+
:matcher:
|
198
|
+
- "unix"
|
199
|
+
- :outdir: "_nix/linux"
|
200
|
+
:matcher:
|
201
|
+
- "linux"
|
202
|
+
- "gdb"
|
203
|
+
- "kernel"
|
204
|
+
- "bash"
|
205
|
+
- :outdir: "_nix/bsd"
|
206
|
+
:matcher:
|
207
|
+
- "bsd"
|
208
|
+
- :outdir: "Others/OpenCV"
|
209
|
+
:matcher:
|
210
|
+
- "opencv"
|
211
|
+
- :outdir: "Others/Tensorflow"
|
212
|
+
:matcher:
|
213
|
+
- "tensorflow"
|
214
|
+
- :outdir: "Others/IPV6"
|
215
|
+
:matcher:
|
216
|
+
- "ipv6"
|
217
|
+
- :outdir: "Others/tex"
|
218
|
+
:matcher:
|
219
|
+
- "tex"
|
220
|
+
- :outdir: "Lisp Scheme Family"
|
221
|
+
:matcher:
|
222
|
+
- "lisp"
|
223
|
+
- "scheme"
|
224
|
+
- :outdir: "Prolog"
|
225
|
+
:matcher:
|
226
|
+
- "prolog"
|
227
|
+
- :outdir: "Excel"
|
228
|
+
:matcher:
|
229
|
+
- "excel"
|
230
|
+
- :outdir: "GIMP"
|
231
|
+
:matcher:
|
232
|
+
- "gimp"
|
233
|
+
- :outdir: "Editor/VIM"
|
234
|
+
:matcher:
|
235
|
+
- "vim"
|
236
|
+
- "vi"
|
237
|
+
- :outdir: "Editor/Emacs"
|
238
|
+
:matcher:
|
239
|
+
- "emacs"
|
240
|
+
- :outdir: "Editor/Sublime"
|
241
|
+
:matcher:
|
242
|
+
- "sublime"
|
243
|
+
- :outdir: "GUI/gtk"
|
244
|
+
:matcher:
|
245
|
+
- "gtk"
|
246
|
+
- "gnome"
|
247
|
+
- :outdir: "GUI/Qt"
|
248
|
+
:matcher:
|
249
|
+
- "qt"
|
250
|
+
- :outdir: "GUI/wxWidget"
|
251
|
+
:matcher:
|
252
|
+
- "wxwidget"
|
253
|
+
- :outdir: "Algo"
|
254
|
+
:matcher:
|
255
|
+
- "art of computer programming"
|
256
|
+
- "algo*"
|
257
|
+
- "bayesian"
|
258
|
+
- :outdir: "Elixir-Erlang"
|
259
|
+
:matcher:
|
260
|
+
- "erlang"
|
261
|
+
- "elixir"
|
262
|
+
- "phoenix"
|
263
|
+
- "gen-server"
|
264
|
+
- :outdir: "Flutter-Dart"
|
265
|
+
:matcher:
|
266
|
+
- "flutter"
|
267
|
+
- "dart"
|
268
|
+
- :outdir: "Automation"
|
269
|
+
:matcher:
|
270
|
+
- "cucumber"
|
271
|
+
- "capybara"
|
272
|
+
- "chef"
|
273
|
+
- "selenium"
|
274
|
+
- "puppet"
|
275
|
+
- :outdir: "lua"
|
276
|
+
:matcher:
|
277
|
+
- "lua"
|
278
|
+
- :outdir: "Rust"
|
279
|
+
:matcher:
|
280
|
+
- "rust*"
|
281
|
+
- :outdir: "Go"
|
282
|
+
:matcher:
|
283
|
+
- "go*"
|
284
|
+
- "golang"
|
285
|
+
- :outdir: "Mac iOS"
|
286
|
+
:matcher:
|
287
|
+
- "swift"
|
288
|
+
- "ios"
|
289
|
+
- "iphone"
|
290
|
+
- "ipad"
|
291
|
+
- "objective-c"
|
292
|
+
- "apple"
|
293
|
+
- "xcode"
|
294
|
+
- :outdir: "C Assembly Compiler OS"
|
295
|
+
:matcher:
|
296
|
+
- "intel"
|
297
|
+
- "c":
|
298
|
+
:mode: :strict
|
299
|
+
- "assembly"
|
300
|
+
- "opcode"
|
301
|
+
- "ooc"
|
302
|
+
- "gcc"
|
303
|
+
- "c20"
|
304
|
+
- "cuda"
|
305
|
+
- "pointer"
|
306
|
+
- "compiler"
|
307
|
+
- "operating system"
|
308
|
+
- "pthread*"
|
309
|
+
- "c\\+\\+"
|
310
|
+
- "antlr"
|
311
|
+
- :outdir: "MicroService RESTFUL WebService"
|
312
|
+
:matcher:
|
313
|
+
- "web service*"
|
314
|
+
- "rest*"
|
315
|
+
- "microservice*"
|
316
|
+
- :outdir: "Game-3D"
|
317
|
+
:matcher:
|
318
|
+
- "unity"
|
319
|
+
- "webgl"
|
320
|
+
- "opengl"
|
321
|
+
- "blender"
|
322
|
+
- "3d"
|
323
|
+
- "unreal"
|
324
|
+
- "game"
|
325
|
+
- "vulkan"
|
326
|
+
:sub_dir_spec:
|
327
|
+
- :outdir: "Android"
|
328
|
+
:matcher:
|
329
|
+
- "android"
|
330
|
+
- :outdir: "Blender"
|
331
|
+
:matcher:
|
332
|
+
- "blender"
|
333
|
+
- :outdir: "Java"
|
334
|
+
:matcher:
|
335
|
+
- "java javafx"
|
336
|
+
- :outdir: "Swift_iOS"
|
337
|
+
:matcher:
|
338
|
+
- "swift"
|
339
|
+
- "ios"
|
340
|
+
- :outdir: "Unity"
|
341
|
+
:matcher:
|
342
|
+
- "unity"
|
343
|
+
- :outdir: "Unreal"
|
344
|
+
:matcher:
|
345
|
+
- "unreal"
|
346
|
+
- :outdir: "OpenGL"
|
347
|
+
:matcher:
|
348
|
+
- "opengl"
|
349
|
+
- :outdir: "Ruby-Rails"
|
350
|
+
:matcher:
|
351
|
+
- "ruby*"
|
352
|
+
- "rails"
|
353
|
+
- "rspec"
|
354
|
+
- "rake"
|
355
|
+
- "sinatra"
|
356
|
+
- "nokogiri"
|
357
|
+
- "merb"
|
data/regex_live_text.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
|
2
|
+
Mode = :strict
|
3
|
+
name = "windows"
|
4
|
+
|
5
|
+
found = Dir.glob(File.join("/mnt/WinVault/Alexandrial/Technical", "**/**")).reject { |f| File.directory?(f) }.select { |v|
|
6
|
+
|
7
|
+
vv = File.basename(v)
|
8
|
+
case Mode
|
9
|
+
when :strict
|
10
|
+
|
11
|
+
res1 = (/^#{name}[-,_,.,\s]/i =~ vv)
|
12
|
+
res2 = (vv =~ /[\(,-,_,.,\s]#{name}[\),-,_,.,\s]/i)
|
13
|
+
res3 = (vv =~ /[-,_,.,\s]#{name}\z/i)
|
14
|
+
|
15
|
+
puts "#{vv} : #{res1} / #{res2} / #{res3}"
|
16
|
+
|
17
|
+
(res1 or res2 or res3)
|
18
|
+
|
19
|
+
else
|
20
|
+
|
21
|
+
res1 = (vv =~ /[(,-,_,.,\s]#{name}[),-,_,.,\s]/i)
|
22
|
+
res2 = (vv =~ /[(,-,_,.,\s]#{name}/i)
|
23
|
+
res3 = (vv =~ /#{name}[),-,_,.,\s]/i)
|
24
|
+
|
25
|
+
puts "#{vv} : #{res1} / #{res2} / #{res3}"
|
26
|
+
(res1 or res2 or res3)
|
27
|
+
end
|
28
|
+
|
29
|
+
}
|
30
|
+
|
31
|
+
p found
|
32
|
+
|
data/regex_test.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
|
2
|
+
t = []
|
3
|
+
t << "art-of-computer-programming-"
|
4
|
+
t << "the-art-of-programming"
|
5
|
+
t << "the.art.of.programming"
|
6
|
+
t << "the_art_of_programming"
|
7
|
+
t << "art.of.taling"
|
8
|
+
t << "whatever there"
|
9
|
+
t << "art of whatever"
|
10
|
+
t << "tart.is.delicious"
|
11
|
+
t << "the-art.of-sing"
|
12
|
+
t << "nothing here"
|
13
|
+
t << " art-anter"
|
14
|
+
t << "Bug Bounty Playbook"
|
15
|
+
t << "the art"
|
16
|
+
t << "this is (art) of bounty"
|
17
|
+
t << "r-quick-syntax-reference.9781430266402.65848"
|
18
|
+
t << "r-cookbook-oreilly-cookbooks"
|
19
|
+
t << "using-r-for-data-analysis-in-social-sciences.9780190656225.90561"
|
20
|
+
t << "a-data-scientists-guide-to-acquiring-cleaning-and-managing-data-in-r.9781119080022.73583"
|
21
|
+
|
22
|
+
name = "r"
|
23
|
+
p t.select { |v|
|
24
|
+
v =~ /#{name}[-,.,_,\s]/ or
|
25
|
+
v =~ /[-,.,_,\s]#{name}[-,.,_,\s]/ or
|
26
|
+
v =~ /[-,.,_,\s]#{name}\z/
|
27
|
+
#v =~ /^#{name}[-,.,_,\s]/i
|
28
|
+
#v =~ /[\(,\),-,.,_,\s]r[\(,\),-,.,_,\s]/ or
|
29
|
+
#v =~ /[\(,\),-,.,_,\s]r\z/
|
30
|
+
#v =~ /[-,.,_,\s]program\w+[-,.,_,\s]/ or
|
31
|
+
#v =~ /program\w+[-,.,_,\s]/ or
|
32
|
+
#v =~ /[-,.,_,\s]program\w+/
|
33
|
+
#v =~ /[-,.,_,\s]bounty\w*[-,.,_,\s]/i
|
34
|
+
#v =~ /[-,.,_,\s]art\z/
|
35
|
+
#v =~ /^art[-,.,_,\s]/
|
36
|
+
}
|
37
|
+
|
metadata
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: elib_mgmt-cli
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chris
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-03-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: string-similarity
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: toolrack
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: teLogger
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: tty-prompt
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: colorize
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: devops_assist
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: ''
|
98
|
+
email:
|
99
|
+
- chris@antrapol.com
|
100
|
+
executables:
|
101
|
+
- elm_auto_sort
|
102
|
+
- elm_config_auto_sort
|
103
|
+
- elm_find_duplicated
|
104
|
+
- elm_search
|
105
|
+
extensions: []
|
106
|
+
extra_rdoc_files: []
|
107
|
+
files:
|
108
|
+
- ".rspec"
|
109
|
+
- Gemfile
|
110
|
+
- Gemfile.lock
|
111
|
+
- README.md
|
112
|
+
- Rakefile
|
113
|
+
- elib_mgmt-cli.gemspec
|
114
|
+
- exe/elm_auto_sort
|
115
|
+
- exe/elm_config_auto_sort
|
116
|
+
- exe/elm_find_duplicated
|
117
|
+
- exe/elm_search
|
118
|
+
- lib/elib_mgmt/cli.rb
|
119
|
+
- lib/elib_mgmt/cli/config.rb
|
120
|
+
- lib/elib_mgmt/cli/file_filter.rb
|
121
|
+
- lib/elib_mgmt/cli/version.rb
|
122
|
+
- mapping.yml
|
123
|
+
- regex_live_text.rb
|
124
|
+
- regex_test.rb
|
125
|
+
- sig/elib_mgmt/cli.rbs
|
126
|
+
homepage: ''
|
127
|
+
licenses: []
|
128
|
+
metadata: {}
|
129
|
+
post_install_message:
|
130
|
+
rdoc_options: []
|
131
|
+
require_paths:
|
132
|
+
- lib
|
133
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: 2.6.0
|
138
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
requirements: []
|
144
|
+
rubygems_version: 3.4.6
|
145
|
+
signing_key:
|
146
|
+
specification_version: 4
|
147
|
+
summary: ''
|
148
|
+
test_files: []
|