claiss 1.0.8 → 1.0.10

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.

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: c0f324755ac02efc230d061a533eb5ab80123ec65fa8c614290212da27ece964
4
- data.tar.gz: 0be3363e9516f0248bf62c418b3a9198b23b20471ee6581669626b90c7cbf48b
3
+ metadata.gz: 5ef3d4170f9601194f42c8a03c6089aad440bda98a91ebce1b3a8d84a3ae21bd
4
+ data.tar.gz: 5386b3b64754fb15f7db09e85c0f6bfd53aa46ad9299ef905b7ad61ca7265d8c
5
5
  SHA512:
6
- metadata.gz: c9f18ed1169ddfb66735e52f8ddb357a7db57906089c66d5e5943b0a95bad3b426ff2322344e5046d202550cf493f5786c8e1fb8ce3a19c068c28b05efe7082e
7
- data.tar.gz: f9c7d2039c6e6f4ba365a192d2a87de0a58b87c007af637b0860f0af830e6c1bb6ed8bdce6f24d446e048fd471a74e02553a28ec5027795ebd94f2e3abdc936c
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.8
4
+ version: 1.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Júlio Papel