yogi 0.3.4 → 0.3.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7b54b9503a88e457bd615cee79d29487ea035117
4
- data.tar.gz: 799e0e7b97888cd1e522a08cd7d9025a4fabfec9
3
+ metadata.gz: c46f01866a79048705361e6ee8c075e898b50603
4
+ data.tar.gz: 949dc9c83e92ffd5d0c866f3a327d38e71838bda
5
5
  SHA512:
6
- metadata.gz: fe2e7075b6e008ca9f2aa16781735fe13cfecd510498bcc8a86c073b408ab24a03c4e22d24604d17e0693eb3e0156ed10f5c62ab0ac5c581fa3655d3aad1fbc4
7
- data.tar.gz: c70a57f9c29068e17239fba4328702a8c542bc94d438611e1ac59f70ffa2658c4db60a609fd3442e3aecd45c9cfe8cd9c0920e33117e5b2be225c6e6f111e788
6
+ metadata.gz: be9caf6d274c676c1b5308d723b0dd111249a4d2a90787cbd0b9ba443c4ea5e9bf1907e09415fb93ba4ef9464ea7a2dfb8b0ea542796ff6332f632973c946867
7
+ data.tar.gz: 9f0a343be667691a918608196b706fd46d52285d54f387b9399eafdb87e41e02803bf98c6c83f31b508e94ef6a2f90e05d439217278f4af9d1ba77fdf5f7211c
data/.DS_Store ADDED
Binary file
data/README.md CHANGED
@@ -8,14 +8,14 @@ So this is good enough to start practice your debugging skills.
8
8
  You can check you progress or..
9
9
  when you get stuck, you can fix your project anytime with just one word.
10
10
 
11
- latest stable version 0.3.4
11
+ latest stable version 0.3.5
12
12
 
13
13
  ## Installation
14
14
 
15
15
  Add this line to your application's Gemfile:
16
16
 
17
17
  ```ruby
18
- gem 'yogi', '~> 0.3.4'
18
+ gem 'yogi', '~> 0.3.5'
19
19
  ```
20
20
 
21
21
  And then execute:
data/bin/activate CHANGED
@@ -1,10 +1,23 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'Yogi'
4
+ require 'os'
4
5
 
5
6
 
6
- setup = Yogi::Setup.new
7
- setup.setup
8
- errorInside = Yogi::ErrorInside.new
9
- errorInside.backup
10
- errorInside.yogify
7
+ if File.exists?(".git/.ignoremefile.txt")
8
+ if OS.mac?
9
+ # # cmd = ("say 'Debugging mode activated'")
10
+ # # exec cmd
11
+ cmd = ("say 'You fool can not activate me twice'")
12
+ system cmd
13
+ end
14
+ puts 'You fool can not activate me twice'
15
+ else
16
+ # puts "You cant fool me..."
17
+ setup = Yogi::Setup.new
18
+ setup.setup
19
+ errorInside = Yogi::ErrorInside.new
20
+ errorInside.backup
21
+ errorInside.yogify
22
+
23
+ end
data/bin/checkme CHANGED
@@ -3,8 +3,12 @@
3
3
  require 'Yogi'
4
4
 
5
5
  if File.exists?(".git/.ignoremefile.txt")
6
- errorCheck = Yogi::CheckErrors.new
7
- errorCheck.checker
6
+ errorCheck = Yogi::CheckErrors.new
7
+ errorCheck.checker
8
8
  else
9
+ if OS.mac?
10
+ cmd = ("say 'You fool should activate me first'")
11
+ system cmd
12
+ end
9
13
  puts 'You should first activate the gem before you can check your progress'
10
14
  end
data/bin/fixme CHANGED
@@ -3,9 +3,13 @@
3
3
  require 'Yogi'
4
4
  # puts 'hello world'
5
5
 
6
- if File.exists?(".git/.ignoremefile.txt")
6
+ if File.exists?(".git/.backupFiles")
7
7
  errorOut = Yogi::ErrorOut.new
8
8
  errorOut.undo
9
9
  else
10
+ if OS.mac?
11
+ cmd = ("say 'You fool should activate me before you can fix me'")
12
+ system cmd
13
+ end
10
14
  puts "nothing to fix here"
11
15
  end
