dslh 0.4.6 → 0.4.7

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: 718c1c22002ee0dc8df5b88ad0b681b4670b459a
4
- data.tar.gz: 7c658477f9b9cc6c621fb5c97fdb9a5d966db872
3
+ metadata.gz: 384dc946f3f3d868008d2795fa6e83ca0cac2a6d
4
+ data.tar.gz: aaeac51e7a989eb285890d40615d3ae984a2effb
5
5
  SHA512:
6
- metadata.gz: 10b485d527f1212db9c8c47110bd8e06d621edcb27289398254fdca5c4727e527285c30e7d04ed61b6c2f2b3807049f45706ed081eaaabc5cd0c3ba8d30a42cd
7
- data.tar.gz: 7547c08154e0959c7fdb5f7836ba82271c89b32857e2b5f0381a0186912e454aa8889a0df4b692a85ae463058f7cab9edd40022de8916acb7b0d94173bcd6dd4
6
+ metadata.gz: 5ea3a48d2a14832c2a01412b2b116bfa85ad5883151968b714c03022e712887fd51affe41408f7f0b4190a556d573a547644b3c334fcc12360acda39c8d743a4
7
+ data.tar.gz: 83e180695a786f0babe25c097dc1ecefd15fc6941bb201424dd9c1b9e9ab794d7c31687e34a86fee3eaaff768c874f31cdc8d4e043736587473dbf60596b2cb1
@@ -37,6 +37,7 @@ class Dslh
37
37
  :time_inspecter,
38
38
  :use_braces_instead_of_do_end,
39
39
  :value_conv,
40
+ :use_heredoc_for_multi_line,
40
41
  ]
41
42
 
42
43
  class << self
@@ -83,6 +84,7 @@ class Dslh
83
84
  :dump_old_hash_array_format => false,
84
85
  :force_dump_braces => false,
85
86
  :use_braces_instead_of_do_end => false,
87
+ :use_heredoc_for_multi_line => false,
86
88
  }.merge(options)
87
89
 
88
90
  @options[:key_conv] ||= (@options[:conv] || proc {|i| i.to_s })
@@ -318,7 +320,13 @@ class Dslh
318
320
  value = @options[:time_inspecter].call(value)
319
321
  value_buf.puts(' ' + value)
320
322
  else
321
- value_buf.puts(' ' + value.inspect)
323
+ if @options[:use_heredoc_for_multi_line] \
324
+ and value.kind_of?(String) \
325
+ and value.match(/\R/)
326
+ value_buf.puts(' ' + "<<-EOS\n#{value}\nEOS")
327
+ else
328
+ value_buf.puts(' ' + value.inspect)
329
+ end
322
330
  end
323
331
  end
324
332
 
@@ -1,3 +1,3 @@
1
1
  class Dslh
2
- VERSION = '0.4.6'
2
+ VERSION = '0.4.7'
3
3
  end
@@ -545,6 +545,54 @@ end
545
545
  EOS
546
546
  end
547
547
 
548
+ it 'should convert hash to dsl with use_heredoc_for_multi_line' do
549
+ h = {"glossary"=>
550
+ {"title"=>"example glossary",
551
+ "description" => "example\nglossary",
552
+ "GlossDiv"=>
553
+ {"title"=>"S",
554
+ "GlossList"=>
555
+ {"GlossEntry"=>
556
+ {"ID"=>"SGML",
557
+ "SortAs"=>"SGML",
558
+ "GlossTerm"=>"Standard Generalized Markup Language",
559
+ "Acronym"=>"SGML",
560
+ "Abbrev"=>"ISO 8879:1986",
561
+ "GlossDef"=>
562
+ {"para"=>
563
+ "A meta-markup language, used to create markup languages such as DocBook.",
564
+ "GlossSeeAlso"=>["GML", "XML"]},
565
+ "GlossSee"=>"markup"}}}}}
566
+
567
+ dsl = Dslh.deval(h, :use_heredoc_for_multi_line => true)
568
+ expect(dsl).to eq(<<-EOT)
569
+ glossary do
570
+ title "example glossary"
571
+ description <<-EOS
572
+ example
573
+ glossary
574
+ EOS
575
+ GlossDiv do
576
+ title "S"
577
+ GlossList do
578
+ GlossEntry do
579
+ ID "SGML"
580
+ SortAs "SGML"
581
+ GlossTerm "Standard Generalized Markup Language"
582
+ Acronym "SGML"
583
+ Abbrev "ISO 8879:1986"
584
+ GlossDef do
585
+ para "A meta-markup language, used to create markup languages such as DocBook."
586
+ GlossSeeAlso "GML", "XML"
587
+ end
588
+ GlossSee "markup"
589
+ end
590
+ end
591
+ end
592
+ end
593
+ EOT
594
+ end
595
+
548
596
  it 'does not allow duplicate key' do
549
597
  expect {
550
598
  Dslh.eval do
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.4.6
4
+ version: 0.4.7
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-12-04 00:00:00.000000000 Z
11
+ date: 2017-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  version: '0'
108
108
  requirements: []
109
109
  rubyforge_project:
110
- rubygems_version: 2.5.1
110
+ rubygems_version: 2.5.2
111
111
  signing_key:
112
112
  specification_version: 4
113
113
  summary: It define Hash as a DSL.