dokaz 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OTE0MmZmNzRmMjlkOGE1ZTFmNjRiYjUwYmU5ZDlhNzQzZGE2Mjc4Yg==
4
+ YmVmYmJhOGQ4YWFjNWM2MDg3ZjIxODcxOGNkYjc0Yjg4ZGY2ODUzOA==
5
5
  data.tar.gz: !binary |-
6
- NTkxNjdlMDk0Mjk5NDZiYmU0ODBlMDE2YjUzYTJjMzliM2YyN2UyZg==
6
+ YWY4ZGM3MDZmYjQ5ZWJiZmNkZjVmMzc2NWVhZGY5ZjM3YWZjMzJiMQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MjI2NDRlZTJkYjlkNWQxYzA0N2UwYWZiZjA0YWYxNzgwZmFkNDJlMWVlNzA2
10
- YWEyNDk0OTZkOGVmYjg5ZDcwNWIxYTc5OGM2ODMzNzRmNTljZTY3Y2VkOGM1
11
- ZmEzZWM5Zjg1NjQ2ZmU2MWZhZTQwYWZjMjE1MDFiNmYzOGY5OGU=
9
+ YjQ4YzBlMThjZmJiN2Y0NjQ0MDRjZmMyYTM2Yjg4NjRiOWRlNTk0YzNjNGY5
10
+ MmYzNjRmZTRlNjdjNjQ3OWY3YTg2OGNiNDAxZTJjOTdjYjBhMTI0NjNjOWY0
11
+ NzkzMmVhZTAzMzA1NzlmNTNjOWFiZjVlYThlMzQ0NGE5NmM2ZGI=
12
12
  data.tar.gz: !binary |-
13
- Y2JmMGY4ODljN2QxZjE0ODA4ZDYwN2Y4Mjg0MmM1M2EwYWNkYjM1YTBjYzIw
14
- YTU2MTYwMjllOTc1NzgyMzUyODQxZmIyN2Y1NWQyMWNlM2E3ZWFmZmFlNThk
15
- OTcyMjVjMjE5ZmI3ZWUwYTZhZGM5MjE4MTEwYTM0MTA0OGU1ZGY=
13
+ MjhkNTU2YWQ3ZTMwN2JlNjMyOTEzNjAzMjRjYzE3MDMyZjEzZmY1Y2RiNGY3
14
+ OGRkM2JhZjg5ZjJhZjVhMWY1NDNkZjExM2E5ZDc3ODc4YTY1MDAzYTI1YWY4
15
+ NmQ3NmYyNTEyMWRkMWNlY2Q1Mjk2ZDQ0OTAxMDQyM2EwMTk5ZDM=
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'dokaz'
3
- s.version = '0.0.3'
3
+ s.version = '0.0.4'
4
4
  s.authors = ['Victor Shepelev']
5
5
  s.email = 'zverok.offline@gmail.com'
6
6
  s.homepage = 'https://github.com/zverok/dokaz'
@@ -24,6 +24,7 @@ Gem::Specification.new do |s|
24
24
 
25
25
  s.add_dependency 'ansi'
26
26
  s.add_dependency 'slop', '~> 3'
27
+ s.add_dependency 'rouge'
27
28
 
28
29
  s.add_development_dependency 'rspec', '~> 3'
29
30
  s.add_development_dependency 'rspec-its', '~> 1'
@@ -1,8 +1,14 @@
1
1
  # encoding: utf-8
2
2
  require 'ansi/code'
3
+ require 'rouge'
3
4
 
4
5
  class Dokaz
5
6
  class Formatter
7
+ def initialize
8
+ @rouge = Rouge::Formatters::Terminal256.new
9
+ @lexer = Rouge::Lexers::Ruby.new
10
+ end
11
+
6
12
  def start_block(block)
7
13
  end
8
14
 
@@ -35,6 +41,14 @@ class Dokaz
35
41
  color(:dark, str)
36
42
  end
37
43
 
44
+ def code(str)
45
+ if STDOUT.tty?
46
+ @rouge.format(@lexer.lex(str))
47
+ else
48
+ code + "\n"
49
+ end
50
+ end
51
+
38
52
  def color(code, str)
39
53
  if STDOUT.tty?
40
54
  ANSI.send(code){str}
@@ -46,6 +60,7 @@ class Dokaz
46
60
 
47
61
  class SpecFormatter < Formatter
48
62
  def initialize
63
+ super
49
64
  @ok = 0
50
65
  @errors = []
51
66
  end
@@ -65,8 +80,8 @@ class Dokaz
65
80
  puts
66
81
  puts
67
82
 
68
- @errors.each do |code, e|
69
- puts code
83
+ @errors.each do |src, e|
84
+ print code(src)
70
85
  puts( error("#{e.message} (#{e.class})\n " + filter_backtrace(e.backtrace).join("\n ") + "\n"))
71
86
  end
72
87
 
@@ -97,16 +112,16 @@ class Dokaz
97
112
  puts "#{block.caption}\n#{'=' * block.caption.size}\n\n"
98
113
  end
99
114
 
100
- def output(code, res, out)
101
- puts code
115
+ def output(src, res, out)
116
+ print code(src)
102
117
  unless out.empty?
103
118
  puts comment("# Prints: \n# " + out.split("\n").join("\n# "))
104
119
  end
105
120
  puts comment("# => " + res.inspect.split("\n").join("\n# "))
106
121
  end
107
122
 
108
- def output_err(code, e)
109
- puts code
123
+ def output_err(src, e)
124
+ print code(src)
110
125
  puts comment("# Throws: #{e.message} (#{e.class})")
111
126
  end
112
127
 
@@ -1,5 +1,6 @@
1
1
  # encoding: utf-8
2
2
  require 'strscan'
3
+ require 'stringio'
3
4
 
4
5
  class Dokaz
5
6
  class Block
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dokaz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Shepelev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-19 00:00:00.000000000 Z
11
+ date: 2015-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ansi
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rouge
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
  - !ruby/object:Gem::Dependency
42
56
  name: rspec
43
57
  requirement: !ruby/object:Gem::Requirement