json_color 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 33eb2ea4766cb2cb732fb57ba8591af15f5aa9dc
4
+ data.tar.gz: ebe68492ce9015de5730cf26279804f029649e08
5
+ SHA512:
6
+ metadata.gz: ce8609e361488a133a27ca5b2c951630ee866555a4cad741d73827f135f10bf3d58f90580954e6bf2dd80545bc5ab0fd87b6088a2ba65ab96bcb21826afad3dd
7
+ data.tar.gz: 4ae2b5c1a48d89df934a56f84bba77bdef750fdb5c3d0120c9db3f18712d6c89b611891d9bd08fa2170803488160d77ca444f3522d236fdfc2d644721ebdd7ce
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ test.rb
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --require spec_helper
2
+ --colour
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in json_colorizer.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Genki Sugawara
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,66 @@
1
+ # json_color
2
+
3
+ It is a library to colorize JSON.
4
+
5
+ [![Gem Version](https://badge.fury.io/rb/json_color.png)](http://badge.fury.io/rb/json_color)
6
+ [![Build Status](https://drone.io/bitbucket.org/winebarrel/json_color/status.png)](https://drone.io/bitbucket.org/winebarrel/json_color/latest)
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ gem 'json_color'
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install json_color
21
+
22
+ ## Usage
23
+
24
+ ```ruby
25
+ require 'json_color'
26
+
27
+ puts JsonColor.colorize(<<-EOS)
28
+ {
29
+ "glossary": {
30
+ "title": "example glossary",
31
+ "GlossDiv": {
32
+ "title": "S",
33
+ "GlossList": {
34
+ "GlossEntry": {
35
+ "ID": "SGML",
36
+ "SortAs": "SGML",
37
+ "GlossTerm": "Standard Generalized Markup Language",
38
+ "Acronym": "SGML",
39
+ "Abbrev": "ISO 8879:1986",
40
+ "GlossDef": {
41
+ "para": "A meta-markup language, used to create markup languages such as DocBook.",
42
+ "GlossSeeAlso": ["GML", "XML"]
43
+ },
44
+ "GlossSee": "markup"
45
+ }
46
+ }
47
+ }
48
+ }
49
+ }
50
+ EOS
51
+ ```
52
+
53
+ ![Screenshot](https://bitbucket.org/winebarrel/json_color/downloads/screenshot.png)
54
+
55
+ # Default color map
56
+
57
+ ```ruby
58
+ module JsonColor
59
+ DEFAULT_COLOR_MAP = {
60
+ :key => :intense_blue,
61
+ :string => :green,
62
+ :null => :intense_black,
63
+ }
64
+ ...
65
+ end
66
+ ```
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new('spec')
5
+
6
+ task :default => :spec
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'json_color/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'json_color'
8
+ spec.version = JsonColor::VERSION
9
+ spec.authors = ['Genki Sugawara']
10
+ spec.email = ['sgwr_dts@yahoo.co.jp']
11
+ spec.summary = %q{It is a library to colorize JSON.}
12
+ spec.description = %q{It is a library to colorize JSON.}
13
+ spec.homepage = 'https://bitbucket.org/winebarrel/json_color'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_dependency 'term-ansicolor'
22
+ spec.add_development_dependency 'bundler'
23
+ spec.add_development_dependency 'rake'
24
+ spec.add_development_dependency 'rspec', '>= 2.11.0'
25
+ end
@@ -0,0 +1,17 @@
1
+ require 'strscan'
2
+ require 'term/ansicolor'
3
+
4
+ require 'json_color/version'
5
+ require 'json_color/parser.tab'
6
+
7
+ module JsonColor
8
+ DEFAULT_COLOR_MAP = {
9
+ :key => :intense_blue,
10
+ :string => :green,
11
+ :null => :intense_black,
12
+ }
13
+
14
+ def self.colorize(src, color_map = nil)
15
+ JsonColor::Parser.parse(src, color_map || DEFAULT_COLOR_MAP)
16
+ end
17
+ end
@@ -0,0 +1,123 @@
1
+ class Parser
2
+ options no_result_var
3
+ rule
4
+ json_text : ws object ws
5
+ { val.flatten.join }
6
+ | ws array ws
7
+ { val.flatten.join }
8
+
9
+ ws :
10
+ { val.flatten.join }
11
+ | ws SPACE
12
+ { val.flatten.join }
13
+
14
+ value : FALSE
15
+ { colorize(val[0], :false, :bool) }
16
+ | NULL
17
+ { colorize(val[0], :null) }
18
+ | TRUE
19
+ { colorize(val[0], :true, :bool) }
20
+ | object
21
+ { val.flatten.join }
22
+ | array
23
+ { val.flatten.join }
24
+ | NUMBER
25
+ { colorize(val[0], :number) }
26
+ | STRING
27
+ { colorize(val[0], :string) }
28
+
29
+ object : '{' ws '}'
30
+ { val.flatten.join }
31
+ | '{' ws members ws '}'
32
+ { val.flatten.join }
33
+
34
+ members : member
35
+ { val.flatten.join }
36
+ | members ws ',' ws member
37
+ { val.flatten.join }
38
+
39
+ member : STRING ws ':' ws value
40
+ {
41
+ val[0] = colorize(val[0], :key, :string)
42
+ val.flatten.join
43
+ }
44
+
45
+ array : '[' ws ']'
46
+ { val.flatten.join }
47
+ | '[' ws values ws ']'
48
+ { val.flatten.join }
49
+
50
+ values : value
51
+ { val.flatten.join }
52
+ | values ws ',' ws value
53
+ { val.flatten.join }
54
+ end
55
+
56
+ ---- header
57
+
58
+ module JsonColor
59
+
60
+ ---- footer
61
+
62
+ end # JsonColor
63
+
64
+ ---- inner
65
+
66
+ R_SPACE = /\A[ \t\n\r]+/
67
+ R_RESERVED = /\A[\{\}\[\],:]/
68
+ R_NUMBER = /\A-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][-+]?\d+)?/
69
+ R_STRING = /\A"(?:\\["\\\/bfnrt]|\\u[\dA-Za-z]{4}|[^\\"])*"/
70
+ R_FALSE = /\Afalse/
71
+ R_NULL = /\Anull/
72
+ R_TRUE = /\Atrue/
73
+
74
+ def self.parse(src, color_map)
75
+ self.new(src, color_map).parse
76
+ end
77
+
78
+ def initialize(src, color_map)
79
+ @ss = StringScanner.new(src)
80
+ @color_map = color_map
81
+ end
82
+
83
+ def scan
84
+ tok = nil
85
+
86
+ until @ss.eos?
87
+ if (tok = @ss.scan R_SPACE)
88
+ yield [:SPACE, tok]
89
+ elsif (tok = @ss.scan R_RESERVED)
90
+ yield [tok, tok]
91
+ elsif (tok = @ss.scan R_NUMBER)
92
+ yield [:NUMBER, tok]
93
+ elsif (tok = @ss.scan R_STRING)
94
+ yield [:STRING, tok]
95
+ elsif (tok = @ss.scan R_FALSE)
96
+ yield [:FALSE, tok]
97
+ elsif (tok = @ss.scan R_NULL)
98
+ yield [:NULL, tok]
99
+ elsif (tok = @ss.scan R_TRUE)
100
+ yield [:TRUE, tok]
101
+ else
102
+ raise Racc::ParseError, ('parse error on value "%s"' % @ss.rest.inspect)
103
+ end
104
+ end
105
+
106
+ yield [false, '$']
107
+ end
108
+
109
+ def parse
110
+ yyparse self, :scan
111
+ end
112
+
113
+ def colorize(str, *types)
114
+ types.each do |t|
115
+ color = @color_map[t]
116
+
117
+ if color
118
+ return Term::ANSIColor.send(color, str)
119
+ end
120
+ end
121
+
122
+ return str
123
+ end
@@ -0,0 +1,347 @@
1
+ #
2
+ # DO NOT MODIFY!!!!
3
+ # This file is automatically generated by Racc 1.4.11
4
+ # from Racc grammer file "".
5
+ #
6
+
7
+ require 'racc/parser.rb'
8
+
9
+
10
+ module JsonColor
11
+
12
+ class Parser < Racc::Parser
13
+
14
+ module_eval(<<'...end parser.rb/module_eval...', 'parser.rb', 65)
15
+
16
+ R_SPACE = /\A[ \t\n\r]+/
17
+ R_RESERVED = /\A[\{\}\[\],:]/
18
+ R_NUMBER = /\A-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][-+]?\d+)?/
19
+ R_STRING = /\A"(?:\\["\\\/bfnrt]|\\u[\dA-Za-z]{4}|[^\\"])*"/
20
+ R_FALSE = /\Afalse/
21
+ R_NULL = /\Anull/
22
+ R_TRUE = /\Atrue/
23
+
24
+ def self.parse(src, color_map)
25
+ self.new(src, color_map).parse
26
+ end
27
+
28
+ def initialize(src, color_map)
29
+ @ss = StringScanner.new(src)
30
+ @color_map = color_map
31
+ end
32
+
33
+ def scan
34
+ tok = nil
35
+
36
+ until @ss.eos?
37
+ if (tok = @ss.scan R_SPACE)
38
+ yield [:SPACE, tok]
39
+ elsif (tok = @ss.scan R_RESERVED)
40
+ yield [tok, tok]
41
+ elsif (tok = @ss.scan R_NUMBER)
42
+ yield [:NUMBER, tok]
43
+ elsif (tok = @ss.scan R_STRING)
44
+ yield [:STRING, tok]
45
+ elsif (tok = @ss.scan R_FALSE)
46
+ yield [:FALSE, tok]
47
+ elsif (tok = @ss.scan R_NULL)
48
+ yield [:NULL, tok]
49
+ elsif (tok = @ss.scan R_TRUE)
50
+ yield [:TRUE, tok]
51
+ else
52
+ raise Racc::ParseError, ('parse error on value "%s"' % @ss.rest.inspect)
53
+ end
54
+ end
55
+
56
+ yield [false, '$']
57
+ end
58
+
59
+ def parse
60
+ yyparse self, :scan
61
+ end
62
+
63
+ def colorize(str, *types)
64
+ types.each do |t|
65
+ color = @color_map[t]
66
+
67
+ if color
68
+ return Term::ANSIColor.send(color, str)
69
+ end
70
+ end
71
+
72
+ return str
73
+ end
74
+ ...end parser.rb/module_eval...
75
+ ##### State transition tables begin ###
76
+
77
+ racc_action_table = [
78
+ 6, 18, 19, 20, 23, 24, 7, 6, 6, 6,
79
+ 8, 25, 6, 6, 6, 35, 9, 33, 34, 7,
80
+ 3, 31, 32, 8, 6, 18, 19, 20, 23, 24,
81
+ 7, nil, nil, nil, 8, 6, 18, 19, 20, 23,
82
+ 24, 7, 6, 6, nil, 8, nil, 17, 17, 14 ]
83
+
84
+ racc_action_check = [
85
+ 13, 13, 13, 13, 13, 13, 13, 30, 29, 10,
86
+ 13, 13, 11, 2, 28, 30, 3, 29, 30, 2,
87
+ 1, 28, 28, 2, 37, 37, 37, 37, 37, 37,
88
+ 37, nil, nil, nil, 37, 38, 38, 38, 38, 38,
89
+ 38, 38, 12, 36, nil, 38, nil, 12, 36, 12 ]
90
+
91
+ racc_action_pointer = [
92
+ nil, 20, 11, 16, nil, nil, nil, nil, nil, nil,
93
+ 7, 10, 40, -2, nil, nil, nil, nil, nil, nil,
94
+ nil, nil, nil, nil, nil, nil, nil, nil, 12, 6,
95
+ 5, nil, nil, nil, nil, nil, 41, 22, 33, nil,
96
+ nil, nil ]
97
+
98
+ racc_action_default = [
99
+ -3, -21, -21, -21, -3, -3, -4, -3, -3, 42,
100
+ -1, -2, -21, -21, -12, -3, -14, -3, -5, -6,
101
+ -7, -8, -9, -10, -11, -17, -3, -19, -21, -21,
102
+ -21, -13, -3, -3, -18, -3, -21, -21, -21, -15,
103
+ -16, -20 ]
104
+
105
+ racc_goto_table = [
106
+ 2, 16, 1, 27, 10, 11, 5, 12, 13, 15,
107
+ 4, 26, nil, nil, nil, 28, nil, 29, nil, nil,
108
+ nil, nil, nil, nil, nil, 39, 30, 40, 41, nil,
109
+ nil, nil, 36, 37, nil, 38 ]
110
+
111
+ racc_goto_check = [
112
+ 2, 7, 1, 5, 2, 2, 4, 2, 2, 6,
113
+ 3, 8, nil, nil, nil, 2, nil, 2, nil, nil,
114
+ nil, nil, nil, nil, nil, 7, 2, 5, 5, nil,
115
+ nil, nil, 2, 2, nil, 2 ]
116
+
117
+ racc_goto_pointer = [
118
+ nil, 2, 0, 8, 4, -10, -3, -11, -2 ]
119
+
120
+ racc_goto_default = [
121
+ nil, nil, nil, 21, 22, nil, nil, nil, nil ]
122
+
123
+ racc_reduce_table = [
124
+ 0, 0, :racc_error,
125
+ 3, 15, :_reduce_1,
126
+ 3, 15, :_reduce_2,
127
+ 0, 16, :_reduce_3,
128
+ 2, 16, :_reduce_4,
129
+ 1, 19, :_reduce_5,
130
+ 1, 19, :_reduce_6,
131
+ 1, 19, :_reduce_7,
132
+ 1, 19, :_reduce_8,
133
+ 1, 19, :_reduce_9,
134
+ 1, 19, :_reduce_10,
135
+ 1, 19, :_reduce_11,
136
+ 3, 17, :_reduce_12,
137
+ 5, 17, :_reduce_13,
138
+ 1, 20, :_reduce_14,
139
+ 5, 20, :_reduce_15,
140
+ 5, 21, :_reduce_16,
141
+ 3, 18, :_reduce_17,
142
+ 5, 18, :_reduce_18,
143
+ 1, 22, :_reduce_19,
144
+ 5, 22, :_reduce_20 ]
145
+
146
+ racc_reduce_n = 21
147
+
148
+ racc_shift_n = 42
149
+
150
+ racc_token_table = {
151
+ false => 0,
152
+ :error => 1,
153
+ :SPACE => 2,
154
+ :FALSE => 3,
155
+ :NULL => 4,
156
+ :TRUE => 5,
157
+ :NUMBER => 6,
158
+ :STRING => 7,
159
+ "{" => 8,
160
+ "}" => 9,
161
+ "," => 10,
162
+ ":" => 11,
163
+ "[" => 12,
164
+ "]" => 13 }
165
+
166
+ racc_nt_base = 14
167
+
168
+ racc_use_result_var = false
169
+
170
+ Racc_arg = [
171
+ racc_action_table,
172
+ racc_action_check,
173
+ racc_action_default,
174
+ racc_action_pointer,
175
+ racc_goto_table,
176
+ racc_goto_check,
177
+ racc_goto_default,
178
+ racc_goto_pointer,
179
+ racc_nt_base,
180
+ racc_reduce_table,
181
+ racc_token_table,
182
+ racc_shift_n,
183
+ racc_reduce_n,
184
+ racc_use_result_var ]
185
+
186
+ Racc_token_to_s_table = [
187
+ "$end",
188
+ "error",
189
+ "SPACE",
190
+ "FALSE",
191
+ "NULL",
192
+ "TRUE",
193
+ "NUMBER",
194
+ "STRING",
195
+ "\"{\"",
196
+ "\"}\"",
197
+ "\",\"",
198
+ "\":\"",
199
+ "\"[\"",
200
+ "\"]\"",
201
+ "$start",
202
+ "json_text",
203
+ "ws",
204
+ "object",
205
+ "array",
206
+ "value",
207
+ "members",
208
+ "member",
209
+ "values" ]
210
+
211
+ Racc_debug_parser = false
212
+
213
+ ##### State transition tables end #####
214
+
215
+ # reduce 0 omitted
216
+
217
+ module_eval(<<'.,.,', 'parser.rb', 4)
218
+ def _reduce_1(val, _values)
219
+ val.flatten.join
220
+ end
221
+ .,.,
222
+
223
+ module_eval(<<'.,.,', 'parser.rb', 6)
224
+ def _reduce_2(val, _values)
225
+ val.flatten.join
226
+ end
227
+ .,.,
228
+
229
+ module_eval(<<'.,.,', 'parser.rb', 9)
230
+ def _reduce_3(val, _values)
231
+ val.flatten.join
232
+ end
233
+ .,.,
234
+
235
+ module_eval(<<'.,.,', 'parser.rb', 11)
236
+ def _reduce_4(val, _values)
237
+ val.flatten.join
238
+ end
239
+ .,.,
240
+
241
+ module_eval(<<'.,.,', 'parser.rb', 14)
242
+ def _reduce_5(val, _values)
243
+ colorize(val[0], :false, :bool)
244
+ end
245
+ .,.,
246
+
247
+ module_eval(<<'.,.,', 'parser.rb', 16)
248
+ def _reduce_6(val, _values)
249
+ colorize(val[0], :null)
250
+ end
251
+ .,.,
252
+
253
+ module_eval(<<'.,.,', 'parser.rb', 18)
254
+ def _reduce_7(val, _values)
255
+ colorize(val[0], :true, :bool)
256
+ end
257
+ .,.,
258
+
259
+ module_eval(<<'.,.,', 'parser.rb', 20)
260
+ def _reduce_8(val, _values)
261
+ val.flatten.join
262
+ end
263
+ .,.,
264
+
265
+ module_eval(<<'.,.,', 'parser.rb', 22)
266
+ def _reduce_9(val, _values)
267
+ val.flatten.join
268
+ end
269
+ .,.,
270
+
271
+ module_eval(<<'.,.,', 'parser.rb', 24)
272
+ def _reduce_10(val, _values)
273
+ colorize(val[0], :number)
274
+ end
275
+ .,.,
276
+
277
+ module_eval(<<'.,.,', 'parser.rb', 26)
278
+ def _reduce_11(val, _values)
279
+ colorize(val[0], :string)
280
+ end
281
+ .,.,
282
+
283
+ module_eval(<<'.,.,', 'parser.rb', 29)
284
+ def _reduce_12(val, _values)
285
+ val.flatten.join
286
+ end
287
+ .,.,
288
+
289
+ module_eval(<<'.,.,', 'parser.rb', 31)
290
+ def _reduce_13(val, _values)
291
+ val.flatten.join
292
+ end
293
+ .,.,
294
+
295
+ module_eval(<<'.,.,', 'parser.rb', 34)
296
+ def _reduce_14(val, _values)
297
+ val.flatten.join
298
+ end
299
+ .,.,
300
+
301
+ module_eval(<<'.,.,', 'parser.rb', 36)
302
+ def _reduce_15(val, _values)
303
+ val.flatten.join
304
+ end
305
+ .,.,
306
+
307
+ module_eval(<<'.,.,', 'parser.rb', 40)
308
+ def _reduce_16(val, _values)
309
+ val[0] = colorize(val[0], :key, :string)
310
+ val.flatten.join
311
+
312
+ end
313
+ .,.,
314
+
315
+ module_eval(<<'.,.,', 'parser.rb', 45)
316
+ def _reduce_17(val, _values)
317
+ val.flatten.join
318
+ end
319
+ .,.,
320
+
321
+ module_eval(<<'.,.,', 'parser.rb', 47)
322
+ def _reduce_18(val, _values)
323
+ val.flatten.join
324
+ end
325
+ .,.,
326
+
327
+ module_eval(<<'.,.,', 'parser.rb', 50)
328
+ def _reduce_19(val, _values)
329
+ val.flatten.join
330
+ end
331
+ .,.,
332
+
333
+ module_eval(<<'.,.,', 'parser.rb', 52)
334
+ def _reduce_20(val, _values)
335
+ val.flatten.join
336
+ end
337
+ .,.,
338
+
339
+ def _reduce_none(val, _values)
340
+ val[0]
341
+ end
342
+
343
+ end # class Parser
344
+
345
+
346
+ end # JsonColor
347
+
@@ -0,0 +1,3 @@
1
+ module JsonColor
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,191 @@
1
+ describe 'JsonColor' do
2
+ let(:json) do
3
+ <<-EOS
4
+ {"web-app": {
5
+ "servlet": [
6
+ {
7
+ "servlet-name": "cofaxCDS",
8
+ "servlet-class": "org.cofax.cds.CDSServlet",
9
+ "init-param": {
10
+ "configGlossary:installationAt": "Philadelphia, PA",
11
+ "configGlossary:adminEmail": "ksm@pobox.com",
12
+ "configGlossary:poweredBy": "Cofax",
13
+ "configGlossary:poweredByIcon": "/images/cofax.gif",
14
+ "configGlossary:staticPath": "/content/static",
15
+ "templateProcessorClass": "org.cofax.WysiwygTemplate",
16
+ "templateLoaderClass": "org.cofax.FilesTemplateLoader",
17
+ "templatePath": "templates",
18
+ "templateOverridePath": "",
19
+ "defaultListTemplate": "listTemplate.htm",
20
+ "defaultFileTemplate": "articleTemplate.htm",
21
+ "useJSP": false,
22
+ "jspListTemplate": "listTemplate.jsp",
23
+ "jspFileTemplate": "articleTemplate.jsp",
24
+ "cachePackageTagsTrack": 200,
25
+ "cachePackageTagsStore": 200,
26
+ "cachePackageTagsRefresh": 60,
27
+ "cacheTemplatesTrack": 100,
28
+ "cacheTemplatesStore": 50,
29
+ "cacheTemplatesRefresh": 15,
30
+ "cachePagesTrack": 200,
31
+ "cachePagesStore": 100,
32
+ "cachePagesRefresh": 10,
33
+ "cachePagesDirtyRead": 10,
34
+ "searchEngineListTemplate": "forSearchEnginesList.htm",
35
+ "searchEngineFileTemplate": "forSearchEngines.htm",
36
+ "searchEngineRobotsDb": "WEB-INF/robots.db",
37
+ "useDataStore": true,
38
+ "dataStoreClass": "org.cofax.SqlDataStore",
39
+ "redirectionClass": "org.cofax.SqlRedirection",
40
+ "dataStoreName": "cofax",
41
+ "dataStoreDriver": "com.microsoft.jdbc.sqlserver.SQLServerDriver",
42
+ "dataStoreUrl": "jdbc:microsoft:sqlserver://LOCALHOST:1433;DatabaseName=goon",
43
+ "dataStoreUser": "sa",
44
+ "dataStorePassword": "dataStoreTestQuery",
45
+ "dataStoreTestQuery": "SET NOCOUNT ON;select test='test';",
46
+ "dataStoreLogFile": "/usr/local/tomcat/logs/datastore.log",
47
+ "dataStoreInitConns": 10,
48
+ "dataStoreMaxConns": 100,
49
+ "dataStoreConnUsageLimit": 100,
50
+ "dataStoreLogLevel": "debug",
51
+ "maxUrlLength": 500,
52
+ "log": null}},
53
+ {
54
+ "servlet-name": "cofaxEmail",
55
+ "servlet-class": "org.cofax.cds.EmailServlet",
56
+ "init-param": {
57
+ "mailHost": "mail1",
58
+ "mailHostOverride": "mail2"}},
59
+ {
60
+ "servlet-name": "cofaxAdmin",
61
+ "servlet-class": "org.cofax.cds.AdminServlet"},
62
+
63
+ {
64
+ "servlet-name": "fileServlet",
65
+ "servlet-class": "org.cofax.cds.FileServlet"},
66
+ {
67
+ "servlet-name": "cofaxTools",
68
+ "servlet-class": "org.cofax.cms.CofaxToolsServlet",
69
+ "init-param": {
70
+ "templatePath": "toolstemplates/",
71
+ "log": 1,
72
+ "logLocation": "/usr/local/tomcat/logs/CofaxTools.log",
73
+ "logMaxSize": "",
74
+ "dataLog": 1,
75
+ "dataLogLocation": "/usr/local/tomcat/logs/dataLog.log",
76
+ "dataLogMaxSize": "",
77
+ "removePageCache": "/content/admin/remove?cache=pages&id=",
78
+ "removeTemplateCache": "/content/admin/remove?cache=templates&id=",
79
+ "fileTransferFolder": "/usr/local/tomcat/webapps/content/fileTransferFolder",
80
+ "lookInContext": 1,
81
+ "adminGroupID": 4,
82
+ "betaServer": true}}],
83
+ "servlet-mapping": {
84
+ "cofaxCDS": "/",
85
+ "cofaxEmail": "/cofaxutil/aemail/*",
86
+ "cofaxAdmin": "/admin/*",
87
+ "fileServlet": "/static/*",
88
+ "cofaxTools": "/tools/*"},
89
+
90
+ "taglib": {
91
+ "taglib-uri": "cofax.tld",
92
+ "taglib-location": "/WEB-INF/tlds/cofax.tld"}}}
93
+ EOS
94
+ end
95
+
96
+ it 'colorize JSON' do
97
+ colorized = JsonColor.colorize(json)
98
+
99
+ expect(colorized).to eq(<<-EOS)
100
+ {\e[94m"web-app"\e[0m: {
101
+ \e[94m"servlet"\e[0m: [
102
+ {
103
+ \e[94m"servlet-name"\e[0m: \e[32m"cofaxCDS"\e[0m,
104
+ \e[94m"servlet-class"\e[0m: \e[32m"org.cofax.cds.CDSServlet"\e[0m,
105
+ \e[94m"init-param"\e[0m: {
106
+ \e[94m"configGlossary:installationAt"\e[0m: \e[32m"Philadelphia, PA"\e[0m,
107
+ \e[94m"configGlossary:adminEmail"\e[0m: \e[32m"ksm@pobox.com"\e[0m,
108
+ \e[94m"configGlossary:poweredBy"\e[0m: \e[32m"Cofax"\e[0m,
109
+ \e[94m"configGlossary:poweredByIcon"\e[0m: \e[32m"/images/cofax.gif"\e[0m,
110
+ \e[94m"configGlossary:staticPath"\e[0m: \e[32m"/content/static"\e[0m,
111
+ \e[94m"templateProcessorClass"\e[0m: \e[32m"org.cofax.WysiwygTemplate"\e[0m,
112
+ \e[94m"templateLoaderClass"\e[0m: \e[32m"org.cofax.FilesTemplateLoader"\e[0m,
113
+ \e[94m"templatePath"\e[0m: \e[32m"templates"\e[0m,
114
+ \e[94m"templateOverridePath"\e[0m: \e[32m""\e[0m,
115
+ \e[94m"defaultListTemplate"\e[0m: \e[32m"listTemplate.htm"\e[0m,
116
+ \e[94m"defaultFileTemplate"\e[0m: \e[32m"articleTemplate.htm"\e[0m,
117
+ \e[94m"useJSP"\e[0m: false,
118
+ \e[94m"jspListTemplate"\e[0m: \e[32m"listTemplate.jsp"\e[0m,
119
+ \e[94m"jspFileTemplate"\e[0m: \e[32m"articleTemplate.jsp"\e[0m,
120
+ \e[94m"cachePackageTagsTrack"\e[0m: 200,
121
+ \e[94m"cachePackageTagsStore"\e[0m: 200,
122
+ \e[94m"cachePackageTagsRefresh"\e[0m: 60,
123
+ \e[94m"cacheTemplatesTrack"\e[0m: 100,
124
+ \e[94m"cacheTemplatesStore"\e[0m: 50,
125
+ \e[94m"cacheTemplatesRefresh"\e[0m: 15,
126
+ \e[94m"cachePagesTrack"\e[0m: 200,
127
+ \e[94m"cachePagesStore"\e[0m: 100,
128
+ \e[94m"cachePagesRefresh"\e[0m: 10,
129
+ \e[94m"cachePagesDirtyRead"\e[0m: 10,
130
+ \e[94m"searchEngineListTemplate"\e[0m: \e[32m"forSearchEnginesList.htm"\e[0m,
131
+ \e[94m"searchEngineFileTemplate"\e[0m: \e[32m"forSearchEngines.htm"\e[0m,
132
+ \e[94m"searchEngineRobotsDb"\e[0m: \e[32m"WEB-INF/robots.db"\e[0m,
133
+ \e[94m"useDataStore"\e[0m: true,
134
+ \e[94m"dataStoreClass"\e[0m: \e[32m"org.cofax.SqlDataStore"\e[0m,
135
+ \e[94m"redirectionClass"\e[0m: \e[32m"org.cofax.SqlRedirection"\e[0m,
136
+ \e[94m"dataStoreName"\e[0m: \e[32m"cofax"\e[0m,
137
+ \e[94m"dataStoreDriver"\e[0m: \e[32m"com.microsoft.jdbc.sqlserver.SQLServerDriver"\e[0m,
138
+ \e[94m"dataStoreUrl"\e[0m: \e[32m"jdbc:microsoft:sqlserver://LOCALHOST:1433;DatabaseName=goon"\e[0m,
139
+ \e[94m"dataStoreUser"\e[0m: \e[32m"sa"\e[0m,
140
+ \e[94m"dataStorePassword"\e[0m: \e[32m"dataStoreTestQuery"\e[0m,
141
+ \e[94m"dataStoreTestQuery"\e[0m: \e[32m"SET NOCOUNT ON;select test='test';"\e[0m,
142
+ \e[94m"dataStoreLogFile"\e[0m: \e[32m"/usr/local/tomcat/logs/datastore.log"\e[0m,
143
+ \e[94m"dataStoreInitConns"\e[0m: 10,
144
+ \e[94m"dataStoreMaxConns"\e[0m: 100,
145
+ \e[94m"dataStoreConnUsageLimit"\e[0m: 100,
146
+ \e[94m"dataStoreLogLevel"\e[0m: \e[32m"debug"\e[0m,
147
+ \e[94m"maxUrlLength"\e[0m: 500,
148
+ \e[94m"log"\e[0m: \e[90mnull\e[0m}},
149
+ {
150
+ \e[94m"servlet-name"\e[0m: \e[32m"cofaxEmail"\e[0m,
151
+ \e[94m"servlet-class"\e[0m: \e[32m"org.cofax.cds.EmailServlet"\e[0m,
152
+ \e[94m"init-param"\e[0m: {
153
+ \e[94m"mailHost"\e[0m: \e[32m"mail1"\e[0m,
154
+ \e[94m"mailHostOverride"\e[0m: \e[32m"mail2"\e[0m}},
155
+ {
156
+ \e[94m"servlet-name"\e[0m: \e[32m"cofaxAdmin"\e[0m,
157
+ \e[94m"servlet-class"\e[0m: \e[32m"org.cofax.cds.AdminServlet"\e[0m},
158
+
159
+ {
160
+ \e[94m"servlet-name"\e[0m: \e[32m"fileServlet"\e[0m,
161
+ \e[94m"servlet-class"\e[0m: \e[32m"org.cofax.cds.FileServlet"\e[0m},
162
+ {
163
+ \e[94m"servlet-name"\e[0m: \e[32m"cofaxTools"\e[0m,
164
+ \e[94m"servlet-class"\e[0m: \e[32m"org.cofax.cms.CofaxToolsServlet"\e[0m,
165
+ \e[94m"init-param"\e[0m: {
166
+ \e[94m"templatePath"\e[0m: \e[32m"toolstemplates/"\e[0m,
167
+ \e[94m"log"\e[0m: 1,
168
+ \e[94m"logLocation"\e[0m: \e[32m"/usr/local/tomcat/logs/CofaxTools.log"\e[0m,
169
+ \e[94m"logMaxSize"\e[0m: \e[32m""\e[0m,
170
+ \e[94m"dataLog"\e[0m: 1,
171
+ \e[94m"dataLogLocation"\e[0m: \e[32m"/usr/local/tomcat/logs/dataLog.log"\e[0m,
172
+ \e[94m"dataLogMaxSize"\e[0m: \e[32m""\e[0m,
173
+ \e[94m"removePageCache"\e[0m: \e[32m"/content/admin/remove?cache=pages&id="\e[0m,
174
+ \e[94m"removeTemplateCache"\e[0m: \e[32m"/content/admin/remove?cache=templates&id="\e[0m,
175
+ \e[94m"fileTransferFolder"\e[0m: \e[32m"/usr/local/tomcat/webapps/content/fileTransferFolder"\e[0m,
176
+ \e[94m"lookInContext"\e[0m: 1,
177
+ \e[94m"adminGroupID"\e[0m: 4,
178
+ \e[94m"betaServer"\e[0m: true}}],
179
+ \e[94m"servlet-mapping"\e[0m: {
180
+ \e[94m"cofaxCDS"\e[0m: \e[32m"/"\e[0m,
181
+ \e[94m"cofaxEmail"\e[0m: \e[32m"/cofaxutil/aemail/*"\e[0m,
182
+ \e[94m"cofaxAdmin"\e[0m: \e[32m"/admin/*"\e[0m,
183
+ \e[94m"fileServlet"\e[0m: \e[32m"/static/*"\e[0m,
184
+ \e[94m"cofaxTools"\e[0m: \e[32m"/tools/*"\e[0m},
185
+
186
+ \e[94m"taglib"\e[0m: {
187
+ \e[94m"taglib-uri"\e[0m: \e[32m"cofax.tld"\e[0m,
188
+ \e[94m"taglib-location"\e[0m: \e[32m"/WEB-INF/tlds/cofax.tld"\e[0m}}}
189
+ EOS
190
+ end
191
+ end
@@ -0,0 +1 @@
1
+ require 'json_color'
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: json_color
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Genki Sugawara
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: term-ansicolor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 2.11.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: 2.11.0
69
+ description: It is a library to colorize JSON.
70
+ email:
71
+ - sgwr_dts@yahoo.co.jp
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - .rspec
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - json_color.gemspec
83
+ - lib/json_color.rb
84
+ - lib/json_color/parser.rb
85
+ - lib/json_color/parser.tab.rb
86
+ - lib/json_color/version.rb
87
+ - spec/json_color_spec.rb
88
+ - spec/spec_helper.rb
89
+ homepage: https://bitbucket.org/winebarrel/json_color
90
+ licenses:
91
+ - MIT
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - '>='
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.0.14
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: It is a library to colorize JSON.
113
+ test_files:
114
+ - spec/json_color_spec.rb
115
+ - spec/spec_helper.rb
116
+ has_rdoc: