hw_checker 1.3.46 → 1.3.47

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YzQ1YmJlODY0MzJhMjAxNmZjZDIwNDRiMWRiOGY4MWU5NTlhMTk1MQ==
4
+ MzFkNTRjNTA5MDI3NGQ4MzE5M2U0YjFhYTY2Y2FkZTk3ZTA4MzhjOA==
5
5
  data.tar.gz: !binary |-
6
- OWNiNmMzNjM5NTkyNjM0YjQ0MTM0YWI2ODA3NTRiZjBhMDMzZGM3ZQ==
6
+ NzJkOTY5YTM2ZTAzZGI4YzkyOTgzYzQzNzJlYzUyMzBiYTkwZTJiOA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- OWQzZWYzMmIxMWVlMTRmNmY2NTcwNzEwZTk3Yzc3YTg2NzcwMmI2N2QwZTcw
10
- MmQxNDFlYjMxMjE3YzlmYmJiNDk4ZTI0N2Q0MzAwYTUxNzA4ZjhkZWMxZTJi
11
- YWFjMWM4NmQ3ZWE1NmE2ZGU3YWJjNTdmNTI5N2Y0YjZlYWIyOTI=
9
+ OWQ4ZWU5OWMyZjEyMTljNWY2NjI3YmI0NzlhMTNkMjY2ZDcxNTk4YzQ3ODRi
10
+ YzUxOTBiMWYxODUwMWMzODVkY2ZjODFiNWU1NDA2ZmNkNGM3YzVlMTQ5M2Mx
11
+ ZDc0NDYyZWZhZmFlOTNkNjQ2MGQwMjJkZWI2MDc5ZTk4MjEyMjk=
12
12
  data.tar.gz: !binary |-
13
- ZWM3OTQ3Mzc5ZDVjNTkyNzc3MTQyMDYxMjk4MzlhMmY2MTgyMTIzMWE2MzIx
14
- ZDMxMDEyMmMyZWVjMWU4OWI5OGFkODlhZjUxYTRjY2I1MDA3M2JjYjE1ZjY0
15
- YzE0NGFjYjdmNzc2ZDU4YzkxNDJiMWI0ZGY0Yjk1NWMzYmM4MmE=
13
+ N2MzZTBkYjdhN2U5NTQ0OGM1ZTBkZDI4NWYxYmQxZTU3M2Y1OTAzYzA1ZjI4
14
+ ZTJjMWE5OWRhYzEyMDFkZGExNjAxMjEyNmQ4MjdmN2U0YjA3ODZhMzM3NjZj
15
+ MDI2M2YwZWIzY2M3NGJkNTZkYTQ5ZjQwYmQ0YTc4YTBmNzM3MWI=
@@ -2,16 +2,17 @@ module HomeWorkChecker
2
2
  module TestRunStat
3
3
  class PythonStat
4
4
  def initialize(tmp_path, dirname)
5
- @tmp_path, @dirname= tmp_path, dirname
5
+ @work_path = "#{tmp_path}/#{dirname}/tests/statistic"
6
+ raise DirectoryExistError, "Archive '#{dirname}' is invalid" unless Dir::exist?(@work_path)
6
7
  @lines_all = @lines_failed = 0
7
8
  end
8
9
 
9
10
  def perform
10
11
  result = 0
11
- Dir.foreach("#{@tmp_path}/#{@dirname}/tests/statistic") do |p|
12
- next unless File.file?("#{@tmp_path}/#{@dirname}/tests/statistic/#{p}") && File.extname(p) == '.py' && p != '__init__.py'
13
- `pylint #{@tmp_path}/#{@dirname}/tests/statistic/#{p} > #{@tmp_path}/#{@dirname}/tests/statistic/#{p}.tmp 2>&1`
14
- result = calc_percent_quality("#{@tmp_path}/#{@dirname}/tests/statistic/#{p}.tmp")
12
+ Dir.foreach(@work_path) do |p|
13
+ next unless File.file?("#{@work_path}/#{p}") && File.extname(p) == '.py' && p != '__init__.py'
14
+ `pylint #{@work_path}/#{p} > #{@work_path}/#{p}.tmp 2>&1`
15
+ result = calc_percent_quality("#{@work_path}/#{p}.tmp")
15
16
  end
16
17
  result
17
18
  end
@@ -2,15 +2,16 @@ module HomeWorkChecker
2
2
  module TestRunStat
3
3
  class PythonTestRun
4
4
  def initialize(tmp_path, dirname)
5
- @tmp_path, @dirname= tmp_path, dirname
5
+ @work_path = "#{tmp_path}/#{dirname}/tests/application"
6
+ raise DirectoryExistError, "Archive '#{dirname}' is invalid" unless Dir::exist?(@work_path)
6
7
  @passed = @failed = 0
7
8
  end
8
9
 
9
10
  def perform
