yogi 0.1.5 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f2d720779229dbae85f32fca087dfabd1a200821
4
- data.tar.gz: fc44a7d7f6f7568fdcebedcbb1a1d3ab29ec0691
3
+ metadata.gz: 8a7b094561f0c52ab43cb54de917b4a75e4a2ec7
4
+ data.tar.gz: 93a6b39fa89b9581cc90a989f94bc3d6e660a105
5
5
  SHA512:
6
- metadata.gz: 5994bd1ad6b4f41e4fcf755b661e6588df4ac3e246a653f8559b3839e573f938124596454436f7f9b5c93a09127c613bc5d8a4a9298af0d9025532b6d5b49668
7
- data.tar.gz: be47206888b8f9dc9bb09c3860935c82bd3554921a3361d25cc47d00331cd9a7846756b6f89cec3ff6bdf16cc380ef5e3b3b380bc6ac305b7768e48248eefca5
6
+ metadata.gz: e3535a7f1d4124cd844fd7c657acb354dc25428452fa2a49bb0354a2cee109cd121c4d41af76adb019122e59daccac5040fb2d06126b8d8b0800aef53df40a2b
7
+ data.tar.gz: 1c591ab5909aacb6ebbac052717b3794a5ab729f13a812b79de1fa3ab5e073e8f9e35562d34e6c400ec3b06f1cd5fbb8a7052994b568a88c97ce7fdede942b50
data/bin/checkme ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'Yogi'
4
+
5
+ errorCheck = Yogi::CheckErrors.new
6
+ errorCheck.checker
data/lib/yogi/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Yogi
2
- VERSION = "0.1.5"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/yogi.rb CHANGED
@@ -6,6 +6,12 @@ $file_names = Dir.glob("app/**/*.rb") + Dir.glob("app/**/*.js") + Dir.glob("app/
6
6
  $file_sample = $file_names.sample(5)
7
7
 
8
8
  module Yogi
9
+
10
+
11
+ def count_em(text, substring)
12
+ text.scan(/(?=#{substring})/).count
13
+ end
14
+
9
15
  class ErrorInside
10
16
  def backup
11
17
  # creating backup directory
@@ -27,22 +33,28 @@ module Yogi
27
33
 
28
34
  def yogify
29
35
  $file_sample.each do |file_name|
30
- text = File.read(file_name)
31
- puts "editing #{$file_sample}"
32
-
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}"
36
+ text = File.open(file_name, "r"){ |file| file.read }#File.read(file_name)
37
+ # puts "editing #{$file_sample}"
38
+
39
+ $pre_counted_comma = count_em(text,",")
40
+ $pre_counted_semicolon = count_em(text,";")
41
+ $pre_counted_l = count_em(text,"l")
42
+ $pre_counted_3 = count_em(text,"3")
43
+ $pre_counted_s = count_em(text,"s")
44
+ $pre_counted_bracket = count_em(text,"}")
45
+ $pre_counted_px = count_em(text,"px")
46
+
47
+ puts "commas : #{$pre_counted_comma}"
48
+ puts "semikolons : #{$pre_counted_semicolon}"
49
+ puts "l : #{$pre_counted_l}"
50
+ puts "3 : #{$pre_counted_3}"
51
+ puts "s : #{$pre_counted_s}"
52
+ puts "} : #{$pre_counted_bracket}"
53
+ puts "px : #{$pre_counted_px}"
54
+
55
+ #counts total symbols to be effected
56
+ pre_total = pre_counted_comma + pre_counted_semicolon + pre_counted_l + pre_counted_3 + pre_counted_s + pre_counted_bracket + pre_counted_px
57
+ # puts pre_total
46
58
 
47
59
  # To merely print the contents of the file, use:
48
60
  new_contents1 = text.gsub(";"){rand(2).zero? ? ";" : ","}
@@ -57,10 +69,133 @@ module Yogi
57
69
 
58
70
  # To write changes to the file, use:
59
71
  File.open(file_name, "w") {|file| file.puts new_contents7 }
72
+
73
+ text = File.open(file_name, "r"){ |file| file.read }#File.read(file_name)
74
+ puts text
75
+ #counts ocurences in the file after initial change
76
+ post_counted_comma = count_em(text,",")
77
+ post_counted_semicolon = count_em(text,";")
78
+ post_counted_l = count_em(text,"l")
79
+ post_counted_3 = count_em(text,"3")
80
+ post_counted_s = count_em(text,"s")
81
+ post_counted_bracket = count_em(text,"}")
82
+ post_counted_px = count_em(text,"px")
83
+
84
+ puts "commas : #{post_counted_comma}"
85
+ puts "semikolons : #{post_counted_semicolon}"
86
+ puts "l : #{post_counted_l}"
87
+ puts "3 : #{post_counted_3}"
88
+ puts "s : #{post_counted_s}"
89
+ puts "} : #{post_counted_bracket}"
90
+ puts "px : #{post_counted_px}"
91
+ #counts total symbols to be effected
92
+ post_total = post_counted_comma + post_counted_semicolon + post_counted_l + post_counted_3 + post_counted_s + post_counted_bracket + post_counted_px
93
+ # puts post_total
94
+
95
+ $pre_diff_comma = $pre_counted_comma - post_counted_comma
96
+ $pre_diff_semicolon = $pre_counted_semicolon - post_counted_semicolon
97
+ $pre_diff_l = $pre_counted_l - post_counted_l
98
+ $pre_diff_3 = $pre_counted_3 - post_counted_3
99
+ $pre_diff_s = $pre_counted_s - post_counted_s
100
+ $pre_diff_bracket = $pre_counted_bracket - post_counted_bracket
101
+ $pre_diff_px = $pre_counted_px - post_counted_px
102
+
103
+ puts "commas : #{$pre_diff_comma}"
104
+ puts "semikolons : #{$pre_diff_semicolon}"
105
+ puts "l : #{$pre_diff_l}"
106
+ puts "3 : #{$pre_diff_3}"
107
+ puts "s : #{$pre_diff_s}"
108
+ puts "} : #{$pre_diff_bracket}"
109
+ puts "px : #{$pre_diff_px}"
110
+
60
111
  end
61
112
  end
62
113
  end
63
114
 
115
+ class CheckErrors
116
+ def checker
117
+ $file_sample.each do |file_name|
118
+ text = File.open(file_name, "r"){ |file| file.read }#File.read(file_name)
119
+ post_counted_comma = count_em(text,",")
120
+ post_counted_semicolon = count_em(text,";")
121
+ post_counted_l = count_em(text,"l")
122
+ post_counted_3 = count_em(text,"3")
123
+ post_counted_s = count_em(text,"s")
124
+ post_counted_bracket = count_em(text,"}")
125
+ post_counted_px = count_em(text,"px")
126
+
127
+ puts "commas : #{post_counted_comma}"
128
+ puts "semikolons : #{post_counted_semicolon}"
129
+ puts "l : #{post_counted_l}"
130
+ puts "3 : #{post_counted_3}"
131
+ puts "s : #{post_counted_s}"
132
+ puts "} : #{post_counted_bracket}"
133
+ puts "px : #{post_counted_px}"
134
+
135
+ post_diff_comma = $pre_counted_comma - post_counted_comma
136
+ post_diff_semicolon = $pre_counted_semicolon - post_counted_semicolon
137
+ post_diff_l = $pre_counted_l - post_counted_l
138
+ post_diff_3 = $pre_counted_3 - post_counted_3
139
+ post_diff_s = $pre_counted_s - post_counted_s
140
+ post_diff_bracket = $pre_counted_bracket - post_counted_bracket
141
+ post_diff_px = $pre_counted_px - post_counted_px
142
+
143
+ if pre_diff_comma == 0
144
+ comma_fix = 100
145
+ else
146
+ comma_fix = ((pre_diff_comma - post_diff_comma)/pre_diff_comma)*100
147
+ end
148
+ puts " #{comma_fix}% of comma errors fixed"
149
+
150
+ if semikolon_fix == 0
151
+ semikolon_fix = 100
152
+ else
153
+ semikolon_fix = ((pre_diff_semikolon - post_diff_semikolon)/pre_diff_semikolon)*100
154
+ end
155
+ puts " #{semikolon_fix}% of comma errors fixed"
156
+
157
+ if l_fix == 0
158
+ l_fix = 100
159
+ else
160
+ l_fix = ((pre_diff_l - post_diff_l)/pre_diff_l)*100
161
+ end
162
+ puts " #{l_fix}% of comma errors fixed"
163
+
164
+ if three_fix == 0
165
+ three_fix = 100
166
+ else
167
+ three_fix = ((pre_diff_3 - post_diff_3)/pre_diff_3)*100
168
+ end
169
+ puts " #{three_fix}% of comma errors fixed"
170
+
171
+ if s_fix == 0
172
+ s_fix = 100
173
+ else
174
+ s_fix = ((pre_diff_s - post_diff_s)/pre_diff_s)*100
175
+ end
176
+ puts " #{s_fix}% of comma errors fixed"
177
+
178
+ if bracket_fix == 0
179
+ bracket_fix = 100
180
+ else
181
+ bracket_fix = ((pre_diff_bracket - post_diff_bracket)/pre_diff_bracket)*100
182
+ end
183
+ puts " #{bracket_fix}% of comma errors fixed"
184
+
185
+ if px_fix == 0
186
+ px_fix = 100
187
+ else
188
+ px_fix = ((pre_diff_px - post_diff_px)/pre_diff_px)*100
189
+ end
190
+ puts " #{px_fix}% of comma errors fixed"
191
+
192
+ end
193
+ end
194
+
195
+
196
+
197
+
198
+
64
199
  class ErrorOut
65
200
  def undo
66
201
  #undo changes originaly made.
data/yogi.gemspec CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
26
  # spec.bindir = "exe"
27
- spec.executables = ["activate" , "fixme"]
27
+ spec.executables = ["activate" , "fixme", "checkme"]
28
28
  #spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
29
  spec.require_paths = ["lib"]
30
30
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yogi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Langnickel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-20 00:00:00.000000000 Z
11
+ date: 2016-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -44,6 +44,7 @@ email:
44
44
  executables:
45
45
  - activate
46
46
  - fixme
47
+ - checkme
47
48
  extensions: []
48
49
  extra_rdoc_files: []
49
50
  files:
@@ -54,6 +55,7 @@ files:
54
55
  - README.md
55
56
  - Rakefile
56
57
  - bin/activate
58
+ - bin/checkme
57
59
  - bin/console
58
60
  - bin/fixme
59
61
  - bin/setup