dslh 0.3.4 → 0.3.5

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: 23606816e11bb7d500a3d596f1d7a9d0402e7019
4
- data.tar.gz: dc4b77c1763562bfc9fe2f7cab15881b93239d11
3
+ metadata.gz: accc36f444e49fdce316464ef42d7ab5dbee863c
4
+ data.tar.gz: 912a67f6db4edb45f73ef454a35016b4b42d1b9a
5
5
  SHA512:
6
- metadata.gz: 18595e8bc2cd2cb93ebb1905957010af282ad3405e216972b1861317c341ee02599c3799725a83702213a5927c548bdcb15035da31308e39b0b4c9e4831e9697
7
- data.tar.gz: 1e012c9cbb59d168111f362104af69656c1d0b8b57e58bde707eb338a928bcd40c6a45893a2c15891b14c8eed9a42339de27667a0b404c48e9870343c8fc4c46
6
+ metadata.gz: e888126dcbbeb1b3045b38fe46a21ff9df09e4b3a1d65d59c93ed6f901f95359ca7102cbfabd73222c96ee38868e5034543199749107996b95ff7063b971af90
7
+ data.tar.gz: cc3ec0b4b6519080bec3742e47bde94d9d32f1c7cf01e1d3183491a533f6f21d1d67f49b3b31a28e2d318dc8796e4e934c5e5519266747f53c78b894dda076db
data/README.md CHANGED
@@ -124,3 +124,32 @@ puts Dslh.deval(h)
124
124
  # end
125
125
  # end
126
126
  ```
127
+
128
+ ### Hash List
129
+
130
+ ```ruby
131
+ h = Dslh.eval do
132
+ glossary do |*|
133
+ title "example glossary"
134
+ date "2016-05-21 00:00:00 UTC"
135
+ end
136
+ glossary do |*|
137
+ title "example glossary2"
138
+ date "2016-05-21 00:01:00 UTC"
139
+ end
140
+ glossary2 do |*|
141
+ title "example glossary"
142
+ date "2016-05-21 00:00:00 UTC"
143
+ end
144
+ end
145
+
146
+ pp h
147
+ #=> {"glossary"=>[
148
+ # {"title"=>"example glossary",
149
+ # "date"=>'2016-05-21 00:00:00 UTC'},
150
+ # {"title"=>"example glossary2",
151
+ # "date"=>'2016-05-21 00:01:00 UTC'}],
152
+ # "glossary2"=>[
153
+ # {"title"=>"example glossary",
154
+ # "date"=>'2016-05-21 00:00:00 UTC'}]}
155
+ ```
data/lib/dslh.rb CHANGED
@@ -41,6 +41,7 @@ class Dslh
41
41
  @options = {
42
42
  :time_inspecter => method(:inspect_time),
43
43
  :dump_old_hash_array_format => false,
44
+ :force_dump_braces => false
44
45
  }.merge(options)
45
46
 
46
47
  @options[:key_conv] ||= (@options[:conv] || proc {|i| i.to_s })
@@ -185,7 +186,7 @@ class Dslh
185
186
  value_buf.print(indent + ']')
186
187
  end
187
188
  end
188
- elsif value.length == 1
189
+ elsif @options[:force_dump_braces] or value.length == 1
189
190
  value_buf.puts(' ' + value.inspect)
190
191
  else
191
192
  value_buf.puts(' ' + value.map {|v|
data/lib/dslh/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Dslh
2
- VERSION = '0.3.4'
2
+ VERSION = '0.3.5'
3
3
  end
data/spec/dslh_spec.rb CHANGED
@@ -2708,4 +2708,47 @@ end
2708
2708
  "date"=>'2016-05-21 00:00:00 UTC'}]}
2709
2709
  )
2710
2710
  end
2711
+
2712
+ it 'should convert hash to dsl (disable omit braces)' do
2713
+ h = {"glossary"=>
2714
+ {"title"=>"example glossary",
2715
+ "GlossDiv"=>
2716
+ {"title"=>"S",
2717
+ "GlossList"=>
2718
+ {"GlossEntry"=>
2719
+ {"ID"=>"SGML",
2720
+ "SortAs"=>"SGML",
2721
+ "GlossTerm"=>"Standard Generalized Markup Language",
2722
+ "Acronym"=>"SGML",
2723
+ "Abbrev"=>"ISO 8879:1986",
2724
+ "GlossDef"=>
2725
+ {"para"=>
2726
+ "A meta-markup language, used to create markup languages such as DocBook.",
2727
+ "GlossSeeAlso"=>["GML", "XML"]},
2728
+ "GlossSee"=>"markup"}}}}}
2729
+
2730
+ dsl = Dslh.deval(h, :force_dump_braces => true)
2731
+ expect(dsl).to eq(<<-EOS)
2732
+ glossary do
2733
+ title "example glossary"
2734
+ GlossDiv do
2735
+ title "S"
2736
+ GlossList do
2737
+ GlossEntry do
2738
+ ID "SGML"
2739
+ SortAs "SGML"
2740
+ GlossTerm "Standard Generalized Markup Language"
2741
+ Acronym "SGML"
2742
+ Abbrev "ISO 8879:1986"
2743
+ GlossDef do
2744
+ para "A meta-markup language, used to create markup languages such as DocBook."
2745
+ GlossSeeAlso ["GML", "XML"]
2746
+ end
2747
+ GlossSee "markup"
2748
+ end
2749
+ end
2750
+ end
2751
+ end
2752
+ EOS
2753
+ end
2711
2754
  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.4
4
+ version: 0.3.5
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-22 00:00:00.000000000 Z
11
+ date: 2016-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler