claiss 1.0.5 → 1.0.6

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 +12 -22
  3. data/lib/tasks/claiss.rake +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a80a9f089824ea94bc360a4fa8bc0e70f0a6a8a5b307782654cfd7308c36a0f2
4
- data.tar.gz: 610227313b276fb02a7f0a29d37667d3aecc0e4ff1a7952e91e18c2eb234766e
3
+ metadata.gz: f7b117b78d9275e924380505e1ca1ddb0818490cd1532dd5a31de08b199e1b84
4
+ data.tar.gz: 39ba11f151fe5ecd59cc291011ef8611e61f4a83cf4d95427bd3589643be7353
5
5
  SHA512:
6
- metadata.gz: 0ac085f33543b4e03f6904775108bc82aab0fb0a805073df1875f65882ad1c4068df2e54fb69bae6b7802fc232ec8e58943a69f2c5354fee2018b00be4b423f7
7
- data.tar.gz: 555a3f6071ac31f6bf0d38f37f11b692b97a02a170d47f3bd71313d3e116c72628b52a8e50f8fe82742effa4e1297d876d6ea4d46a132649807ec93571e0b3ad
6
+ metadata.gz: 4265f73dadbbae241ca6d6dab87b121f5fc931c9f2044c8a159d52031c1b629eec97c4439dbd7879efbc48ad5bb6c36075d40cd8c7c3a5d12a87117d6b580efa
7
+ data.tar.gz: b217629b6cc0da245dfe5e1e3b33123a22f52d7037b6c8900688d32291b730a75ef76152be7c059fce5bd2b9d7fb5c932f11fa098bab3355a22a28acb3d92c26
data/lib/claiss.rb CHANGED
@@ -28,9 +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}"
33
-
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
+
34
35
  if !json_file.nil?
35
36
  jfile = File.read(json_file)
36
37
  dict = JSON.parse(jfile)
@@ -46,12 +47,10 @@ module Claiss
46
47
  input = STDIN.gets.chomp!
47
48
  end
48
49
  end
49
- puts dict.inspect
50
-
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)
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)
55
54
 
56
55
  dict.map do |p, i|
57
56
  destination.gsub!(p, i)
@@ -60,20 +59,11 @@ module Claiss
60
59
  end
61
60
  end
62
61
 
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
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)
76
65
  end
66
+ puts "done!"
77
67
 
78
68
  end
79
69
  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,7 +1,7 @@
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.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Júlio Papel