babl-json 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1bad3eaac421de5e967efa6a17096a9a95529174
4
- data.tar.gz: e722e283eb9a3004a935a28bac8b09f8f94a10e6
3
+ metadata.gz: e01613db4c4f669f2f64a0bdbc324bfe38074b44
4
+ data.tar.gz: 62b10c1b72ad3f2773f3e655099d90453d3f6b1d
5
5
  SHA512:
6
- metadata.gz: fa8c6c330b936f4c1b4a3a455bba8491a43911c7c644d161b233215e8a436e2091722e6d85c0005d2b6aa89f5641d69dddb8d50ebd1cc49010368caa434633fb
7
- data.tar.gz: 9a6a76cc67edcf4f7f2b952b645d5fa974f492294dde354925c9eb3aa794dd3c210689c55b082923ee4682eaaa960cc6db540dd78776cc10ac7fc6cb83758bc6
6
+ metadata.gz: 3ca13bb367880694af386e52197753e1e4a1a85aa624bc59c05af691fe98227e840ea5c54e0124eb5401988aa01393657c90c92abd278c3230664046ff638406
7
+ data.tar.gz: bcbecaa3869e2c8f2c04c4fc565eef473ae5219a39d92c2d6c5dd950eaeaba2d03f66017df98859ecef1ee48e6da9ff919452a76965644ddad32324035553960
@@ -12,7 +12,12 @@ module Babl
12
12
  end
13
13
 
14
14
  def json
15
- { anyOf: choice_set.map(&:json) }
15
+ primitives, complex = choice_set.partition { |choice| Primitive === choice }
16
+
17
+ simple_enum = { enum: primitives.map(&:value) }
18
+ return simple_enum if complex.empty?
19
+
20
+ { anyOf: complex.map(&:json) + (primitives.empty? ? [] : [simple_enum]) }
16
21
  end
17
22
 
18
23
  # Perform simple transformations in order to reduce the size of the generated
data/lib/babl/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Babl
3
- VERSION = '0.5.0'
3
+ VERSION = '0.5.1'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: babl-json
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frederic Terrazzoni
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-27 00:00:00.000000000 Z
11
+ date: 2018-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: coveralls