claiss 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a1aeba7f21350d881633d4d21d29cb4f85a4bba95ca0fb4f98530e8ac720681d
4
- data.tar.gz: 03dedc88fbc506e11c9b6f68e2eb6ea425b953113251bb2bde9d7b935c6d17fb
3
+ metadata.gz: a80a9f089824ea94bc360a4fa8bc0e70f0a6a8a5b307782654cfd7308c36a0f2
4
+ data.tar.gz: 610227313b276fb02a7f0a29d37667d3aecc0e4ff1a7952e91e18c2eb234766e
5
5
  SHA512:
6
- metadata.gz: 1d37082c93df94fe71ee8d55f773435212a6fbe235e31e389833fc82be22fce5f5212511d4a620a0aa117ae843d5d8865e29a20f885bbc7c07eb6e0db59692ab
7
- data.tar.gz: aa6d5d393da6782cca6126f0db9acca7d3f0634b9fcb79da33cf692deed277e2526fecbfafd43f73d04dc6b6d35067fde6bd9a07487658e26ba53c9e4ac47c71
6
+ metadata.gz: 0ac085f33543b4e03f6904775108bc82aab0fb0a805073df1875f65882ad1c4068df2e54fb69bae6b7802fc232ec8e58943a69f2c5354fee2018b00be4b423f7
7
+ data.tar.gz: 555a3f6071ac31f6bf0d38f37f11b692b97a02a170d47f3bd71313d3e116c72628b52a8e50f8fe82742effa4e1297d876d6ea4d46a132649807ec93571e0b3ad
data/exe/claiss CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  require "dry/cli"
4
4
  require 'claiss'
5
- Dry::CLI.new(Claiss).call
5
+ Dry::CLI.new(Claiss).call
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, required: false, desc: "Provide a Ruby hash file"
25
- def call(path:, json_file:, **)
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
- if !json_file.nil? || !json_file.empty?
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
- dict[path] = "refactored-#{Time.now.to_i.to_s}/"
48
- Dir.glob(path + "**/" +"*").reject{ |f| File.directory?(f)}.each do |file|
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
- 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}"
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
71
76
  end
72
77
 
73
78
  end
74
79
  end
75
80
 
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
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
@@ -22,4 +22,4 @@ namespace :claiss do
22
22
  system "rm " + path + "*.gem"
23
23
  end
24
24
 
25
- end
25
+ end
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
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Júlio Papel