rouge-lexers-fluentd 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: df3cb79b3b1920d0f178a3aac42c1a9beb85849e
4
+ data.tar.gz: 348935f5d414183f9490e5a6a9651ab39cf9aec8
5
+ SHA512:
6
+ metadata.gz: 1fca72f3c5d08eb5cfcfc2f2761cdbf8c3f53f70703e0efef6cb6f87306b90fbb2410ee428619e3540138c5ef02d59c97123a1bc7e18e45e514549c2cc0c73f3
7
+ data.tar.gz: 7c724aa3279bc40888dce8f6733ff91cf6218b6fcfccd088dab4b99905e80aca6147be3802678647e2940a2ef9ad19c47fa1d544b8c4ccd4e19ad5d22510166f
data/.document ADDED
@@ -0,0 +1,3 @@
1
+ -
2
+ ChangeLog.md
3
+ LICENSE.txt
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ /.bundle
2
+ /.yardoc/
3
+ /Gemfile.lock
4
+ /doc/
5
+ /pkg/
6
+ /vendor/cache/*.gem
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ --markup markdown --title "rouge-lexers-fluentd Documentation" --protected
data/ChangeLog.md ADDED
@@ -0,0 +1,4 @@
1
+ ### 0.1.0 / 2016-06-10
2
+
3
+ * Initial release:
4
+
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem 'kramdown'
7
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2016 KITAITI Makoto
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # rouge-lexers-fluentd
2
+
3
+ * [Homepage](https://rubygems.org/gems/rouge-lexers-fluentd)
4
+ * [Documentation](http://rubydoc.info/gems/rouge-lexers-fluentd/frames)
5
+ * [Email](mailto:KitaitiMakoto at gmail.com)
6
+
7
+ ## Description
8
+
9
+ Rouge lexer for fluentd configuration files
10
+
11
+ ## Features
12
+
13
+ * Guesses Fluentd configuration files from filename
14
+ * Lexes Fluentd configuration files
15
+
16
+ ## Examples
17
+
18
+ require 'rouge/lexers/fluentd'
19
+
20
+ config = File.read("path/to/fluent.conf")
21
+ lexer = Rouge::Lexer.find("fluentd")
22
+ tokens = lexer.lex(config)
23
+ terminal_formatter = Rouge::Formatters::Terminal256.new
24
+ html_formatter = Rouge::Formatters::HTML.new
25
+ File.write 'path/to/output.html', html_formatter.format(tokens)
26
+ puts terminal_formatter.format(tokens)
27
+
28
+ ## Requirements
29
+
30
+ * [Rouge][]
31
+
32
+ ## Install
33
+
34
+ $ gem install rouge-lexers-fluentd
35
+
36
+ ## Todo
37
+
38
+ * Lex array values
39
+ * Lex hash values
40
+ * Lex embedded Ruby code
41
+ * Recognize labels
42
+ * Recognize tag with separator dots
43
+ * Lex quotes in quoted strings correctly
44
+ * Lex closing brackets in array correctly
45
+ * Lex closing braces in hash correctly
46
+
47
+ ## Copyright
48
+
49
+ Copyright (c) 2016 KITAITI Makoto
50
+
51
+ See {file:LICENSE.txt} for details.
52
+
53
+ [Rouge]: http://rouge.jneen.net/
data/Rakefile ADDED
@@ -0,0 +1,26 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+
5
+ begin
6
+ require 'bundler/setup'
7
+ rescue LoadError => e
8
+ abort e.message
9
+ end
10
+
11
+ require 'rake'
12
+
13
+
14
+ require 'rubygems/tasks'
15
+ Gem::Tasks.new
16
+
17
+ require 'rake/testtask'
18
+ Rake::TestTask.new do |test|
19
+ test.libs << 'test'
20
+ test.pattern = 'test/**/test_*.rb'
21
+ test.verbose = true
22
+ end
23
+
24
+ require 'yard'
25
+ YARD::Rake::YardocTask.new
26
+ task :doc => :yard
@@ -0,0 +1,72 @@
1
+ # Receive events from 24224/tcp
2
+ # This is used by log forwarding and the fluent-cat command
3
+ <source>
4
+ @type forward
5
+ port 24224
6
+ </source>
7
+
8
+ # http://this.host:9880/myapp.access?json={"event":"data"}
9
+ <source>
10
+ @type http
11
+ port 9880
12
+ </source>
13
+
14
+ <source>
15
+ @type tail
16
+ @label @SYSTEM
17
+ </source>
18
+
19
+ <label @SYSTEM>
20
+ <filter var.log.middleware.**>
21
+ @type grep
22
+ # ...
23
+ </filter>
24
+ <match **>
25
+ @type s3
26
+ # ...
27
+ </match>
28
+ </label>
29
+
30
+ <filter myapp.access>
31
+ @type record_transformer
32
+ <record>
33
+ host_param "#{Socket.gethostname}"
34
+ </record>
35
+ </filter>
36
+
37
+ # Match events tagged with "myapp.access" and
38
+ # store them to /var/log/fluent/access.%Y-%m-%d
39
+ # Of course, you can control how you partition your data
40
+ # with the time_slice_format option.
41
+ <match myapp.access>
42
+ @type file
43
+ path /var/log/fluent/access
44
+ </match>
45
+
46
+ # Include config files in the ./config.d directory
47
+ @include config.d/*.conf
48
+
49
+ array_param [
50
+ "a", "b"
51
+ ]
52
+ hash_param {
53
+ "k":"v",
54
+ "k1":10
55
+ }
56
+
57
+ <match **>
58
+ @type mail
59
+ subject "[CRITICAL] foo's alert system"
60
+ </match>
61
+
62
+ <match tag>
63
+ @type map
64
+ map '[["code." + tag, time, { "code" => record["code"].to_i}], ["time." + tag, time, { "time" => record["time"].to_i}]]'
65
+ multi true
66
+ </match>
67
+
68
+ str_param "foo"
69
+
70
+ host_param "#{Socket.gethostname}" # host_param is actual hostname like `webserver1`.
71
+
72
+ str_param "foo\nbar" # \n is interpreted as actual LF character
@@ -0,0 +1,114 @@
1
+ require "rouge"
2
+
3
+ module Rouge
4
+ module Lexers
5
+ class Fluentd < RegexLexer
6
+ title "Fluentd"
7
+ desc "configuration files for Fluentd"
8
+ tag "fluentd"
9
+ filenames "fluent.conf", "td-agent.conf"
10
+
11
+ state :whitespace do
12
+ rule /\#.*/, Comment
13
+ rule /\s+/m, Text
14
+ end
15
+
16
+ state :root do
17
+ mixin :whitespace
18
+
19
+ rule /(<\/?)(\w+)/ do
20
+ groups Punctuation, Name::Label
21
+ push :section
22
+ end
23
+
24
+ rule /@\w+/ do
25
+ token Name::Builtin
26
+ push :directive
27
+ end
28
+
29
+ rule /\w+/ do
30
+ token Name::Class
31
+ push :directive
32
+ end
33
+ end
34
+
35
+ # @todo recognize tag with dots as separator
36
+ # @todo recognize label
37
+ state :section do
38
+ rule /([^>]+)?(>(?:\r\n?|\n)?)/ do
39
+ groups Literal::String::Regex, Punctuation
40
+ pop!
41
+ end
42
+
43
+ mixin :whitespace
44
+ end
45
+
46
+ # @todo embedded Ruby code
47
+ state :directive do
48
+ rule /\r\n?|\n/, Text, :pop!
49
+
50
+ mixin :whitespace
51
+
52
+ rule /"/ do
53
+ token Str::Double
54
+ push :double_quoted_string
55
+ end
56
+
57
+ rule /'/ do
58
+ token Str::Single
59
+ push :single_quoted_string
60
+ end
61
+
62
+ rule /\[/ do
63
+ token Punctuation
64
+ push :array
65
+ end
66
+
67
+ rule /\{/ do
68
+ token Punctuation
69
+ push :hash
70
+ end
71
+
72
+ rule /\S+/ do
73
+ token Literal::String::Symbol
74
+ end
75
+ end
76
+
77
+ # @todo don't break at escaped double quote
78
+ state :double_quoted_string do
79
+ rule /([^\"]*)(\")/ do
80
+ groups Literal::String::Symbol, Str::Double
81
+ pop!
82
+ end
83
+ end
84
+
85
+ # @todo don't break at escaped single quote
86
+ state :single_quoted_string do
87
+ rule /([^\']*)(\')/ do
88
+ groups Literal::String::Symbol, Str::Single
89
+ pop!
90
+ end
91
+ end
92
+
93
+ # @todo don't escape at escaped or in-string closing bracket
94
+ state :array do
95
+ mixin :whitespace
96
+
97
+ rule /\]/, Punctuation, :pop!
98
+ rule /\S+/ do
99
+ token Literal::String::Symbol
100
+ end
101
+ end
102
+
103
+ # @todo don't escape at escaped or in-string closing brace
104
+ state :hash do
105
+ mixin :whitespace
106
+
107
+ rule /}/, Punctuation, :pop!
108
+ rule /\S+/ do
109
+ token Literal::String::Symbol
110
+ end
111
+ end
112
+ end
113
+ end
114
+ end
@@ -0,0 +1,38 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "rouge-lexers-fluentd"
8
+ gem.version = "0.1.0"
9
+ gem.summary = %q{Rouge lexer for fluentd configuration files}
10
+ gem.description = %q{Rouge lexer for fluentd configuration files}
11
+ gem.license = "MIT"
12
+ gem.authors = ["KITAITI Makoto"]
13
+ gem.email = "KitaitiMakoto@gmail.com"
14
+ gem.homepage = "https://rubygems.org/gems/rouge-lexers-fluentd"
15
+
16
+ gem.files = `git ls-files`.split($/)
17
+
18
+ `git submodule --quiet foreach --recursive pwd`.split($/).each do |submodule|
19
+ submodule.sub!("#{Dir.pwd}/",'')
20
+
21
+ Dir.chdir(submodule) do
22
+ `git ls-files`.split($/).map do |subpath|
23
+ gem.files << File.join(submodule,subpath)
24
+ end
25
+ end
26
+ end
27
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
28
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
29
+ gem.require_paths = ['lib']
30
+
31
+ gem.add_runtime_dependency 'rouge', '~> 1.11'
32
+ gem.add_development_dependency 'test-unit', '~> 3'
33
+ gem.add_development_dependency 'test-unit-notify', '~> 1'
34
+ gem.add_development_dependency 'bundler', '~> 1.10'
35
+ gem.add_development_dependency 'rake', '~> 10.0'
36
+ gem.add_development_dependency 'rubygems-tasks', '~> 0.2'
37
+ gem.add_development_dependency 'yard', '~> 0.8'
38
+ end
@@ -0,0 +1,468 @@
1
+ ---
2
+ - - Comment
3
+ - "# Receive events from 24224/tcp"
4
+ - - Text
5
+ - "\n"
6
+ - - Comment
7
+ - "# This is used by log forwarding and the fluent-cat command"
8
+ - - Text
9
+ - "\n"
10
+ - - Punctuation
11
+ - "<"
12
+ - - Name.Label
13
+ - source
14
+ - - Punctuation
15
+ - ">\n"
16
+ - - Text
17
+ - " "
18
+ - - Name.Builtin
19
+ - "@type"
20
+ - - Text
21
+ - " "
22
+ - - Literal.String.Symbol
23
+ - forward
24
+ - - Text
25
+ - "\n "
26
+ - - Name.Class
27
+ - port
28
+ - - Text
29
+ - " "
30
+ - - Literal.String.Symbol
31
+ - '24224'
32
+ - - Text
33
+ - "\n"
34
+ - - Punctuation
35
+ - "</"
36
+ - - Name.Label
37
+ - source
38
+ - - Punctuation
39
+ - ">\n"
40
+ - - Text
41
+ - "\n"
42
+ - - Comment
43
+ - '# http://this.host:9880/myapp.access?json={"event":"data"}'
44
+ - - Text
45
+ - "\n"
46
+ - - Punctuation
47
+ - "<"
48
+ - - Name.Label
49
+ - source
50
+ - - Punctuation
51
+ - ">\n"
52
+ - - Text
53
+ - " "
54
+ - - Name.Builtin
55
+ - "@type"
56
+ - - Text
57
+ - " "
58
+ - - Literal.String.Symbol
59
+ - http
60
+ - - Text
61
+ - "\n "
62
+ - - Name.Class
63
+ - port
64
+ - - Text
65
+ - " "
66
+ - - Literal.String.Symbol
67
+ - '9880'
68
+ - - Text
69
+ - "\n"
70
+ - - Punctuation
71
+ - "</"
72
+ - - Name.Label
73
+ - source
74
+ - - Punctuation
75
+ - ">\n"
76
+ - - Text
77
+ - "\n"
78
+ - - Punctuation
79
+ - "<"
80
+ - - Name.Label
81
+ - source
82
+ - - Punctuation
83
+ - ">\n"
84
+ - - Text
85
+ - " "
86
+ - - Name.Builtin
87
+ - "@type"
88
+ - - Text
89
+ - " "
90
+ - - Literal.String.Symbol
91
+ - tail
92
+ - - Text
93
+ - "\n "
94
+ - - Name.Builtin
95
+ - "@label"
96
+ - - Text
97
+ - " "
98
+ - - Literal.String.Symbol
99
+ - "@SYSTEM"
100
+ - - Text
101
+ - "\n"
102
+ - - Punctuation
103
+ - "</"
104
+ - - Name.Label
105
+ - source
106
+ - - Punctuation
107
+ - ">\n"
108
+ - - Text
109
+ - "\n"
110
+ - - Punctuation
111
+ - "<"
112
+ - - Name.Label
113
+ - label
114
+ - - Literal.String.Regex
115
+ - " @SYSTEM"
116
+ - - Punctuation
117
+ - ">\n"
118
+ - - Text
119
+ - " "
120
+ - - Punctuation
121
+ - "<"
122
+ - - Name.Label
123
+ - filter
124
+ - - Literal.String.Regex
125
+ - " var.log.middleware.**"
126
+ - - Punctuation
127
+ - ">\n"
128
+ - - Text
129
+ - " "
130
+ - - Name.Builtin
131
+ - "@type"
132
+ - - Text
133
+ - " "
134
+ - - Literal.String.Symbol
135
+ - grep
136
+ - - Text
137
+ - "\n "
138
+ - - Comment
139
+ - "# ..."
140
+ - - Text
141
+ - "\n "
142
+ - - Punctuation
143
+ - "</"
144
+ - - Name.Label
145
+ - filter
146
+ - - Punctuation
147
+ - ">\n"
148
+ - - Text
149
+ - " "
150
+ - - Punctuation
151
+ - "<"
152
+ - - Name.Label
153
+ - match
154
+ - - Literal.String.Regex
155
+ - " **"
156
+ - - Punctuation
157
+ - ">\n"
158
+ - - Text
159
+ - " "
160
+ - - Name.Builtin
161
+ - "@type"
162
+ - - Text
163
+ - " "
164
+ - - Literal.String.Symbol
165
+ - s3
166
+ - - Text
167
+ - "\n "
168
+ - - Comment
169
+ - "# ..."
170
+ - - Text
171
+ - "\n "
172
+ - - Punctuation
173
+ - "</"
174
+ - - Name.Label
175
+ - match
176
+ - - Punctuation
177
+ - |-
178
+ >
179
+ </
180
+ - - Name.Label
181
+ - label
182
+ - - Punctuation
183
+ - ">\n"
184
+ - - Text
185
+ - "\n"
186
+ - - Punctuation
187
+ - "<"
188
+ - - Name.Label
189
+ - filter
190
+ - - Literal.String.Regex
191
+ - " myapp.access"
192
+ - - Punctuation
193
+ - ">\n"
194
+ - - Text
195
+ - " "
196
+ - - Name.Builtin
197
+ - "@type"
198
+ - - Text
199
+ - " "
200
+ - - Literal.String.Symbol
201
+ - record_transformer
202
+ - - Text
203
+ - "\n "
204
+ - - Punctuation
205
+ - "<"
206
+ - - Name.Label
207
+ - record
208
+ - - Punctuation
209
+ - ">\n"
210
+ - - Text
211
+ - " "
212
+ - - Name.Class
213
+ - host_param
214
+ - - Text
215
+ - " "
216
+ - - Literal.String.Double
217
+ - "\""
218
+ - - Literal.String.Symbol
219
+ - "#{Socket.gethostname}"
220
+ - - Literal.String.Double
221
+ - "\""
222
+ - - Text
223
+ - "\n "
224
+ - - Punctuation
225
+ - "</"
226
+ - - Name.Label
227
+ - record
228
+ - - Punctuation
229
+ - |-
230
+ >
231
+ </
232
+ - - Name.Label
233
+ - filter
234
+ - - Punctuation
235
+ - ">\n"
236
+ - - Text
237
+ - "\n"
238
+ - - Comment
239
+ - '# Match events tagged with "myapp.access" and'
240
+ - - Text
241
+ - "\n"
242
+ - - Comment
243
+ - "# store them to /var/log/fluent/access.%Y-%m-%d"
244
+ - - Text
245
+ - "\n"
246
+ - - Comment
247
+ - "# Of course, you can control how you partition your data"
248
+ - - Text
249
+ - "\n"
250
+ - - Comment
251
+ - "# with the time_slice_format option."
252
+ - - Text
253
+ - "\n"
254
+ - - Punctuation
255
+ - "<"
256
+ - - Name.Label
257
+ - match
258
+ - - Literal.String.Regex
259
+ - " myapp.access"
260
+ - - Punctuation
261
+ - ">\n"
262
+ - - Text
263
+ - " "
264
+ - - Name.Builtin
265
+ - "@type"
266
+ - - Text
267
+ - " "
268
+ - - Literal.String.Symbol
269
+ - file
270
+ - - Text
271
+ - "\n "
272
+ - - Name.Class
273
+ - path
274
+ - - Text
275
+ - " "
276
+ - - Literal.String.Symbol
277
+ - "/var/log/fluent/access"
278
+ - - Text
279
+ - "\n"
280
+ - - Punctuation
281
+ - "</"
282
+ - - Name.Label
283
+ - match
284
+ - - Punctuation
285
+ - ">\n"
286
+ - - Text
287
+ - "\n"
288
+ - - Comment
289
+ - "# Include config files in the ./config.d directory"
290
+ - - Text
291
+ - "\n"
292
+ - - Name.Builtin
293
+ - "@include"
294
+ - - Text
295
+ - " "
296
+ - - Literal.String.Symbol
297
+ - config.d/*.conf
298
+ - - Text
299
+ - "\n\n"
300
+ - - Name.Class
301
+ - array_param
302
+ - - Text
303
+ - " "
304
+ - - Punctuation
305
+ - "["
306
+ - - Text
307
+ - "\n "
308
+ - - Literal.String.Symbol
309
+ - '"a",'
310
+ - - Text
311
+ - " "
312
+ - - Literal.String.Symbol
313
+ - '"b"'
314
+ - - Text
315
+ - "\n"
316
+ - - Punctuation
317
+ - "]"
318
+ - - Text
319
+ - "\n"
320
+ - - Name.Class
321
+ - hash_param
322
+ - - Text
323
+ - " "
324
+ - - Punctuation
325
+ - "{"
326
+ - - Text
327
+ - "\n "
328
+ - - Literal.String.Symbol
329
+ - '"k":"v",'
330
+ - - Text
331
+ - "\n "
332
+ - - Literal.String.Symbol
333
+ - '"k1":10'
334
+ - - Text
335
+ - "\n"
336
+ - - Punctuation
337
+ - "}"
338
+ - - Text
339
+ - "\n\n"
340
+ - - Punctuation
341
+ - "<"
342
+ - - Name.Label
343
+ - match
344
+ - - Literal.String.Regex
345
+ - " **"
346
+ - - Punctuation
347
+ - ">\n"
348
+ - - Text
349
+ - " "
350
+ - - Name.Builtin
351
+ - "@type"
352
+ - - Text
353
+ - " "
354
+ - - Literal.String.Symbol
355
+ - mail
356
+ - - Text
357
+ - "\n "
358
+ - - Name.Class
359
+ - subject
360
+ - - Text
361
+ - " "
362
+ - - Literal.String.Double
363
+ - "\""
364
+ - - Literal.String.Symbol
365
+ - "[CRITICAL] foo's alert system"
366
+ - - Literal.String.Double
367
+ - "\""
368
+ - - Text
369
+ - "\n"
370
+ - - Punctuation
371
+ - "</"
372
+ - - Name.Label
373
+ - match
374
+ - - Punctuation
375
+ - ">\n"
376
+ - - Text
377
+ - "\n"
378
+ - - Punctuation
379
+ - "<"
380
+ - - Name.Label
381
+ - match
382
+ - - Literal.String.Regex
383
+ - " tag"
384
+ - - Punctuation
385
+ - ">\n"
386
+ - - Text
387
+ - " "
388
+ - - Name.Builtin
389
+ - "@type"
390
+ - - Text
391
+ - " "
392
+ - - Literal.String.Symbol
393
+ - map
394
+ - - Text
395
+ - "\n "
396
+ - - Name.Class
397
+ - map
398
+ - - Text
399
+ - " "
400
+ - - Literal.String.Single
401
+ - "'"
402
+ - - Literal.String.Symbol
403
+ - '[["code." + tag, time, { "code" => record["code"].to_i}], ["time." + tag, time,
404
+ { "time" => record["time"].to_i}]]'
405
+ - - Literal.String.Single
406
+ - "'"
407
+ - - Text
408
+ - "\n "
409
+ - - Name.Class
410
+ - multi
411
+ - - Text
412
+ - " "
413
+ - - Literal.String.Symbol
414
+ - 'true'
415
+ - - Text
416
+ - "\n"
417
+ - - Punctuation
418
+ - "</"
419
+ - - Name.Label
420
+ - match
421
+ - - Punctuation
422
+ - ">\n"
423
+ - - Text
424
+ - "\n"
425
+ - - Name.Class
426
+ - str_param
427
+ - - Text
428
+ - " "
429
+ - - Literal.String.Double
430
+ - "\""
431
+ - - Literal.String.Symbol
432
+ - foo
433
+ - - Literal.String.Double
434
+ - "\""
435
+ - - Text
436
+ - "\n\n"
437
+ - - Name.Class
438
+ - host_param
439
+ - - Text
440
+ - " "
441
+ - - Literal.String.Double
442
+ - "\""
443
+ - - Literal.String.Symbol
444
+ - "#{Socket.gethostname}"
445
+ - - Literal.String.Double
446
+ - "\""
447
+ - - Text
448
+ - " "
449
+ - - Comment
450
+ - "# host_param is actual hostname like `webserver1`."
451
+ - - Text
452
+ - "\n\n"
453
+ - - Name.Class
454
+ - str_param
455
+ - - Text
456
+ - " "
457
+ - - Literal.String.Double
458
+ - "\""
459
+ - - Literal.String.Symbol
460
+ - foo\nbar
461
+ - - Literal.String.Double
462
+ - "\""
463
+ - - Text
464
+ - " "
465
+ - - Comment
466
+ - "# \\n is interpreted as actual LF character"
467
+ - - Text
468
+ - "\n"
data/test/helper.rb ADDED
@@ -0,0 +1,13 @@
1
+ require 'rubygems'
2
+
3
+ begin
4
+ require 'bundler/setup'
5
+ rescue LoadError => error
6
+ abort error.message
7
+ end
8
+
9
+ require 'test/unit'
10
+ require 'test/unit/notify'
11
+
12
+ class Test::Unit::TestCase
13
+ end
@@ -0,0 +1,25 @@
1
+ require 'helper'
2
+ require 'rouge/lexers/fluentd'
3
+
4
+ class TestRougeLexersFluentd < Test::Unit::TestCase
5
+ def setup
6
+ @lexer = Rouge::Lexers::Fluentd.new(debug: ENV['ROUGE_DEBUG'])
7
+ @demo = File.read(File.join(__dir__, '../lib/rouge/demos/fluentd'))
8
+ @demo_stack = YAML.load(File.read(File.join(__dir__, 'demo-stack.yaml')))
9
+ end
10
+
11
+ data("fluent.conf", "fluent.conf")
12
+ data("td-agent.conf", "td-agent.conf")
13
+ def test_guess(filename)
14
+ actual = Rouge::Lexer.guess(filename: filename)
15
+ assert_equal Rouge::Lexers::Fluentd, actual
16
+ end
17
+
18
+ def test_lex
19
+ tokens = @lexer.lex(@demo)
20
+ stack = tokens.collect {|token, value|
21
+ [token.qualname, value]
22
+ }
23
+ assert_equal @demo_stack, stack
24
+ end
25
+ end
metadata ADDED
@@ -0,0 +1,158 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rouge-lexers-fluentd
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - KITAITI Makoto
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-06-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rouge
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.11'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: test-unit
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: test-unit-notify
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.10'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.10'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubygems-tasks
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.2'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.2'
97
+ - !ruby/object:Gem::Dependency
98
+ name: yard
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.8'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.8'
111
+ description: Rouge lexer for fluentd configuration files
112
+ email: KitaitiMakoto@gmail.com
113
+ executables: []
114
+ extensions: []
115
+ extra_rdoc_files: []
116
+ files:
117
+ - ".document"
118
+ - ".gitignore"
119
+ - ".yardopts"
120
+ - ChangeLog.md
121
+ - Gemfile
122
+ - LICENSE.txt
123
+ - README.md
124
+ - Rakefile
125
+ - lib/rouge/demos/fluentd
126
+ - lib/rouge/lexers/fluentd.rb
127
+ - rouge-lexers-fluentd.gemspec
128
+ - test/demo-stack.yaml
129
+ - test/helper.rb
130
+ - test/test_rouge-lexers-fluentd.rb
131
+ homepage: https://rubygems.org/gems/rouge-lexers-fluentd
132
+ licenses:
133
+ - MIT
134
+ metadata: {}
135
+ post_install_message:
136
+ rdoc_options: []
137
+ require_paths:
138
+ - lib
139
+ required_ruby_version: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ required_rubygems_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ requirements: []
150
+ rubyforge_project:
151
+ rubygems_version: 2.5.1
152
+ signing_key:
153
+ specification_version: 4
154
+ summary: Rouge lexer for fluentd configuration files
155
+ test_files:
156
+ - test/demo-stack.yaml
157
+ - test/helper.rb
158
+ - test/test_rouge-lexers-fluentd.rb