yogi 0.1.3 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/yogi/version.rb +1 -1
- data/lib/yogi.rb +31 -29
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2d720779229dbae85f32fca087dfabd1a200821
|
4
|
+
data.tar.gz: fc44a7d7f6f7568fdcebedcbb1a1d3ab29ec0691
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5994bd1ad6b4f41e4fcf755b661e6588df4ac3e246a653f8559b3839e573f938124596454436f7f9b5c93a09127c613bc5d8a4a9298af0d9025532b6d5b49668
|
7
|
+
data.tar.gz: be47206888b8f9dc9bb09c3860935c82bd3554921a3361d25cc47d00331cd9a7846756b6f89cec3ff6bdf16cc380ef5e3b3b380bc6ac305b7768e48248eefca5
|
data/lib/yogi/version.rb
CHANGED
data/lib/yogi.rb
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
require "yogi/version"
|
2
2
|
require 'fileutils'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
$file_names = []
|
5
|
+
$file_names = Dir.glob("app/**/*.rb") + Dir.glob("app/**/*.js") + Dir.glob("app/**/*.css") + Dir.glob("app/**/*.scss") + Dir.glob("app/**/*.erb") + Dir.glob("app/**/*.html")
|
6
|
+
$file_sample = $file_names.sample(5)
|
7
7
|
|
8
8
|
module Yogi
|
9
9
|
class ErrorInside
|
10
10
|
def backup
|
11
11
|
# creating backup directory
|
12
|
-
FileUtils.mkdir_p 'backupFiles' unless File.exists?('backupFiles')
|
13
|
-
puts "created folder backupFiles"
|
12
|
+
FileUtils.mkdir_p '.backupFiles' unless File.exists?('.backupFiles')
|
13
|
+
# puts "created folder backupFiles"
|
14
14
|
|
15
15
|
#copy backup to backup folder
|
16
|
-
FileUtils.cp_r "./app", "backupFiles/"
|
17
|
-
puts "copied files to backupFiles #{
|
16
|
+
FileUtils.cp_r "./app", ".backupFiles/"
|
17
|
+
# puts "copied files to backupFiles #{$file_names}"
|
18
18
|
|
19
19
|
# #rename files in backupFiles folder
|
20
20
|
# backup_file_path = "./backupFiles/"
|
@@ -26,35 +26,37 @@ module Yogi
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def yogify
|
29
|
-
|
29
|
+
$file_sample.each do |file_name|
|
30
30
|
text = File.read(file_name)
|
31
|
-
puts "editing #{
|
31
|
+
puts "editing #{$file_sample}"
|
32
32
|
|
33
33
|
#counting ocurences of the original chars before changes
|
34
|
-
counted_comma = text.count(",") #counts ocurences in the file
|
35
|
-
counted_semicolon = text.count(";") #counts ocurences in the file
|
36
|
-
counted_1 = text.count("1") #counts ocurences in the file
|
37
|
-
counted_3 = text.count("3") #counts ocurences in the file
|
38
|
-
counted_5 = text.count("5") #counts ocurences in the file
|
39
|
-
counted_px = text.count("px") #counts ocurences in the file
|
40
|
-
puts "commas : #{counted_comma}"
|
41
|
-
puts "semikolons : #{counted_semicolon}"
|
42
|
-
puts "1 : #{counted_1}"
|
43
|
-
puts "3 : #{counted_3}"
|
44
|
-
puts "5 : #{counted_5}"
|
45
|
-
puts "px : #{counted_px}"
|
34
|
+
# counted_comma = text.count(",") #counts ocurences in the file
|
35
|
+
# counted_semicolon = text.count(";") #counts ocurences in the file
|
36
|
+
# counted_1 = text.count("1") #counts ocurences in the file
|
37
|
+
# counted_3 = text.count("3") #counts ocurences in the file
|
38
|
+
# counted_5 = text.count("5") #counts ocurences in the file
|
39
|
+
# counted_px = text.count("px") #counts ocurences in the file
|
40
|
+
# puts "commas : #{counted_comma}"
|
41
|
+
# puts "semikolons : #{counted_semicolon}"
|
42
|
+
# puts "1 : #{counted_1}"
|
43
|
+
# puts "3 : #{counted_3}"
|
44
|
+
# puts "5 : #{counted_5}"
|
45
|
+
# puts "px : #{counted_px}"
|
46
46
|
|
47
47
|
# To merely print the contents of the file, use:
|
48
48
|
new_contents1 = text.gsub(";"){rand(2).zero? ? ";" : ","}
|
49
49
|
new_contents2 = new_contents1.gsub(","){rand(2).zero? ? "," : ";"}
|
50
|
-
new_contents3 = new_contents2.gsub("
|
50
|
+
new_contents3 = new_contents2.gsub("l"){rand(2).zero? ? "l" : "1"}
|
51
51
|
new_contents4 = new_contents3.gsub("3"){rand(2).zero? ? "3" : "E"}
|
52
|
-
new_contents5 = new_contents4.gsub("
|
53
|
-
new_contents6 = new_contents5.gsub("
|
54
|
-
|
52
|
+
new_contents5 = new_contents4.gsub("s"){rand(2).zero? ? "s" : "5"}
|
53
|
+
new_contents6 = new_contents5.gsub("}"){rand(2).zero? ? "}" : "]"}
|
54
|
+
new_contents7 = new_contents6.gsub("px"){rand(2).zero? ? "px" : "xp"}
|
55
|
+
|
56
|
+
# puts new_contents6
|
55
57
|
|
56
58
|
# To write changes to the file, use:
|
57
|
-
File.open(file_name, "w") {|file| file.puts
|
59
|
+
File.open(file_name, "w") {|file| file.puts new_contents7 }
|
58
60
|
end
|
59
61
|
end
|
60
62
|
end
|
@@ -62,14 +64,14 @@ module Yogi
|
|
62
64
|
class ErrorOut
|
63
65
|
def undo
|
64
66
|
#undo changes originaly made.
|
65
|
-
Dir.foreach('backupFiles') do |item|
|
67
|
+
Dir.foreach('.backupFiles') do |item|
|
66
68
|
next if item == '.' or item == '..'
|
67
|
-
FileUtils.cp_r "backupFiles/"+ item, "./"
|
69
|
+
FileUtils.cp_r ".backupFiles/"+ item, "./"
|
68
70
|
# puts item
|
69
71
|
# FileUtils.cp_r file_names, "backupFiles/"
|
70
72
|
end
|
71
73
|
#removes folder backupFiles
|
72
|
-
|
74
|
+
FileUtils.rm_r '.backupFiles'
|
73
75
|
end
|
74
76
|
end
|
75
77
|
|