lazy-pp-json 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +49 -0
- data/lib/lazy/pp/json.rb +1 -1
- data/lib/lazy/pp/json/version.rb +1 -1
- data/test/testutils.rb +5 -7
- metadata +54 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 579c37d4c1e53e942bc73727cf127a6753c2844b
|
4
|
+
data.tar.gz: 29d5ac23cdcb5e494f00dbb1e9008cbdfc674f06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: deea4510434eb7e551a2c9288b64d845950e0701c005eb1d9be9658e5f9df7fb620dbb574bce939d9ef00734fc99cd33afa86bc974b5a701e189403102155cda
|
7
|
+
data.tar.gz: 023079a1b4ff69b704387c48b48282c6a734ccd9daed896aa94f095455390575ae3769a35a27e38d825ec42e133ec3d258273b898624fafe3ad636d64faab612
|
data/README.md
CHANGED
@@ -6,6 +6,55 @@
|
|
6
6
|
|
7
7
|
Lazy pp json responses.
|
8
8
|
|
9
|
+
### JSON#pretty_generate
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
example_json = "[[0,1395671860.99505,2.50339508056641e-05],{"alloc_count":136,"starttime":1395671856,"uptime":4,"version":"4.0.0","n_queries":0,"cache_hit_rate":0.0,"command_version":1,"default_command_version":1,"max_command_version":2}]"
|
13
|
+
puts JSON.pretty_generate(JSON.parse(example_json))
|
14
|
+
#=>
|
15
|
+
# [
|
16
|
+
# [
|
17
|
+
# 0,
|
18
|
+
# 1395671860.99505,
|
19
|
+
# 2.50339508056641e-05
|
20
|
+
# ],
|
21
|
+
# {
|
22
|
+
# "alloc_count": 136,
|
23
|
+
# "starttime": 1395671856,
|
24
|
+
# "uptime": 4,
|
25
|
+
# "version": "4.0.0",
|
26
|
+
# "n_queries": 0,
|
27
|
+
# "cache_hit_rate": 0.0,
|
28
|
+
# "command_version": 1,
|
29
|
+
# "default_command_version": 1,
|
30
|
+
# "max_command_version": 2
|
31
|
+
# }
|
32
|
+
# ]
|
33
|
+
```
|
34
|
+
|
35
|
+
### lazy-pp-json
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
example_json = "[[0,1395671860.99505,2.50339508056641e-05],{"alloc_count":136,"starttime":1395671856,"uptime":4,"version":"4.0.0","n_queries":0,"cache_hit_rate":0.0,"command_version":1,"default_command_version":1,"max_command_version":2}]"
|
39
|
+
pp Lazy::PP::JSON.new(example_json)
|
40
|
+
#=>
|
41
|
+
[
|
42
|
+
[0, 1395671860.99505, 2.50339508056641e-05],
|
43
|
+
{
|
44
|
+
"alloc_count" :136,
|
45
|
+
"starttime" :1395671856,
|
46
|
+
"uptime" :4,
|
47
|
+
"version" :"4.0.0",
|
48
|
+
"n_queries" :0,
|
49
|
+
"cache_hit_rate" :0.0,
|
50
|
+
"command_version" :1,
|
51
|
+
"default_command_version":1,
|
52
|
+
"max_command_version" :2
|
53
|
+
}
|
54
|
+
]
|
55
|
+
|
56
|
+
```
|
57
|
+
|
9
58
|
## Installation
|
10
59
|
|
11
60
|
$ gem install lazy-pp-json
|
data/lib/lazy/pp/json.rb
CHANGED
data/lib/lazy/pp/json/version.rb
CHANGED
data/test/testutils.rb
CHANGED
@@ -8,16 +8,14 @@ module Lazy
|
|
8
8
|
class JSON
|
9
9
|
module TestUtils
|
10
10
|
|
11
|
-
|
12
|
-
LONG_STRING = "
|
11
|
+
LONG_STRING_LENGTH = Lazy::PP::JSON::MAX_CHARACTER_SIZE + 2
|
12
|
+
LONG_STRING = "a" * LONG_STRING_LENGTH
|
13
13
|
SPLITED_LONG_ARRAY = [
|
14
|
-
LONG_STRING[0..
|
15
|
-
LONG_STRING[
|
14
|
+
LONG_STRING[0..LONG_STRING_LENGTH/2-1],
|
15
|
+
LONG_STRING[LONG_STRING_LENGTH/2..-1]
|
16
16
|
]
|
17
17
|
|
18
|
-
SPLITED_LONG_ARRAY_STRING =
|
19
|
-
["#{LONG_STRING[0..25]}", "#{LONG_STRING[26..51]}"]
|
20
|
-
ACTUAL
|
18
|
+
SPLITED_LONG_ARRAY_STRING = SPLITED_LONG_ARRAY.inspect
|
21
19
|
|
22
20
|
private
|
23
21
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lazy-pp-json
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yoshihara
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -80,7 +80,57 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
-
description:
|
83
|
+
description: |-
|
84
|
+
Lazy pp json responses.
|
85
|
+
|
86
|
+
### JSON#pretty_generate
|
87
|
+
|
88
|
+
```ruby
|
89
|
+
example_json = "[[0,1395671860.99505,2.50339508056641e-05],{"alloc_count":136,"starttime":1395671856,"uptime":4,"version":"4.0.0","n_queries":0,"cache_hit_rate":0.0,"command_version":1,"default_command_version":1,"max_command_version":2}]"
|
90
|
+
puts JSON.pretty_generate(JSON.parse(example_json))
|
91
|
+
#=>
|
92
|
+
# [
|
93
|
+
# [
|
94
|
+
# 0,
|
95
|
+
# 1395671860.99505,
|
96
|
+
# 2.50339508056641e-05
|
97
|
+
# ],
|
98
|
+
# {
|
99
|
+
# "alloc_count": 136,
|
100
|
+
# "starttime": 1395671856,
|
101
|
+
# "uptime": 4,
|
102
|
+
# "version": "4.0.0",
|
103
|
+
# "n_queries": 0,
|
104
|
+
# "cache_hit_rate": 0.0,
|
105
|
+
# "command_version": 1,
|
106
|
+
# "default_command_version": 1,
|
107
|
+
# "max_command_version": 2
|
108
|
+
# }
|
109
|
+
# ]
|
110
|
+
```
|
111
|
+
|
112
|
+
### lazy-pp-json
|
113
|
+
|
114
|
+
```ruby
|
115
|
+
example_json = "[[0,1395671860.99505,2.50339508056641e-05],{"alloc_count":136,"starttime":1395671856,"uptime":4,"version":"4.0.0","n_queries":0,"cache_hit_rate":0.0,"command_version":1,"default_command_version":1,"max_command_version":2}]"
|
116
|
+
pp Lazy::PP::JSON.new(example_json)
|
117
|
+
#=>
|
118
|
+
[
|
119
|
+
[0, 1395671860.99505, 2.50339508056641e-05],
|
120
|
+
{
|
121
|
+
"alloc_count" :136,
|
122
|
+
"starttime" :1395671856,
|
123
|
+
"uptime" :4,
|
124
|
+
"version" :"4.0.0",
|
125
|
+
"n_queries" :0,
|
126
|
+
"cache_hit_rate" :0.0,
|
127
|
+
"command_version" :1,
|
128
|
+
"default_command_version":1,
|
129
|
+
"max_command_version" :2
|
130
|
+
}
|
131
|
+
]
|
132
|
+
|
133
|
+
```
|
84
134
|
email:
|
85
135
|
- h.yoshihara@everyleaf.com
|
86
136
|
executables:
|
@@ -124,7 +174,7 @@ rubyforge_project:
|
|
124
174
|
rubygems_version: 2.2.0
|
125
175
|
signing_key:
|
126
176
|
specification_version: 4
|
127
|
-
summary: Lazy pp json responses
|
177
|
+
summary: Lazy pp json responses
|
128
178
|
test_files:
|
129
179
|
- test/run-test.rb
|
130
180
|
- test/test_array.rb
|