claiss 1.0.5 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/claiss.rb +35 -21
  3. data/lib/tasks/claiss.rake +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a80a9f089824ea94bc360a4fa8bc0e70f0a6a8a5b307782654cfd7308c36a0f2
4
- data.tar.gz: 610227313b276fb02a7f0a29d37667d3aecc0e4ff1a7952e91e18c2eb234766e
3
+ metadata.gz: 3a27c84097fb8adb9ce3e2351651821770f6973b000557e8566b79c24428b66c
4
+ data.tar.gz: 74a986701d5b7031cd6f0fdfc9a93d18df2801bd6f1474138a30200fad9c7c73
5
5
  SHA512:
6
- metadata.gz: 0ac085f33543b4e03f6904775108bc82aab0fb0a805073df1875f65882ad1c4068df2e54fb69bae6b7802fc232ec8e58943a69f2c5354fee2018b00be4b423f7
7
- data.tar.gz: 555a3f6071ac31f6bf0d38f37f11b692b97a02a170d47f3bd71313d3e116c72628b52a8e50f8fe82742effa4e1297d876d6ea4d46a132649807ec93571e0b3ad
6
+ metadata.gz: 05af17263512ea15e08d4742d9e2ac8d0db3f2f1d2796f805372ce3afb76d3419b79d37c6566a857da75723e606fa402324baa89c8985df528eb0d8236d1ce8d
7
+ data.tar.gz: aa9387b2cf6f4bf87cdcb9424564c31a34af908fa5664fee85c4211f29d26dad09af20068fa08e50f957152adc57a2e4e07ed6309bb174675ce01478513bc41b
data/lib/claiss.rb CHANGED
@@ -13,7 +13,7 @@ module Claiss
13
13
 
14
14
  def call(*)
15
15
  spec = Gem::Specification::load("claiss.gemspec")
16
- puts "#{spec.summary}"
16
+ puts "#{spec.description}"
17
17
  puts "Version: #{spec.version}"
18
18
  end
19
19
  end
@@ -28,8 +28,10 @@ module Claiss
28
28
  search = ""
29
29
  replace = ""
30
30
  input = "y"
31
- origin_path = File.expand_path(File.dirname(path))
32
- destination_path = File.expand_path(File.dirname(".")) + "/refactored-#{Time.now.to_i.to_s}"
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
+
33
35
 
34
36
  if !json_file.nil?
35
37
  jfile = File.read(json_file)
@@ -46,12 +48,13 @@ module Claiss
46
48
  input = STDIN.gets.chomp!
47
49
  end
48
50
  end
49
- puts dict.inspect
50
51
 
51
- Dir.glob(origin_path + "/**" + "/*").reject{ |f| File.directory?(f)}.each do |file|
52
- destination = file.to_s
53
- puts destination
54
- text = File.read(file) if !File.directory?(file)
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)
55
58
 
56
59
  dict.map do |p, i|
57
60
  destination.gsub!(p, i)
@@ -60,24 +63,35 @@ module Claiss
60
63
  end
61
64
  end
62
65
 
63
- FileUtils.mkdir_p(File.dirname(destination)) unless File.exist?(destination)
64
- File.open(destination, "wb") do |f|
65
- f.puts text
66
- end
67
- end
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
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)
76
69
  end
77
70
 
71
+ puts "done! your project is in the #{temp_dir} folder"
78
72
  end
79
73
  end
80
74
 
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'}`
90
+ end
91
+ end
92
+
93
+
81
94
  register "version", Version, aliases: ["v", "-v", "--version"]
82
95
  register "refactor",Refactor
96
+ register "fix_ruby_permissions",FixRubyPermissions
83
97
  end
@@ -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/jumpstart/lib/claiss/"
5
+ path = "/home/rails/laiss/lib/claiss/"
6
6
 
7
7
  task :default => :build
8
8
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: claiss
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Júlio Papel
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-07-02 00:00:00.000000000 Z
11
+ date: 2023-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-cli