claiss 1.0.3 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/claiss +1 -1
- data/lib/claiss.rb +19 -99
- data/lib/tasks/claiss.rake +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a80a9f089824ea94bc360a4fa8bc0e70f0a6a8a5b307782654cfd7308c36a0f2
|
4
|
+
data.tar.gz: 610227313b276fb02a7f0a29d37667d3aecc0e4ff1a7952e91e18c2eb234766e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ac085f33543b4e03f6904775108bc82aab0fb0a805073df1875f65882ad1c4068df2e54fb69bae6b7802fc232ec8e58943a69f2c5354fee2018b00be4b423f7
|
7
|
+
data.tar.gz: 555a3f6071ac31f6bf0d38f37f11b692b97a02a170d47f3bd71313d3e116c72628b52a8e50f8fe82742effa4e1297d876d6ea4d46a132649807ec93571e0b3ad
|
data/exe/claiss
CHANGED
data/lib/claiss.rb
CHANGED
@@ -21,14 +21,17 @@ module Claiss
|
|
21
21
|
class Refactor < Dry::CLI::Command
|
22
22
|
desc "Refactors terms and files on directories"
|
23
23
|
argument :path, type: :string, required: true, desc: "Relative path directory"
|
24
|
-
argument :json_file, type: :string,
|
25
|
-
|
24
|
+
argument :json_file, type: :string, desc: "Provide a Ruby hash file"
|
25
|
+
|
26
|
+
def call(path:, json_file: nil, **)
|
26
27
|
dict = {}
|
27
28
|
search = ""
|
28
29
|
replace = ""
|
29
30
|
input = "y"
|
30
|
-
|
31
|
-
|
31
|
+
origin_path = File.expand_path(File.dirname(path))
|
32
|
+
destination_path = File.expand_path(File.dirname(".")) + "/refactored-#{Time.now.to_i.to_s}"
|
33
|
+
|
34
|
+
if !json_file.nil?
|
32
35
|
jfile = File.read(json_file)
|
33
36
|
dict = JSON.parse(jfile)
|
34
37
|
else
|
@@ -44,9 +47,10 @@ module Claiss
|
|
44
47
|
end
|
45
48
|
end
|
46
49
|
puts dict.inspect
|
47
|
-
|
48
|
-
Dir.glob(
|
50
|
+
|
51
|
+
Dir.glob(origin_path + "/**" + "/*").reject{ |f| File.directory?(f)}.each do |file|
|
49
52
|
destination = file.to_s
|
53
|
+
puts destination
|
50
54
|
text = File.read(file) if !File.directory?(file)
|
51
55
|
|
52
56
|
dict.map do |p, i|
|
@@ -56,108 +60,24 @@ module Claiss
|
|
56
60
|
end
|
57
61
|
end
|
58
62
|
|
59
|
-
puts "Destination file #{destination}"
|
60
63
|
FileUtils.mkdir_p(File.dirname(destination)) unless File.exist?(destination)
|
61
64
|
File.open(destination, "wb") do |f|
|
62
65
|
f.puts text
|
63
66
|
end
|
64
67
|
end
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
class Echo < Dry::CLI::Command
|
77
|
-
desc "Print input"
|
78
|
-
|
79
|
-
argument :input, desc: "Input to print"
|
80
|
-
|
81
|
-
example [
|
82
|
-
" # Prints 'wuh?'",
|
83
|
-
"hello, folks # Prints 'hello, folks'"
|
84
|
-
]
|
85
|
-
|
86
|
-
def call(input: nil, **)
|
87
|
-
if input.nil?
|
88
|
-
puts "wuh?"
|
89
|
-
else
|
90
|
-
puts input
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
class Start < Dry::CLI::Command
|
96
|
-
desc "Start Foo machinery"
|
97
|
-
|
98
|
-
argument :root, required: true, desc: "Root directory"
|
99
|
-
|
100
|
-
example [
|
101
|
-
"path/to/root # Start Foo at root directory"
|
102
|
-
]
|
103
|
-
|
104
|
-
def call(root:, **)
|
105
|
-
puts "started - root: #{root}"
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
class Stop < Dry::CLI::Command
|
110
|
-
desc "Stop Foo machinery"
|
111
|
-
|
112
|
-
option :graceful, type: :boolean, default: true, desc: "Graceful stop"
|
113
|
-
|
114
|
-
def call(**options)
|
115
|
-
puts "stopped - graceful: #{options.fetch(:graceful)}"
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
class Exec < Dry::CLI::Command
|
120
|
-
desc "Execute a task"
|
121
|
-
|
122
|
-
argument :task, type: :string, required: true, desc: "Task to be executed"
|
123
|
-
argument :dirs, type: :array, required: false, desc: "Optional directories"
|
124
|
-
|
125
|
-
def call(task:, dirs: [], **)
|
126
|
-
puts "exec - task: #{task}, dirs: #{dirs.inspect}"
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
module Generate
|
131
|
-
class Configuration < Dry::CLI::Command
|
132
|
-
desc "Generate configuration"
|
133
|
-
|
134
|
-
option :apps, type: :array, default: [], desc: "Generate configuration for specific apps"
|
135
|
-
|
136
|
-
def call(apps:, **)
|
137
|
-
puts "generated configuration for apps: #{apps.inspect}"
|
68
|
+
if File.directory?(destination_path)
|
69
|
+
puts "Do you want Move and delete to the original folder? (y/n): "
|
70
|
+
del = STDIN.gets.chomp
|
71
|
+
if del.downcase == "y"
|
72
|
+
FileUtils.rm_r(path)
|
73
|
+
FileUtils.mv destination_path, origin_path
|
74
|
+
puts "Moved from #{destination_path} to #{origin_path}"
|
75
|
+
end
|
138
76
|
end
|
139
|
-
end
|
140
|
-
|
141
|
-
class Test < Dry::CLI::Command
|
142
|
-
desc "Generate tests"
|
143
77
|
|
144
|
-
option :framework, default: "minitest", values: %w[minitest rspec]
|
145
|
-
|
146
|
-
def call(framework:, **)
|
147
|
-
puts "generated tests - framework: #{framework}"
|
148
|
-
end
|
149
78
|
end
|
150
79
|
end
|
151
80
|
|
152
81
|
register "version", Version, aliases: ["v", "-v", "--version"]
|
153
|
-
#register "echo", Echo
|
154
|
-
#register "start", Start
|
155
|
-
#register "stop", Stop
|
156
|
-
#register "exec", Exec
|
157
82
|
register "refactor",Refactor
|
158
|
-
|
159
|
-
register "generate", aliases: ["g"] do |prefix|
|
160
|
-
prefix.register "config", Generate::Configuration
|
161
|
-
prefix.register "test", Generate::Test
|
162
|
-
end
|
163
|
-
end
|
83
|
+
end
|
data/lib/tasks/claiss.rake
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Júlio Papel
|
@@ -81,7 +81,8 @@ files:
|
|
81
81
|
homepage: http://rubygems.org/gems/claiss
|
82
82
|
licenses:
|
83
83
|
- MIT
|
84
|
-
metadata:
|
84
|
+
metadata:
|
85
|
+
documentation_uri: https://github.com/JulioPapel/claiss/blob/main/readme.md
|
85
86
|
post_install_message:
|
86
87
|
rdoc_options: []
|
87
88
|
require_paths:
|
@@ -90,7 +91,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
90
91
|
requirements:
|
91
92
|
- - ">="
|
92
93
|
- !ruby/object:Gem::Version
|
93
|
-
version:
|
94
|
+
version: 2.7.0
|
94
95
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
96
|
requirements:
|
96
97
|
- - ">="
|