bitclust-core 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bitclust/syntax_highlighter.rb +8 -0
- data/lib/bitclust/version.rb +1 -1
- data/test/test_syntax_highlighter.rb +44 -0
- metadata +15 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f862080777927bb3b01d118c4eed19be1924fc7764a66ada4a05d2dced710474
|
4
|
+
data.tar.gz: 8686589708e6c3514eaf06ac27622e57fc6b74945734d6303306b0567b1cbec6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e183939ea2f3463750a8ed60498a3b9f63f2792af3d1f90751bf6b8f41ddfee0b98704f8ffc5f52fb161750ad6e5705d5d4714fb70d124e13290f59a7168726
|
7
|
+
data.tar.gz: 1ea7d07e5bed99ab26ef3e7266bc1cd981890e9cb0e7da998f8d49b46a025854b610efb795487dcb7e969186f03f5a24278c766bf0991faa7667a73a6d7aaf34
|
@@ -118,6 +118,7 @@ module BitClust
|
|
118
118
|
|
119
119
|
def initialize(src, filename = "-", lineno = 1)
|
120
120
|
super
|
121
|
+
@src = src
|
121
122
|
@stack = []
|
122
123
|
@name_buffer = []
|
123
124
|
@__lexer.define_singleton_method(:on_parse_error) do |message|
|
@@ -354,6 +355,13 @@ module BitClust
|
|
354
355
|
on_default(:on_embexpr_end, token, data)
|
355
356
|
end
|
356
357
|
|
358
|
+
def on___end__(token, data)
|
359
|
+
on_default(:on___end__, token, data)
|
360
|
+
style = COLORS[:comment]
|
361
|
+
data << "<span class=\"#{style}\">#{escape_html(@src.lines[lineno..-1].join)}</span>"
|
362
|
+
data
|
363
|
+
end
|
364
|
+
|
357
365
|
def highlight
|
358
366
|
parse("")
|
359
367
|
end
|
data/lib/bitclust/version.rb
CHANGED
@@ -20,4 +20,48 @@ class TestSyntaxHighlighter < Test::Unit::TestCase
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
23
|
+
|
24
|
+
sub_test_case "__END__" do
|
25
|
+
test "extra data" do
|
26
|
+
source = <<~END
|
27
|
+
require "csv"
|
28
|
+
csv = CSV.new(DATA.read)
|
29
|
+
csv.read
|
30
|
+
# => [["header1", "header2"], ["row1_1", "row1_2"], ["row2_1", "row2_2"]]
|
31
|
+
__END__
|
32
|
+
header1,header2
|
33
|
+
row1_1,row1_2
|
34
|
+
row2_1,row2_2
|
35
|
+
END
|
36
|
+
expected = <<~END.chomp
|
37
|
+
<span class="nb">require</span> <span class="s2">"</span><span class="s2">csv</span><span class="s2">"</span>
|
38
|
+
csv <span class="o">=</span> <span class="no">CSV</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="no">DATA</span><span class="p">.</span><span class="nf">read</span><span class="p">)</span>
|
39
|
+
csv<span class="p">.</span><span class="nf">read</span>
|
40
|
+
<span class="c1"># => [["header1", "header2"], ["row1_1", "row1_2"], ["row2_1", "row2_2"]]
|
41
|
+
</span><span class="k">__END__
|
42
|
+
</span><span class="c1">header1,header2
|
43
|
+
row1_1,row1_2
|
44
|
+
row2_1,row2_2
|
45
|
+
</span>
|
46
|
+
END
|
47
|
+
assert_equal(expected, highlight(source))
|
48
|
+
end
|
49
|
+
|
50
|
+
test "without extra data" do
|
51
|
+
source = <<~END
|
52
|
+
require "csv"
|
53
|
+
csv = CSV.new(DATA.read)
|
54
|
+
csv.read
|
55
|
+
# => [["header1", "header2"], ["row1_1", "row1_2"], ["row2_1", "row2_2"]]
|
56
|
+
END
|
57
|
+
expected = <<~END.chomp
|
58
|
+
<span class="nb">require</span> <span class="s2">"</span><span class="s2">csv</span><span class="s2">"</span>
|
59
|
+
csv <span class="o">=</span> <span class="no">CSV</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="no">DATA</span><span class="p">.</span><span class="nf">read</span><span class="p">)</span>
|
60
|
+
csv<span class="p">.</span><span class="nf">read</span>
|
61
|
+
<span class="c1"># => [["header1", "header2"], ["row1_1", "row1_2"], ["row2_1", "row2_2"]]
|
62
|
+
</span>
|
63
|
+
END
|
64
|
+
assert_equal(expected, highlight(source))
|
65
|
+
end
|
66
|
+
end
|
23
67
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bitclust-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- https://github.com/rurema
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test-unit
|
@@ -241,24 +241,24 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
241
241
|
version: '0'
|
242
242
|
requirements: []
|
243
243
|
rubyforge_project: ''
|
244
|
-
rubygems_version: 2.7.
|
244
|
+
rubygems_version: 2.7.6
|
245
245
|
signing_key:
|
246
246
|
specification_version: 4
|
247
247
|
summary: BitClust is a rurema document processor.
|
248
248
|
test_files:
|
249
|
-
- test/
|
250
|
-
- test/
|
251
|
-
- test/
|
249
|
+
- test/test_rdcompiler.rb
|
250
|
+
- test/test_libraryentry.rb
|
251
|
+
- test/test_runner.rb
|
252
|
+
- test/test_syntax_highlighter.rb
|
252
253
|
- test/test_bitclust.rb
|
254
|
+
- test/test_refsdatabase.rb
|
253
255
|
- test/test_methodsignature.rb
|
254
|
-
- test/test_functionreferenceparser.rb
|
255
|
-
- test/test_simplesearcher.rb
|
256
256
|
- test/test_preprocessor.rb
|
257
|
-
- test/test_runner.rb
|
258
|
-
- test/test_libraryentry.rb
|
259
|
-
- test/test_nameutils.rb
|
260
|
-
- test/test_entry.rb
|
261
|
-
- test/run_test.rb
|
262
|
-
- test/test_rdcompiler.rb
|
263
257
|
- test/test_rrdparser.rb
|
264
|
-
- test/
|
258
|
+
- test/test_simplesearcher.rb
|
259
|
+
- test/run_test.rb
|
260
|
+
- test/test_entry.rb
|
261
|
+
- test/test_methoddatabase.rb
|
262
|
+
- test/test_functiondatabase.rb
|
263
|
+
- test/test_nameutils.rb
|
264
|
+
- test/test_functionreferenceparser.rb
|