data/lib/.DS_Store ADDED
Binary file
Binary file
Binary file
Binary file
Binary file
data/lib/yogi/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Yogi
2
- VERSION = "0.3.4"
2
+ VERSION = "0.3.5"
3
3
  end
data/lib/yogi.rb CHANGED
@@ -2,14 +2,16 @@ require 'rubygems'
2
2
  require "yogi/version"
3
3
  require 'fileutils'
4
4
  require 'json'
5
+ require 'os'
6
+ require 'shellwords'
5
7
 
6
8
  module Yogi
7
9
 
8
10
  class Setup
9
11
  def setup
10
12
  $file_names = []
11
- $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")
12
- $sample_size = 5
13
+ $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") + Dir.glob("config/routes.rb")
14
+ $sample_size = 7
13
15
  $file_sample = $file_names.sample($sample_size)
14
16
  File.open('.git/.ignoremefile.txt', "a") {|file| file.puts $file_sample.to_json}
15
17
  end
@@ -23,6 +25,7 @@ module Yogi
23
25
  $pre_counted_bracket = 0
24
26
  $pre_counted_px = 0
25
27
  $pre_counted_sq_bracket = 0
28
+ $pre_counted_equal = 0
26
29
 
27
30
  $pre_diff_comma = 0
28
31
  $pre_diff_semicolon = 0
@@ -32,6 +35,7 @@ module Yogi
32
35
  $pre_diff_bracket = 0
33
36
  $pre_diff_px = 0
34
37
  $pre_diff_sq_bracket = 0
38
+ $pre_diff_equal = 0
35
39
 
36
40
  class ErrorInside
37
41
 
@@ -46,6 +50,7 @@ module Yogi
46
50
 
47
51
  #copy backup to backup folder
48
52
  FileUtils.cp_r "./app", ".git/.backupFiles/"
53
+ FileUtils.cp_r "./config", ".git/.backupFiles/"
49
54
  # puts "copied files to backupFiles #{$file_names}"
50
55
 
51
56
  # #rename files in backupFiles folder
@@ -75,6 +80,7 @@ module Yogi
75
80
  $pre_counted_bracket = count_em(text,"}")
76
81
  $pre_counted_px = count_em(text,"px")
77
82
  $pre_counted_sq_bracket = count_em(text,">")
83
+ $pre_counted_equal = count_em(text,"==")
78
84
 
79
85
  # puts "commas : #{$pre_counted_comma}"
80
86
  # puts "semicolons : #{$pre_counted_semicolon}"
@@ -97,11 +103,12 @@ module Yogi
97
103
  new_contents6 = new_contents5.gsub("}"){rand(2).zero? ? "}" : ")"}
98
104
  new_contents7 = new_contents6.gsub("px"){rand(2).zero? ? "px" : "xp"}
99
105
  new_contents8 = new_contents7.gsub(">"){rand(2).zero? ? "<" : "."}
106
+ new_contents9 = new_contents8.gsub("=="){rand(2).zero? ? "==" : "="}
100
107
 
101
108
  # puts new_contents6
102
109
 
103
110
  # To write changes to the file, use:
104
- File.open(file_name, "w") {|file| file.puts new_contents8 }
111
+ File.open(file_name, "w") {|file| file.puts new_contents9 }
105
112
 
106
113
  text = File.open(file_name, "r"){ |file| file.read }#File.read(file_name)
107
114
  # puts text
@@ -113,8 +120,8 @@ module Yogi
113
120
  post_counted_s = count_em(text,"s")
114
121
  post_counted_bracket = count_em(text,"}")
115
122
  post_counted_px = count_em(text,"px")
116
- post_counted_px = count_em(text,">")
117
123
  post_counted_sq_bracket = count_em(text,">")
124
+ post_counted_equal = count_em(text,"==")
118
125
 
119
126
  # puts "commas : #{post_counted_comma}"
120
127
  # puts "semicolons : #{post_counted_semicolon}"
@@ -135,6 +142,7 @@ module Yogi
135
142
  $pre_diff_bracket = $pre_counted_bracket - post_counted_bracket
136
143
  $pre_diff_px = $pre_counted_px - post_counted_px
137
144
  $pre_diff_sq_bracket = $pre_counted_sq_bracket - post_counted_sq_bracket
