hw_checker 1.3.47 → 1.3.48
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 +8 -8
- data/lib/hw_checker/ruby_stat.rb +22 -18
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OTg3MzhlZDRmZTg3MWQ3ODVhNmI2YzAzMzg1MWZlMGYxZGRmYTY5Ng==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
N2RhYzFlMGNlNmQ5ZDYwOTZlOGYzNWM3N2RhYzc3OTQ4MWU0NTllNA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NzgxZWZhY2E4Mjk5ZTZhNDA3ZTM0ZGI5MzczNjAzZTgxOWYyYjk0NDRmZTIw
|
10
|
+
N2U5ZTdkM2Q2NzcwNjFkNzkyOWM5OGNjMzY0MGYzZmU0MzdiYjE0YmQ5OWIw
|
11
|
+
ZGI0YTRjMjNmZTE4OTg2Njg4NjNhMWZjODE2YjIwYjU5YzUyZjU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZGQ5OTA2YmExMDdlNDlkMGMxYmNiZWUxMWZiMDU0NGQ4MzI3Yjk2YjNiYTli
|
14
|
+
ZmIwZWM5YzdmZDcxMzI0ZmE3YmVkNGU1ZDkwZGI3OTc0OTgwMzI2YzFiMjE0
|
15
|
+
OTVlZWVmODIxN2I1MDk3YjYxM2FkYjIyMTU4MDFlMTNhNDI0NDY=
|
data/lib/hw_checker/ruby_stat.rb
CHANGED
@@ -1,34 +1,38 @@
|
|
1
1
|
module HomeWorkChecker
|
2
2
|
module TestRunStat
|
3
|
-
class
|
3
|
+
class RubyStat
|
4
4
|
def initialize(tmp_path, dirname)
|
5
|
-
@work_path = "#{tmp_path}/#{dirname}
|
6
|
-
raise DirectoryExistError, "Archive '#{dirname}' is invalid" unless Dir::exist?(@work_path)
|
7
|
-
@
|
5
|
+
@work_path = "#{tmp_path}/#{dirname}"
|
6
|
+
raise DirectoryExistError, "Archive '#{dirname}' is invalid" unless Dir::exist?(@work_path)
|
7
|
+
@lines_all = @lines_failed = 0
|
8
8
|
end
|
9
9
|
|
10
10
|
def perform
|
11
11
|
Dir.foreach(@work_path) do |p|
|
12
|
-
next unless File
|
13
|
-
`
|
14
|
-
|
12
|
+
next unless File::file?("#{@work_path}/#{p}") && File.extname(p) == '.rb'
|
13
|
+
`rubocop #{@work_path}/#{p} > #{@work_path}/#{p}.tmp`
|
14
|
+
count_lines_failed("#{@work_path}/#{p}.tmp")
|
15
|
+
count_lines_all("#{@work_path}/#{p}")
|
15
16
|
end
|
16
|
-
|
17
|
+
calc_percent_quality
|
17
18
|
end
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
@passed += 1 if value == '.'
|
25
|
-
@failed += 1 if value == 'F'
|
20
|
+
def count_lines_failed(filename)
|
21
|
+
temp = []
|
22
|
+
File.open(filename).each_line do |line|
|
23
|
+
next unless line.match(/[CW]:\s+\d+:\s+[\w\W]{4,}/)
|
24
|
+
temp << line.scan(/\d+/).first.to_i
|
26
25
|
end
|
26
|
+
@lines_failed += temp.uniq.size
|
27
27
|
end
|
28
28
|
|
29
|
-
def
|
30
|
-
|
31
|
-
|
29
|
+
def count_lines_all(filename)
|
30
|
+
File.open(filename).each_line { @lines_all += 1 }
|
31
|
+
end
|
32
|
+
|
33
|
+
def calc_percent_quality
|
34
|
+
return 0.00 if @lines_all.zero?
|
35
|
+
( (1.0 - @lines_failed.to_f / @lines_all) * 100).round(2)
|
32
36
|
end
|
33
37
|
end
|
34
38
|
end
|