lazy-pp-json 0.0.4 → 0.0.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bed24ae16f915588c3a5feb5636c9b3e42181534
4
- data.tar.gz: 510e16a5a6e611ac79b55c9c871d11e7838effa4
3
+ metadata.gz: 579c37d4c1e53e942bc73727cf127a6753c2844b
4
+ data.tar.gz: 29d5ac23cdcb5e494f00dbb1e9008cbdfc674f06
5
5
  SHA512:
6
- metadata.gz: 9a375c877f5ab675c1cf002b48b6151dfbbc646fa636cf3ea46abfdb05b6a5a2aa7cd63933f586f96bc07c104b85d54dd763e5325605e0423e27c798168b1a9f
7
- data.tar.gz: df45f79cd8b8a81a007002e14e02f5824c0bfbca0140bb052a860e2c2375f7757a4acd0dfd34b48481a8f3fc2b6f47170f292e2fec2c26d2344726fa332e6702
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
@@ -8,7 +8,7 @@ module Lazy
8
8
  class JSON < String
9
9
  INDENT_SIZE = 2
10
10
  INDENT = ' ' * INDENT_SIZE
11
- MAX_CHARACTER_SIZE = 40
11
+ MAX_CHARACTER_SIZE = 60
12
12
 
13
13
  def initialize(raw, indent_count=nil)
14
14
  super(raw)
@@ -3,7 +3,7 @@
3
3
  module Lazy
4
4
  module PP
5
5
  class JSON < String
6
- VERSION = "0.0.4"
6
+ VERSION = "0.0.5"
7
7
  end
8
8
  end
9
9
  end
@@ -8,16 +8,14 @@ module Lazy
8
8
  class JSON
9
9
  module TestUtils
10
10
 
11
- # 52 chars
12
- LONG_STRING = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
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..25],
15
- LONG_STRING[26..51]
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 = <<ACTUAL
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
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-15 00:00:00.000000000 Z
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: Lazy pp json responses.
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