Skip to content

Commit cf26b52

Browse files
committed
fix YAML encoder for Psych (damn!)
1 parent fc509f3 commit cf26b52

File tree

2 files changed

+14
-26
lines changed

2 files changed

+14
-26
lines changed

lib/coderay/encoders/yaml.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ def setup options
2020
end
2121

2222
def finish options
23-
::YAML.dump @data, @out
24-
25-
super
23+
output ::YAML.dump(@data)
2624
end
2725

2826
public

test/unit/duo.rb

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require 'test/unit'
2+
require 'yaml'
23
require 'coderay'
34

45
class DuoTest < Test::Unit::TestCase
@@ -17,29 +18,18 @@ def test_two_hash
1718

1819
def test_call
1920
duo = CodeRay::Duo[:python => :yml]
20-
assert_equal <<-'YAML', duo.call('def test: "pass"')
21-
---
22-
- - def
23-
- :keyword
24-
- - " "
25-
- :space
26-
- - test
27-
- :method
28-
- - ":"
29-
- :operator
30-
- - " "
31-
- :space
32-
- - :begin_group
33-
- :string
34-
- - "\""
35-
- :delimiter
36-
- - pass
37-
- :content
38-
- - "\""
39-
- :delimiter
40-
- - :end_group
41-
- :string
42-
YAML
21+
yaml = [["def", :keyword],
22+
[" ", :space],
23+
["test", :method],
24+
[":", :operator],
25+
[" ", :space],
26+
[:begin_group, :string],
27+
["\"", :delimiter],
28+
["pass", :content],
29+
["\"", :delimiter],
30+
[:end_group, :string]]
31+
32+
assert_equal yaml, YAML.load(duo.call('def test: "pass"'))
4333
end
4434

4535
end

0 commit comments

Comments
 (0)