10
- Dir.foreach("#{@tmp_path}/#{@dirname}/tests/application") do |p|
11
- next unless File.file?("#{@tmp_path}/#{@dirname}/tests/application/#{p}") && File.extname(p) == '.py' && p != '__init__.py'
12
- `python #{@tmp_path}/#{@dirname}/tests/application/#{p} > #{@tmp_path}/#{@dirname}/tests/application/#{p}.tmp 2>&1`
13
- count_passed_failed("#{@tmp_path}/#{@dirname}/tests/application/#{p}.tmp")
11
+ Dir.foreach(@work_path) do |p|
12
+ next unless File.file?("#{@work_path}/#{p}") && File.extname(p) == '.py' && p != '__init__.py'
13
+ `python #{@work_path}/#{p} > #{@work_path}/#{p}.tmp 2>&1`
14
+ count_passed_failed("#{@work_path}/#{p}.tmp")
14
15
  end
15
16
  calc_percent_passed
16
17
  end
@@ -1,37 +1,34 @@
1
1
  module HomeWorkChecker
2
2
  module TestRunStat
3
- class RubyStat
3
+ class RubyTestRun
4
4
  def initialize(tmp_path, dirname)
5
- @tmp_path, @dirname= tmp_path, dirname
6
- @lines_all = @lines_failed = 0
5
+ @work_path = "#{tmp_path}/#{dirname}/test"
6
+ raise DirectoryExistError, "Archive '#{dirname}' is invalid" unless Dir::exist?(@work_path)
7
+ @passed = @failed = 0
7
8
  end
8
9
 
9
10
  def perform
10
- Dir.foreach("#{@tmp_path}/#{@dirname}") do |p|
11
- next unless File::file?("#{@tmp_path}/#{@dirname}/#{p}") && File.extname(p) == '.rb'
12
- `rubocop #{@tmp_path}/#{@dirname}/#{p} > #{@tmp_path}/#{@dirname}/#{p}.tmp`
13
- count_lines_failed("#{@tmp_path}/#{@dirname}/#{p}.tmp")
14
- count_lines_all("#{@tmp_path}/#{@dirname}/#{p}")
11
+ Dir.foreach(@work_path) do |p|
12
+ next unless File.file?("#{@work_path}/#{p}") && File.extname(p) == '.rb'
13
+ `rspec #{@work_path}/#{p} > #{@work_path}/#{p}.tmp`
14
+ count_passed_failed("#{@work_path}/#{p}.tmp")
15
15
  end
16
- calc_percent_quality
16
+ calc_percent_passed
17
17
  end
18
18
 
19
- def count_lines_failed(filename)
20
- temp = []
21
- File.open(filename).each_line do |line|
22
- next unless line.match(/[CW]:\s+\d+:\s+[\w\W]{4,}/)
23
- temp << line.scan(/\d+/).first.to_i
19
+ private
20
+ def count_passed_failed(filename)
21
+ report = File.open(filename).first.chomp
22
+ return if report == 'No examples found.'
23
+ report.each_char do |value|
24
+ @passed += 1 if value == '.'
25
+ @failed += 1 if value == 'F'
24
26
  end
25
- @lines_failed += temp.uniq.size
26
27
  end
27
28
 
28
- def count_lines_all(filename)
29
- File.open(filename).each_line { @lines_all += 1 }
30
- end
31
-
32
- def calc_percent_quality
33
- return 0.00 if @lines_all.zero?
34
- ( (1.0 - @lines_failed.to_f / @lines_all) * 100).round(2)
29
+ def calc_percent_passed
30
+ return 0.00 if @passed.zero? && @failed.zero?
31
+ (@passed.to_f / (@passed + @failed) * 100).round(2)
35
32
  end
36
33
  end
37
34
  end
@@ -2,15 +2,16 @@ module HomeWorkChecker
2
2
  module TestRunStat
3
3
  class RubyTestRun
4
4
  def initialize(tmp_path, dirname)
5
- @tmp_path, @dirname= tmp_path, dirname
5
+ @work_path = "#{tmp_path}/#{dirname}/test"
6
+ raise DirectoryExistError, "Archive '#{dirname}' is invalid" unless Dir::exist?(@work_path)
6
7
  @passed = @failed = 0
7
8
  end
8
9
 
9
10
  def perform
10
- Dir.foreach("#{@tmp_path}/#{@dirname}/test") do |p|
11
- next unless File.file?("#{@tmp_path}/#{@dirname}/test/#{p}") && File.extname(p) == '.rb'
12
- `rspec #{@tmp_path}/#{@dirname}/test/#{p} > #{@tmp_path}/#{@dirname}/test/#{p}.tmp`
13
- count_passed_failed("#{@tmp_path}/#{@dirname}/test/#{p}.tmp")
11
+ Dir.foreach(@work_path) do |p|
12
+ next unless File.file?("#{@work_path}/#{p}") && File.extname(p) == '.rb'
13
+ `rspec #{@work_path}/#{p} > #{@work_path}/#{p}.tmp`
14
+ count_passed_failed("#{@work_path}/#{p}.tmp")
14
15
  end
15
16
  calc_percent_passed
16
17
  end
@@ -7,4 +7,4 @@ module HomeWorkChecker
7
7
  end
8
8
  end
9
9
  end
10
- end
10
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hw_checker
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.46
4
+ version: 1.3.47
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lv-LAMP-085
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-07 00:00:00.000000000 Z
11
+ date: 2013-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec