dokaz 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +8 -8
  2. data/dokaz.gemspec +1 -1
  3. data/lib/dokaz/formatters.rb +26 -11
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- N2ZlMjgzMWE1M2FiMWQ0ZjNiODJkZDgzMzAxZGU2MzcxOWZiNGI3NA==
4
+ OTE0MmZmNzRmMjlkOGE1ZTFmNjRiYjUwYmU5ZDlhNzQzZGE2Mjc4Yg==
5
5
  data.tar.gz: !binary |-
6
- ZGIyYTAxYTAxOTUyZTRlNzQ0ZGQ5N2JjOTQxZmEwNGE0MTg0ZTJmNw==
6
+ NTkxNjdlMDk0Mjk5NDZiYmU0ODBlMDE2YjUzYTJjMzliM2YyN2UyZg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZGRhODA3NmJjMzc5YTMwNmQwZTJlMzA5MWRkZjhjMTVkN2YwNTViZmIzMzVi
10
- NjQ0YzliZjE2ODk5N2IxN2IxYThmNDVkZGQzNGQ2YTc3NmI3ODAyZjM0ZDZj
11
- YjhkNDExOTVkMTgzZTk3OTM4M2YwZWQyM2Y2ODk3MzBkNTlkYjc=
9
+ MjI2NDRlZTJkYjlkNWQxYzA0N2UwYWZiZjA0YWYxNzgwZmFkNDJlMWVlNzA2
10
+ YWEyNDk0OTZkOGVmYjg5ZDcwNWIxYTc5OGM2ODMzNzRmNTljZTY3Y2VkOGM1
11
+ ZmEzZWM5Zjg1NjQ2ZmU2MWZhZTQwYWZjMjE1MDFiNmYzOGY5OGU=
12
12
  data.tar.gz: !binary |-
13
- ZTdlMzJkYjlhMjEwN2U0YzAwODhlYmEzODU2ZDY4MjFiYjM0MzVkYTg1NDZh
14
- NTRiYTk3YzE0NDUwYjkxNzQ1ZTM2ZjhmMGU4Njg2MzMxNTc5NTZiNWRlZTMy
15
- ZDJkOGQ3NDg4M2NhNTA1ZWIxYjY4NzhlZTkyZGRjYjMzNmRjN2Q=
13
+ Y2JmMGY4ODljN2QxZjE0ODA4ZDYwN2Y4Mjg0MmM1M2EwYWNkYjM1YTBjYzIw
14
+ YTU2MTYwMjllOTc1NzgyMzUyODQxZmIyN2Y1NWQyMWNlM2E3ZWFmZmFlNThk
15
+ OTcyMjVjMjE5ZmI3ZWUwYTZhZGM5MjE4MTEwYTM0MTA0OGU1ZGY=
data/dokaz.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'dokaz'
3
- s.version = '0.0.2'
3
+ s.version = '0.0.3'
4
4
  s.authors = ['Victor Shepelev']
5
5
  s.email = 'zverok.offline@gmail.com'
6
6
  s.homepage = 'https://github.com/zverok/dokaz'
@@ -22,6 +22,26 @@ class Dokaz
22
22
  def filter_backtrace(trace)
23
23
  trace.take_while{|ln| ln !~ /lib\/dokaz/}
24
24
  end
25
+
26
+ def ok(str)
27
+ color(:green, str)
28
+ end
29
+
30
+ def error(str)
31
+ color(:red, str)
32
+ end
33
+
34
+ def comment(str)
35
+ color(:dark, str)
36
+ end
37
+
38
+ def color(code, str)
39
+ if STDOUT.tty?
40
+ ANSI.send(code){str}
41
+ else
42
+ str
43
+ end
44
+ end
25
45
  end
26
46
 
27
47
  class SpecFormatter < Formatter
@@ -37,7 +57,7 @@ class Dokaz
37
57
  def finish_block(block)
38
58
  unless @err
39
59
  @ok += 1
40
- print ANSI.green{'.'}
60
+ print ok('.')
41
61
  end
42
62
  end
43
63
 
@@ -47,27 +67,27 @@ class Dokaz
47
67
 
48
68
  @errors.each do |code, e|
49
69
  puts code
50
- puts( ANSI.red{"#{e.message} (#{e.class})\n " + filter_backtrace(e.backtrace).join("\n ") + "\n"})
70
+ puts( error("#{e.message} (#{e.class})\n " + filter_backtrace(e.backtrace).join("\n ") + "\n"))
51
71
  end
52
72
 
53
73
  puts
54
74
  @errors.each do |code, e|
55
75
  ln = e.backtrace.first.sub(/:in .*$/, '')
56
- puts ANSI.red{"dokaz #{ln}"} + ANSI.cyan{" # #{e.message} (#{e.class})"}
76
+ puts error("dokaz #{ln}") + comment(" # #{e.message} (#{e.class})")
57
77
  end
58
78
 
59
79
  puts
60
80
  puts [
61
81
  "#{@ok + @errors.count} total",
62
- !@ok.zero? && ANSI.green{"#{@ok} ok"},
63
- !@errors.empty? && ANSI.red{"#{@errors.count} errors"}
82
+ !@ok.zero? && ok("#{@ok} ok"),
83
+ !@errors.empty? && error("#{@errors.count} errors")
64
84
  ].select{|l| l}.join(', ')
65
85
 
66
86
  end
67
87
 
68
88
  def output_err(code, e)
69
89
  @errors << [code, e]
70
- print ANSI.red{'F'}
90
+ print error('F')
71
91
  @err = true
72
92
  end
73
93
  end
@@ -93,10 +113,5 @@ class Dokaz
93
113
  def finish_block(block)
94
114
  puts "\n\n"
95
115
  end
96
-
97
- private
98
- def comment(str)
99
- ANSI.dark{str}
100
- end
101
116
  end
102
117
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dokaz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Shepelev