145
+ $pre_diff_equal = $pre_counted_equal - post_counted_equal
138
146
 
139
147
  pre_count_hash = {file_name => {
140
148
  "pre_counted_comma": $pre_counted_comma,
@@ -145,6 +153,7 @@ module Yogi
145
153
  "pre_counted_bracket": $pre_counted_bracket,
146
154
  "pre_counted_px": $pre_counted_px,
147
155
  "pre_counted_sq_bracket": $pre_counted_sq_bracket,
156
+ "pre_counted_equal": $pre_counted_equal,
148
157
  "pre_diff_comma": $pre_diff_comma,
149
158
  "pre_diff_semicolon": $pre_diff_semicolon,
150
159
  "pre_diff_l": $pre_diff_l,
@@ -152,7 +161,8 @@ module Yogi
152
161
  "pre_diff_s": $pre_diff_s,
153
162
  "pre_diff_bracket": $pre_diff_bracket,
154
163
  "pre_diff_px": $pre_diff_px,
155
- "pre_diff_sq_bracket": $pre_diff_sq_bracket
164
+ "pre_diff_sq_bracket": $pre_diff_sq_bracket,
165
+ "pre_diff_equal": $pre_diff_equal
156
166
  }}
157
167
  count_hash << pre_count_hash
158
168
 
@@ -172,6 +182,19 @@ module Yogi
172
182
  File.open('.git/.ignoreme.json', "a") {|file| file.write count_hash.to_json}
173
183
  puts "You can start your debugging..."
174
184
  puts "if your are sick of it, just type...'fixme'"
185
+ if OS.mac?
186
+ file = File.join(__dir__, 'sound', 'activated.mp3')
187
+ escfile = Shellwords.escape(file)
188
+ cmd = "afplay #{escfile}"
189
+ system cmd
190
+
191
+
192
+ # cmd = ("say 'Debugging mode activated'")
193
+ # exec cmd
194
+ # cmd = ("afplay 'sound/activated.wav'")
195
+ # exec cmd
196
+
197
+ end
175
198
  end
176
199
  end
177
200
 
@@ -202,6 +225,7 @@ module Yogi
202
225
  post_counted_bracket = count_em(text,"}")
203
226
  post_counted_px = count_em(text,"px")
204
227
  post_counted_sq_bracket = count_em(text,">")
228
+ post_counted_equal = count_em(text,"==")
205
229
 
206
230
  json_file = File.read(".git/.ignoreme.json")
207
231
  variable_hash = JSON.parse(json_file)
@@ -214,6 +238,8 @@ module Yogi
214
238
  $pre_counted_bracket = variable_hash[i][file_name]['pre_counted_bracket']
215
239
  $pre_counted_px = variable_hash[i][file_name]['pre_counted_px']
216
240
  $pre_counted_sq_bracket = variable_hash[i][file_name]['pre_counted_sq_bracket']
241
+ $pre_counted_equal = variable_hash[i][file_name]['pre_counted_equal']
242
+
217
243
  $pre_diff_comma = variable_hash[i][file_name]['pre_diff_comma']
218
244
  $pre_diff_semicolon = variable_hash[i][file_name]['pre_diff_semicolon']
219
245
  $pre_diff_l = variable_hash[i][file_name]['pre_diff_l']
@@ -222,6 +248,7 @@ module Yogi
222
248
  $pre_diff_bracket = variable_hash[i][file_name]['pre_diff_bracket']
223
249
  $pre_diff_px = variable_hash[i][file_name]['pre_diff_px']
224
250
  $pre_diff_sq_bracket = variable_hash[i][file_name]['pre_diff_sq_bracket']
251
+ $pre_diff_equal = variable_hash[i][file_name]['pre_diff_equal']
225
252
  i += 1
226
253
  post_diff_comma = $pre_counted_comma - post_counted_comma
227
254
  post_diff_semicolon = $pre_counted_semicolon - post_counted_semicolon
@@ -231,12 +258,13 @@ module Yogi
231
258
  post_diff_bracket = $pre_counted_bracket - post_counted_bracket
232
259
  post_diff_px = $pre_counted_px - post_counted_px
233
260
  post_diff_sq_bracket = $pre_counted_sq_bracket - post_counted_sq_bracket
261
+ post_diff_equal = $pre_counted_equal - post_counted_equal
234
262
 
235
263
  # total changes made in each file
236
- total_pre_diff = $pre_diff_comma + $pre_diff_semicolon + $pre_diff_l + $pre_diff_3 + $pre_diff_s + $pre_diff_bracket + $pre_diff_px + $pre_diff_sq_bracket
264
+ total_pre_diff = $pre_diff_comma + $pre_diff_semicolon + $pre_diff_l + $pre_diff_3 + $pre_diff_s + $pre_diff_bracket + $pre_diff_px + $pre_diff_sq_bracket + $pre_diff_equal
237
265
 
238
266
  # total changes not fixed
239
- total_post_diff = post_diff_comma + post_diff_semicolon + post_diff_l + post_diff_3 + post_diff_s + post_diff_bracket + post_diff_px + post_diff_sq_bracket
267
+ total_post_diff = post_diff_comma + post_diff_semicolon + post_diff_l + post_diff_3 + post_diff_s + post_diff_bracket + post_diff_px + post_diff_sq_bracket + post_diff_equal
240
268
 
241
269
  pre_diff_array << total_pre_diff
242
270
  post_diff_array << total_post_diff
@@ -333,11 +361,20 @@ module Yogi
333
361
  if pre_diff == 0
334
362
  puts 'there must have gone something wrong...no errors to begin with'
335
363
  else
336
- fix = ((pre_diff - post_diff)/pre_diff)*100
364
+ fixed_errors = pre_diff - post_diff
365
+ fix = ((fixed_errors)/pre_diff)*100
337
366
  fix = fix.round(3)
338
367
  puts "================================="
339
368
  puts " You fixed #{fix}% of all the errors "
369
+ puts " You fixed #{fixed_errors.to_i} errors, #{post_diff.to_i} more to go."
340
370
  puts "================================="
371
+ if OS.mac?
372
+ file = File.join(__dir__, 'sound', 'oh-yeah.mp3')
373
+ escfile = Shellwords.escape(file)
374
+ cmd = "afplay #{escfile}"
375
+ system cmd
376
+
377
+ end
341
378
  end
342
379
  end
343
380
  end
@@ -356,6 +393,12 @@ module Yogi
356
393
  FileUtils.rm_r '.git/.ignoreme.json'
357
394
  FileUtils.rm_r '.git/.ignoremefile.txt'
358
395
  puts " Hope You had fun and try it again later."
396
+ if OS.mac?
397
+ file = File.join(__dir__, 'sound', 'Giving-up.mp3')
398
+ escfile = Shellwords.escape(file)
399
+ cmd = "afplay #{escfile}"
400
+ system cmd
401
+ end
359
402
  end
360
403
  end
361
404
 
data/yogi.gemspec CHANGED
@@ -32,5 +32,5 @@ Gem::Specification.new do |spec|
32
32
 
33
33
  spec.add_development_dependency "bundler", "~> 1.12"
34
34
  spec.add_development_dependency "rake", "~> 10.0"
35
- # spec.add_dependency "fileutils"
35
+ spec.add_dependency "os"
36
36
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yogi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Langnickel
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: os
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  description: |-
42
56
  The Master of Syntax Error brings you... this debugging exercise
43
57
  type "activate" to start the exercise, happy ...debugging your project
@@ -51,6 +65,7 @@ executables:
51
65
  extensions: []
52
66
  extra_rdoc_files: []
53
67
  files:
68
+ - ".DS_Store"
54
69
  - ".gitignore"
55
70
  - CODE_OF_CONDUCT.md
56
71
  - Gemfile
@@ -62,6 +77,12 @@ files:
62
77
  - bin/console
63
78
  - bin/fixme
64
79
  - bin/setup
80
+ - lib/.DS_Store
81
+ - lib/sound/.DS_Store
82
+ - lib/sound/Giving-up.mp3
83
+ - lib/sound/activated.mp3
84
+ - lib/sound/missile-launch-intiated.mp3
85
+ - lib/sound/oh-yeah.mp3
65
86
  - lib/tasks/yogi.rake
66
87
  - lib/yogi.rb
67
88
  - lib/yogi/version.rb