claiss 1.0.4 → 1.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.
Potentially problematic release.
This version of claiss might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/exe/claiss +1 -1
- data/lib/claiss.rb +16 -106
- data/lib/tasks/claiss.rake +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7b117b78d9275e924380505e1ca1ddb0818490cd1532dd5a31de08b199e1b84
|
4
|
+
data.tar.gz: 39ba11f151fe5ecd59cc291011ef8611e61f4a83cf4d95427bd3589643be7353
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4265f73dadbbae241ca6d6dab87b121f5fc931c9f2044c8a159d52031c1b629eec97c4439dbd7879efbc48ad5bb6c36075d40cd8c7c3a5d12a87117d6b580efa
|
7
|
+
data.tar.gz: b217629b6cc0da245dfe5e1e3b33123a22f52d7037b6c8900688d32291b730a75ef76152be7c059fce5bd2b9d7fb5c932f11fa098bab3355a22a28acb3d92c26
|
data/exe/claiss
CHANGED
data/lib/claiss.rb
CHANGED
@@ -21,14 +21,18 @@ 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"
|
31
|
+
temp_dir = "/refactored-#{Time.now.to_i.to_s}"
|
32
|
+
origin_path = File.expand_path(path)
|
33
|
+
destination_path = File.expand_path("."+ temp_dir)
|
30
34
|
|
31
|
-
if !json_file.nil?
|
35
|
+
if !json_file.nil?
|
32
36
|
jfile = File.read(json_file)
|
33
37
|
dict = JSON.parse(jfile)
|
34
38
|
else
|
@@ -43,11 +47,10 @@ module Claiss
|
|
43
47
|
input = STDIN.gets.chomp!
|
44
48
|
end
|
45
49
|
end
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
text = File.read(file) if !File.directory?(file)
|
50
|
+
source = File.expand_path(origin_path + "/**/*", __FILE__)
|
51
|
+
Dir.glob(source).reject{ |f| File.directory?(f)}.each do |file_name|
|
52
|
+
destination = file_name
|
53
|
+
text = File.read(file_name) if !File.directory?(file_name)
|
51
54
|
|
52
55
|
dict.map do |p, i|
|
53
56
|
destination.gsub!(p, i)
|
@@ -56,108 +59,15 @@ module Claiss
|
|
56
59
|
end
|
57
60
|
end
|
58
61
|
|
59
|
-
|
60
|
-
|
61
|
-
File
|
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}"
|
62
|
+
FileUtils.mkdir_p(File.dirname(destination))
|
63
|
+
File.write(destination, text) if !File.directory?(file_name)
|
64
|
+
puts "File: #{destination}, OK" if !File.directory?(file_name)
|
71
65
|
end
|
66
|
+
puts "done!"
|
72
67
|
|
73
68
|
end
|
74
69
|
end
|
75
70
|
|
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}"
|
138
|
-
# end
|
139
|
-
# end
|
140
|
-
|
141
|
-
# class Test < Dry::CLI::Command
|
142
|
-
# desc "Generate tests"
|
143
|
-
|
144
|
-
# option :framework, default: "minitest", values: %w[minitest rspec]
|
145
|
-
|
146
|
-
# def call(framework:, **)
|
147
|
-
# puts "generated tests - framework: #{framework}"
|
148
|
-
# end
|
149
|
-
# end
|
150
|
-
# end
|
151
|
-
|
152
71
|
register "version", Version, aliases: ["v", "-v", "--version"]
|
153
|
-
#register "echo", Echo
|
154
|
-
#register "start", Start
|
155
|
-
#register "stop", Stop
|
156
|
-
#register "exec", Exec
|
157
72
|
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
|
73
|
+
end
|
data/lib/tasks/claiss.rake
CHANGED
@@ -2,7 +2,7 @@ GEM_NAME = "claiss"
|
|
2
2
|
GEM_VERSION = "1.0.0"
|
3
3
|
|
4
4
|
namespace :claiss do
|
5
|
-
path = "/home/rails/
|
5
|
+
path = "/home/rails/laiss/lib/claiss/"
|
6
6
|
|
7
7
|
task :default => :build
|
8
8
|
|
@@ -22,4 +22,4 @@ namespace :claiss do
|
|
22
22
|
system "rm " + path + "*.gem"
|
23
23
|
end
|
24
24
|
|
25
|
-
end
|
25
|
+
end
|