neatjson 0.1 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/neatjson.rb +11 -3
  3. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eeaca511388e6d3cad43037baa89da3a8a09150e
4
- data.tar.gz: cfe5814113721a431a545d54f72897de17a6e79c
3
+ metadata.gz: 64c5854c172eb390bfde86510249681edec98bb8
4
+ data.tar.gz: 9fb24cd03782f06920f6dece4a387162621bc289
5
5
  SHA512:
6
- metadata.gz: 60071be202ba2346d54125b8e37c0f7eef1d3636f0271c822efdfb0d1dfcca94b9cde15b732087bd689caa78af018eba7c996a036e718b0a42bf69a573bc8838
7
- data.tar.gz: 1c81000e0dd2b8d79f63eb51dba7a0ddf2356a4624768c32713abf5ede4ef6a0c879c9ddb3acd4b2fed04c3a133cbd9d59742632034d2ab69e1339e3996a3f7c
6
+ metadata.gz: 7b7126888caaeaf5396ff4ba003865ef2d32f8d2b716907ac77a828c3c216e9dc9ab157d1a0689b9c22229e3a76c53d5a7b8be8da3eb2763585d1243e2ea904a
7
+ data.tar.gz: e043570423bc55294a2176872fe68bfbb8fddee7f1ad0a001c053ee00345434f9be51ba5e97c579836c9f11678413a7fef0b89e469c6890aebf12656db47ab10
data/lib/neatjson.rb CHANGED
@@ -83,9 +83,17 @@ module JSON
83
83
  longest = keyvals.map(&:first).map(&:length).max
84
84
  keyvals.each{ |k,v| k.replace( "%-#{longest}s" % k ) }
85
85
  end
86
- pieces = keyvals.map{ |k,v| "#{k}#{colon}#{build[v,'']}" }
87
- pieces.last << opad << "}"
88
- pieces.join ",\n"
86
+ keyvals.map! do |k,v|
87
+ indent2 = " "*"#{k}#{colon}".length
88
+ one_line = "#{k}#{colon}#{build[v,'']}"
89
+ if opts[:wrap] && (one_line.length > opts[:wrap]) && (v.is_a?(Array) || v.is_a?(Hash))
90
+ "#{k}#{colon}#{build[v,indent2].lstrip}"
91
+ else
92
+ one_line
93
+ end
94
+ end
95
+ keyvals.last << opad << "}"
96
+ keyvals.join ",\n"
89
97
  else
90
98
  keyvals = o.map{ |k,v| ["#{indent}#{opts[:indent]}#{k.to_s.inspect}",v] }
91
99
  keyvals = keyvals.sort_by(&:first) if opts[:sorted]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neatjson
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: '0.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin Kistner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-15 00:00:00.000000000 Z
11
+ date: 2015-04-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: gavin@phrogz.net
@@ -36,8 +36,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
36
36
  version: '0'
37
37
  requirements: []
38
38
  rubyforge_project:
39
- rubygems_version: 2.0.14
39
+ rubygems_version: 2.4.5
40
40
  signing_key:
41
41
  specification_version: 4
42
42
  summary: Pretty, powerful JSON generation.
43
43
  test_files: []
44
+ has_rdoc: yard