claiss 1.0.9 → 1.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/claiss.rb +73 -75
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c854bbec01b168ea59872dd5814ff9015ee581cf3792460159877596bab0fb2d
4
- data.tar.gz: ec6ffc175143a6128ca11448362b68870d25ef4a444e2a09d927a4f69eae419f
3
+ metadata.gz: 5ef3d4170f9601194f42c8a03c6089aad440bda98a91ebce1b3a8d84a3ae21bd
4
+ data.tar.gz: 5386b3b64754fb15f7db09e85c0f6bfd53aa46ad9299ef905b7ad61ca7265d8c
5
5
  SHA512:
6
- metadata.gz: b407b087d27e05c0b18a8b60e1253d700135fa2bd2348989646facf54f03b0b6c5231f9b2609bc9617a9cc5c86c416596e7ba38c4b2b0831ef5fe82de29fd900
7
- data.tar.gz: 1bc3da0a43d68a2f98f93c24aa35b130715b13a85b0a64284c23a619e77106ab2539f35137c75ac57e73c665745dc65da53972e7682ef5a8ea5298cec8e4d8cf
6
+ metadata.gz: 788da6b6055fda32c443db38ce8cb4fa88057e4ca2f50560814b938adb02bec9b913fb068f1b7ae2afa09e6a8f9607cd52ca4bd91a308422e02ca728c9ce95b0
7
+ data.tar.gz: eee327c7ba60ba69ca65ed6672b7ebc886ede89a49cf1085c9bf75d9537b0364abd0401e507a8d33bfec7e8d552ec1d05511014bc71d19b87f7fa344b0697db3
data/lib/claiss.rb CHANGED
@@ -8,90 +8,88 @@ require 'json'
8
8
  module Claiss
9
9
  extend Dry::CLI::Registry
10
10
 
11
- class Version < Dry::CLI::Command
12
- desc "Print version"
11
+ class Version < Dry::CLI::Command
12
+ desc "Print version"
13
13
 
14
- def call(*)
15
- spec = Gem::Specification::load("claiss.gemspec")
16
- puts "#{spec.description}"
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, desc: "Provide a Ruby hash file"
25
-
26
- def call(path:, json_file: nil, **)
27
- dict = {}
28
- search = ""
29
- replace = ""
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)
34
-
35
-
36
- if !json_file.nil?
37
- jfile = File.read(json_file)
38
- dict = JSON.parse(jfile)
39
- else
40
- while input.downcase == "y" do
41
- puts "Term to search: "
42
- search = STDIN.gets.chomp
43
- puts "Term to replace: "
44
- replace = STDIN.gets.chomp
45
-
46
- dict[search] = replace
47
- puts "\nAdd another? Type Y \nto Start Refactoring press Enter"
48
- input = STDIN.gets.chomp!
49
- end
50
- end
51
-
52
- dict = {origin_path => destination_path}.merge(dict)
53
- dict[origin_path] = destination_path
54
- source = File.expand_path(origin_path + "/**/{*,.*}/**/*", __FILE__)
55
- Dir.glob(source).reject{ |f| File.directory?(f)}.each do |file_name|
56
- destination = file_name
57
- text = File.read(file_name) if !File.directory?(file_name)
14
+ def call(*)
15
+ spec = Gem::Specification::load("claiss.gemspec")
16
+ puts "#{spec.description}"
17
+ puts "Version: #{spec.version}"
18
+ end
19
+ end
58
20
 
59
- dict.map do |p, i|
60
- destination.gsub!(p, i)
61
- if !text.nil?
62
- text.gsub!(p, i)
63
- end
64
- end
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, desc: "Provide a Ruby hash file"
25
+
26
+ def call(path:, json_file: nil, **)
27
+ dict = {}
28
+ search = ""
29
+ replace = ""
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)
65
34
 
66
- FileUtils.mkdir_p(File.dirname(destination))
67
- File.write(destination, text) if !File.directory?(file_name)
68
- puts "File: #{destination}, OK" if !File.directory?(file_name)
69
- end
35
+ if !json_file.nil?
36
+ jfile = File.read(json_file)
37
+ dict = JSON.parse(jfile)
38
+ else
39
+ while input.downcase == "y" do
40
+ puts "Term to search: "
41
+ search = STDIN.gets.chomp
42
+ puts "Term to replace: "
43
+ replace = STDIN.gets.chomp
70
44
 
71
- puts "done! your project is in the #{temp_dir} folder"
45
+ dict[search] = replace
46
+ puts "\nAdd another? Type Y \nto Start Refactoring press Enter"
47
+ input = STDIN.gets.chomp!
72
48
  end
73
49
  end
74
50
 
75
- class FixRubyPermissions < Dry::CLI::Command
76
- argument :path, required: true, desc: "The path of your ruby project"
77
-
78
- def call(path: nil, **)
79
- if path.nil?
80
- path = File.basename(Dir.getwd)
81
- end
82
-
83
- # Run shell scripts to set permissions.
84
- directories = `chmod 755 $(find #{path} -type d)`
85
- files = `chmod 644 $(find #{path} -type f)`
86
- bundle = `chmod 755 #{path+'/bin/bundle'}`
87
- rails = `chmod 755 #{path+'/bin/rails'}`
88
- rake = `chmod 755 #{path+'/bin/rake'}`
89
- spring = `chmod 755 #{path+'/bin/spring'}`
51
+ dict = {origin_path => destination_path}.merge(dict)
52
+ dict[origin_path] = destination_path
53
+ source = File.join(origin_path, "**", "{*,.*}")
54
+ Dir.glob(source, File::FNM_DOTMATCH).each do |file_name|
55
+ next if File.directory?(file_name)
56
+
57
+ destination = file_name
58
+ text = File.read(file_name)
59
+
60
+ dict.each do |p, i|
61
+ destination.gsub!(p, i)
62
+ text.gsub!(p, i)
90
63
  end
64
+
65
+ FileUtils.mkdir_p(File.dirname(destination))
66
+ File.write(destination, text)
67
+ puts "File: #{destination}, OK"
91
68
  end
92
69
 
70
+ puts "done! your project is in the #{temp_dir} folder"
71
+ end
72
+ end
93
73
 
94
- register "version", Version, aliases: ["v", "-v", "--version"]
95
- register "refactor",Refactor
96
- register "fix_ruby_permissions",FixRubyPermissions
74
+ class FixRubyPermissions < Dry::CLI::Command
75
+ argument :path, required: true, desc: "The path of your ruby project"
76
+
77
+ def call(path: nil, **)
78
+ if path.nil?
79
+ path = File.basename(Dir.getwd)
80
+ end
81
+
82
+ # Run shell scripts to set permissions.
83
+ directories = `chmod 755 $(find #{path} -type d)`
84
+ files = `chmod 644 $(find #{path} -type f)`
85
+ bundle = `chmod 755 #{path+'/bin/bundle'}`
86
+ rails = `chmod 755 #{path+'/bin/rails'}`
87
+ rake = `chmod 755 #{path+'/bin/rake'}`
88
+ spring = `chmod 755 #{path+'/bin/spring'}`
89
+ end
97
90
  end
91
+
92
+ register "version", Version, aliases: ["v", "-v", "--version"]
93
+ register "refactor", Refactor
94
+ register "fix_ruby_permissions", FixRubyPermissions
95
+ 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.9
4
+ version: 1.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Júlio Papel