dslh 0.3.7 → 0.3.8

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: 7390c52a2f651e8ae19478c3b499fd156bfe9ce8
4
- data.tar.gz: a417585a38c5a06e1cdfff655c60edbe5f50cb0e
3
+ metadata.gz: 7267513e3fe1badab65d769c081bb53f2404de4d
4
+ data.tar.gz: 63b83baed10b9303f5078ab2d6b63231d85dc602
5
5
  SHA512:
6
- metadata.gz: 9fd88853d1941b413207e4b5616e6a20f38181f805e8a9038cfefcc51f993162318d368440c8941390abec7354f5be41a5414a01eba5075928bb04b17b384ad2
7
- data.tar.gz: dae0498effdc33b5086711927e6d786433ac94dbe3febab0693f9d0cc8c70d52ad4a2f34ad60daadb38b042fe3a7dbab4666b367a284f0b04b7993ea18fc27bd
6
+ metadata.gz: 47010ec35a9c6c7e963569a3ecd6605d44c803efcd0911a65a142fe4d58d33c10a308972830d840498d919fcfd6289e1dc375361f63b3060d0fb02518ed4bfc7
7
+ data.tar.gz: c7dd1ad51654a185a51b2722e583ca261866d95c22d5a5048ebc16f7c8953275ade78eca8384e7f0c9ced5d27ce2bff7f57386b46abaa72a5338ed7b0c5e6539
data/lib/dslh.rb CHANGED
@@ -134,7 +134,7 @@ class Dslh
134
134
 
135
135
  case value
136
136
  when Hash
137
- if exclude_keys?(value.keys) or value.values.any? {|v| v == [] }
137
+ if exclude_keys?(value.keys)
138
138
  value_buf.puts('(' + ("\n" + value.pretty_inspect.strip).gsub("\n", "\n" + next_indent) + ')')
139
139
  else
140
140
  nested = true
@@ -143,7 +143,9 @@ class Dslh
143
143
  value_buf.puts(indent + (@options[:use_braces_instead_of_do_end] ? '}' : 'end'))
144
144
  end
145
145
  when Array
146
- if value.any? {|v| [Array, Hash].any? {|c| v.kind_of?(c) }}
146
+ if value.empty?
147
+ value_buf.puts(" []")
148
+ elsif value.any? {|v| [Array, Hash].any? {|c| v.kind_of?(c) }}
147
149
  nested = true
148
150
 
149
151
  if not @options[:dump_old_hash_array_format] and value.all? {|i| i.kind_of?(Hash) and not exclude_keys?(i.keys) }
data/lib/dslh/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Dslh
2
- VERSION = '0.3.7'
2
+ VERSION = '0.3.8'
3
3
  end
data/spec/dslh_spec.rb CHANGED
@@ -2434,6 +2434,51 @@ end
2434
2434
  EOS
2435
2435
  end
2436
2436
 
2437
+ it 'deval to hash from dsl that include empty array argument' do
2438
+ dsl = <<-EOS
2439
+ glossary do
2440
+ title "example glossary"
2441
+ GlossDiv do
2442
+ title "S"
2443
+ GlossList do
2444
+ GlossEntry do
2445
+ ID "SGML"
2446
+ SortAs "SGML"
2447
+ GlossTerm "Standard Generalized Markup Language"
2448
+ Acronym "SGML"
2449
+ Abbrev "ISO 8879:1986"
2450
+ GlossDef do
2451
+ para "A meta-markup language, used to create markup languages such as DocBook."
2452
+ GlossSeeAlso []
2453
+ end
2454
+ GlossSee "markup"
2455
+ end
2456
+ end
2457
+ end
2458
+ end
2459
+ EOS
2460
+
2461
+ h = Dslh.eval(dsl)
2462
+ expect(h).to eq(
2463
+ {"glossary"=>
2464
+ {"title"=>"example glossary",
2465
+ "GlossDiv"=>
2466
+ {"title"=>"S",
2467
+ "GlossList"=>
2468
+ {"GlossEntry"=>
2469
+ {"ID"=>"SGML",
2470
+ "SortAs"=>"SGML",
2471
+ "GlossTerm"=>"Standard Generalized Markup Language",
2472
+ "Acronym"=>"SGML",
2473
+ "Abbrev"=>"ISO 8879:1986",
2474
+ "GlossDef"=>
2475
+ {"para"=>
2476
+ "A meta-markup language, used to create markup languages such as DocBook.",
2477
+ "GlossSeeAlso"=>[]},
2478
+ "GlossSee"=>"markup"}}}}}
2479
+ )
2480
+ end
2481
+
2437
2482
  it 'should be hash that include empty array' do
2438
2483
  h = {"glossary"=>
2439
2484
  {"title"=>"example glossary",
@@ -2465,10 +2510,10 @@ glossary do
2465
2510
  GlossTerm "Standard Generalized Markup Language"
2466
2511
  Acronym "SGML"
2467
2512
  Abbrev "ISO 8879:1986"
2468
- GlossDef(
2469
- {"para"=>
2470
- "A meta-markup language, used to create markup languages such as DocBook.",
2471
- "GlossSeeAlso"=>[]})
2513
+ GlossDef do
2514
+ para "A meta-markup language, used to create markup languages such as DocBook."
2515
+ GlossSeeAlso []
2516
+ end
2472
2517
  GlossSee "markup"
2473
2518
  end
2474
2519
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dslh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7
4
+ version: 0.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Sugawara
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-25 00:00:00.000000000 Z
11
+ date: 2016-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler