claiss 1.0.1 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/claiss +5 -0
- data/lib/claiss.rb +72 -14
- metadata +50 -8
- data/bin/claiss +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 111930915061d881a017a8f3d0865d606717c5b5f198a37204324dcf35ad2ad6
|
4
|
+
data.tar.gz: bfa45b41895c4de0be9e4d71d73e9181b41d50699696b5562387979a2c76163b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7fd6115f2b46b9dd6d77386cf40c78ca364ca23bcbb8e2fde184572a8e2be0753c26069e76462025a23ad04fec8ae6e08380aeb360cf37e4d147af3d3f9d916
|
7
|
+
data.tar.gz: '0088d2492a54bd95ab8c9b23d81def46d28b947d0993a79759d4150d013280890ff44680d01266bc29c015c8628a78505b77f0e0f04d9d90bced279aff15cbcf'
|
data/exe/claiss
ADDED
data/lib/claiss.rb
CHANGED
@@ -1,17 +1,75 @@
|
|
1
|
+
require "bundler/setup"
|
2
|
+
require "dry/cli"
|
3
|
+
require "fileutils"
|
4
|
+
require "pathname"
|
5
|
+
require 'find'
|
6
|
+
require 'json'
|
7
|
+
|
1
8
|
module Claiss
|
2
|
-
|
3
|
-
# spec = Gem::Specification::load("claiss.gemspec")
|
4
|
-
# puts "#{spec.summary}"
|
5
|
-
# puts "Version: #{spec.version}"
|
6
|
-
# end
|
7
|
-
module Commands
|
8
|
-
extend Dry::CLI::Registry
|
9
|
+
extend Dry::CLI::Registry
|
9
10
|
|
10
11
|
class Version < Dry::CLI::Command
|
11
12
|
desc "Print version"
|
12
13
|
|
13
14
|
def call(*)
|
14
|
-
|
15
|
+
spec = Gem::Specification::load("claiss.gemspec")
|
16
|
+
puts "#{spec.summary}"
|
17
|
+
puts "Version: #{spec.version}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class Refactor < Dry::CLI::Command
|
22
|
+
desc "Refactors terms and files on directories"
|
23
|
+
argument :path, type: :string, required: true, desc: "Relative path directory"
|
24
|
+
argument :json_file, type: :string, required: false, desc: "Provide a Ruby hash file"
|
25
|
+
def call(path:, json_file:, **)
|
26
|
+
dict = {}
|
27
|
+
search = ""
|
28
|
+
replace = ""
|
29
|
+
input = "y"
|
30
|
+
|
31
|
+
if !json_file.nil? || !json_file.empty?
|
32
|
+
jfile = File.read(json_file)
|
33
|
+
dict = JSON.parse(jfile)
|
34
|
+
else
|
35
|
+
while input.downcase == "y" do
|
36
|
+
puts "Term to search: "
|
37
|
+
search = STDIN.gets.chomp
|
38
|
+
puts "Term to replace: "
|
39
|
+
replace = STDIN.gets.chomp
|
40
|
+
|
41
|
+
dict[search] = replace
|
42
|
+
puts "\nAdd another? Type Y \nto Start Refactoring press Enter"
|
43
|
+
input = STDIN.gets.chomp!
|
44
|
+
end
|
45
|
+
end
|
46
|
+
puts dict.inspect
|
47
|
+
dict[path] = "refactored-#{Time.now.to_i.to_s}/"
|
48
|
+
Dir.glob(path + "**/" +"*").reject{ |f| File.directory?(f)}.each do |file|
|
49
|
+
destination = file.to_s
|
50
|
+
text = File.read(file) if !File.directory?(file)
|
51
|
+
|
52
|
+
dict.map do |p, i|
|
53
|
+
destination.gsub!(p, i)
|
54
|
+
if !text.nil?
|
55
|
+
text.gsub!(p, i)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
puts "Destination file #{destination}"
|
60
|
+
FileUtils.mkdir_p(File.dirname(destination)) unless File.exist?(destination)
|
61
|
+
File.open(destination, "wb") do |f|
|
62
|
+
f.puts text
|
63
|
+
end
|
64
|
+
end
|
65
|
+
puts "Do you want Move and delete to the original folder? (y/n): "
|
66
|
+
del = STDIN.gets.chomp
|
67
|
+
if del.downcase == "y"
|
68
|
+
FileUtils.rm_r(path)
|
69
|
+
FileUtils.mv dict[path], path
|
70
|
+
puts "Moved from #{dict[path]} to #{path}"
|
71
|
+
end
|
72
|
+
|
15
73
|
end
|
16
74
|
end
|
17
75
|
|
@@ -92,14 +150,14 @@ module Claiss
|
|
92
150
|
end
|
93
151
|
|
94
152
|
register "version", Version, aliases: ["v", "-v", "--version"]
|
95
|
-
register "echo", Echo
|
96
|
-
register "start", Start
|
97
|
-
register "stop", Stop
|
98
|
-
register "exec", Exec
|
153
|
+
#register "echo", Echo
|
154
|
+
#register "start", Start
|
155
|
+
#register "stop", Stop
|
156
|
+
#register "exec", Exec
|
157
|
+
register "refactor",Refactor
|
99
158
|
|
100
159
|
register "generate", aliases: ["g"] do |prefix|
|
101
160
|
prefix.register "config", Generate::Configuration
|
102
161
|
prefix.register "test", Generate::Test
|
103
162
|
end
|
104
|
-
end
|
105
|
-
end
|
163
|
+
end
|
metadata
CHANGED
@@ -1,29 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: claiss
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Júlio Papel
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-07-
|
11
|
+
date: 2023-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-cli
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.0.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:
|
26
|
+
version: 1.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pathname
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.2.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.2.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: fileutils
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.7.1
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.7.1
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: json
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.6.3
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.6.3
|
27
69
|
description: CLI application Toolbox to manage Laiss AI applications and deployments.
|
28
70
|
Some thing may not work on your environment. Use with caution!
|
29
71
|
email:
|
@@ -33,7 +75,7 @@ executables:
|
|
33
75
|
extensions: []
|
34
76
|
extra_rdoc_files: []
|
35
77
|
files:
|
36
|
-
-
|
78
|
+
- exe/claiss
|
37
79
|
- lib/claiss.rb
|
38
80
|
- lib/tasks/claiss.rake
|
39
81
|
homepage: http://rubygems.org/gems/claiss
|